« first day (1179 days earlier)      last day (3810 days later) » 

7:01 PM
would you say that my good answers exists in the null space?
 
@MichaelT holy shit, I didn't know you knew quantitative financial analysis!
 
user41796
@JimmyHoffa links or it didn't happen (ie WAT?)
 
user55340
@JimmyHoffa Apparently I need to get a new job that involves more digits...
 
aka you can make basic math sound fancy!
 
user41796
random, likely dumb, question: Why do all the remote helicopter thingy's have 4 sets of rotors instead of three? example: costco.com/…
 
user55340
7:06 PM
@GlenH7 I assume more stability.
 
user55340
It appears also it has to do with torque. An even number would cancel each other out.
 
@GlenH7 think about directional movements, 3 gives you an amount but with 4 imagine diagonal powerup/powerdowns to give you various rotational dynamics etc
 
user41796
@MichaelT I guess that makes sense. If you center an XY plot over the top of the not-a-helicopter thingy, then your controls only have to worry about the rotor in each quadrant
 
user55340
 
user55340
1923. Stayed aloft for 2 minutes, 45 seconds.
 
user55340
7:08 PM
{| |} The de Bothezat helicopter, also known as the Jerome-de Bothezat Flying Octopus, was an experimental quadrotor helicopter built for the United States Army Air Service by George de Bothezat in the early 1920s, and was said at the time to be the first successful helicopter. Although its four massive six-bladed rotors allowed the craft to successfully fly, it suffered from complexity, control difficulties, and high pilot workload, and was reportedly only capable of forwards flight in a favorable wind. The Army canceled the program in 1924, and the aircraft was scrapped. Development an...
 
user41796
I'm trying to think through the comment about torque and cancelling out
 
@GlenH7 Exactly, segmenting the plane into 3 sections as opposed to 4 will work, but then you're going to get less symettrical movements when you power up/down any of the 3 and you've got much more complex accounting for it by the other 2
 
user41796
I think the maths would be more complicated with 3 rotors instead of 4 for both stability and directional motion
 
user55340
 
user55340
From the Flight control section in...
 
user55340
7:09 PM
A quadcopter, also called a quadrotor helicopter, quadrocopter, quadrotor, is a multicopter that is lifted and propelled by four rotors. Quadcopters are classified as rotorcraft, as opposed to fixed-wing aircraft, because their lift is generated by a set of revolving narrow-chord airfoils. Unlike most helicopters, quadcopters generally use symmetrically pitched blades; these can be adjusted as a group, a property known as 'collective', but not individually based upon the blade's position in the rotor disc, which is called 'cyclic' (see helicopter). Control of vehicle motion is achieved by...
 
user55340
> Four rotors are used, rather than three, six or some other number, because four offers two convenient axes of symmetry. With four rotors it is easy to imbalance side-to-side thrust, thus giving a roll movement. As this pair of side rotors rotate in the same direction, and one is increased whilst the other is decreased, the overall torque reaction and yawing force remains zero.
 
@GlenH7 you want it to go right, power down the left 2 rotors, a triangle to go right first you need to rotate it to have one rotor symettrically to the left and power it down to get the same effect
 
user41796
okay, that makes sense. materials cost is higher, but overall system design is easier
 
user41796
had been thinking from my woodworking days that a stool with three legs is a lot easier to balance than with four legs
 
@GlenH7 If you're sitting on the quadcopter you're doing it wrong.
 
user41796
7:12 PM
@JimmyHoffa oh, you have no idea...
 
user55340
> From the very start nitroglycerine was produced on the batch process plant which, with its "one-legged stool" (to prevent the operator falling asleep) is now almost a logotype for dynamite manufacture.
 
user55340
You need to go for a 1 legged stool.
 
user55340
On copter designs... consider that the helicopter is actually a 2 system in most cases - the tail acting to counter the torque of the lift.
 
user55340
So that gets you the design of the 1 and 2, the 3 then gets into symmetrical issues - you've got torque again to contend with. 4 is the known stable design, 5 and above get into issues of "how do you get the other controls" of pitch and yaw.
 
user41796
@MichaelT voodoo magic!
 
user55340
7:16 PM
(and now we know the real secrets of "engineers")
 
user41796
"magic happens here"
 
user55340
Which is followed by profit, of course.
 
user41796
no profit means it's not worth the while
 
user55340
Oh, @GlenH7 Helpful flag #666 was a migration to UX.SE. Still a bit to catch up to you and gnat.
 
user41796
I have a few questions flagged to go through and clean out the comments with. Great way to bump flag counts.
 
user55340
7:23 PM
You should ask Undo about his comment clean outs... getting the entire data dump and crunching them for obsoleteness.
 
user55340
Consider also, cleaning ancient comments can help get questions marked as 'abandoned' and push to the roomba.
 
user41796
@MichaelT I think his promise of unleashing it on P.SE was just an empty threat... :-)
 
user55340
> If the question is more than 365 days old, and ...

has a score of 0 or a score of 1 with a deleted owner
has no answers
is not locked
has a viewcount <= the age of the question in days times 1.5
has 1 or 0 comments
... it will be automatically deleted.
 
user41796
If you're serious about coming to Programmers next, please drop into chat (The Whiteboard) and let us know. You'll find a number of like-minded users who would be happy to review, flag, and help clear out stale comments. — GlenH7 13 secs ago
 
user41796
@MichaelT oh blech. I forgot that the crap (closed, no answer, not dup, ...) questions need a -1 to get automatically sloughed to /dev/null. I thought they would go at 0 too.
 
user55340
7:29 PM
Old questions at 0 will go... the bit I quoted hits open abandoned questions.
 
user55340
And poorly found dups...
 
user41796
@MichaelT ok, then I don't feel so bad.
 
user55340
(I should write a "comments holding it back" query for things to go find and flag)
 
user41796
@MichaelT # of comments shows up in data explorer?
 
user41796
I didn't think it did, but I'm clearly not a data guru.
 
user55340
7:32 PM
@GlenH7 I can do it as part of another query...
 
user55340
 
user55340
(yea, there's a bug there - flags for close where getting counted as close in the review review)
 
user41796
@MichaelT good thing no one said "leave open." That would stick out like a sore thumb
 
user55340
@user109734 - The reasonable rate to charge the customer, is the rate, you agreed to before you started the work. — Ramhound 9 mins ago
 
user55340
7:47 PM
@GlenH7 I'm conflicted on that android file sharing... I actually had an early cv on it, but retracted it (I'm fairly sure that if it is, it can still easily garner the 5 votes).
 
user55340
The full set of the solution to the various parts needed (not recommending tools / libraries) could be a valid question.
 
user41796
@MichaelT as it's currently phrased, I think it's off-topic. It's currently an implementation issue. "Should I plug my phone in or should I write a conduit?" is kind of how it reads.
 
user55340
As I said, I'm conflicted on it.
 
user41796
Alternately, he just needs to write a service and be done with it. There are (too) many ways to skin that issue though.
 
user55340
Btw, @GlenH7 did you see my 10k VLQ auto flag question?
 
user55340
7:52 PM
2
Q: 10k tools, automatic low quality flags and flagging

MichaelTWhen looking at the 10k tools, I saw a little '1' next to the flags and thought I'd go poke at it to see what it was. It was a very short answer, not more than a poorly formed sentence. But it vaguely tried to answer the question. Elsequestion - Why is this question not low quality? The "v...

 
user41796
To clarify my vote-to-close comment. There are too many options for consideration in this case, which would also imply a "too broad" reason for closing. An FTP service is one route; services in the web app server are another; ... there are several ways to do this without using some intermediary cloud storage service. Your statement of "I'm looking for something..." sounds closer to a resource request ("tell me what library to use") which would also be off-topic as Programmers doesn't provide off-site resource recommendations. — GlenH7 10 secs ago
 
user41796
@MichaelT props for pulling down an answer from Tim.
 
user55340
@GlenH7 I'm still a bit confused about the proper approach though.
 
user55340
And this is the review when it hit the VLQ review queue...
 
user41796
8:01 PM
I don't know that there is a proper approach. 10k flag reviews have always seemed iffy for me.
 
user55340
I suspect its more important on SO, where the flag count is much higher... the 10k's adding their (non-existent) flag weight to a flag would move it up in the list back then.
 
user41796
I've been burned by reviewing autogenerated flags by the system, which merely caused minor grief between the mods and me. Net result was that I was told to ignore the obvious automatic ones, and an MSO request to remove the automatic ones from the 10k tools.
 
user55340
Or if disputed, remove it from the list.
 
user55340
Where the flag count is lower (P.SE), we don't save too much work from the mods... and I suspect there are more mods on the flag activity than there are 10k'ers reviewing them.
 
user41796
@MichaelT I'd say that isn't VLQ. It's also not not-an-answer because you could twist it to claim it is an answer. But it's definitely delete worthy
 
user55340
8:04 PM
@GlenH7 Exactly my conundrum.
 
user41796
@MichaelT since they have taken the notification off of the toolbar, I haven't really been checking the flags. But yeah, even when I saw them they really weren't that frequent.
 
user41796
There are several aspects of the 10k tools that are great in concept and poor in execution.
 
user55340
I'm still thinking maybe I should have flagged it with "Bleh" as a mod special note.
 
user41796
beating on the flag issue - so what if I agreed with the flag? Does my flagging agreement really do anything to help the mods? From what I can tell, the answer is "not really"
 
now I want to tag everything as bleh
 
user55340
8:05 PM
@Ampt Did you see the Bleh conversations?
 
you mean up there ^?
 
user41796
The evil mod responsible for "bleh" would never see the results of his handiwork that way.
 
user55340

Bleh! Leave this for Robert to deal with.

Nov 21 at 20:08, 3 minutes total – 6 messages, 3 users, 1 star

Bookmarked yesterday by MichaelT

 
user55340
And then part 2 at:
 
user55340
Nov 21 at 22:53, by Robert Harvey
lolwut? You mean you actually take my advice? You poor soul.
 
user41796
8:07 PM
android file sharing question was deleted by the owner
 
lmfao
if you don't know me by nooooooow
 
user55340
Nov 21 at 22:52, by Jimmy Hoffa
@RobertHarvey I blame you:
 
user55340
Nov 21 at 22:52, by Jimmy Hoffa
> Bleh! programmers.stackexchange.com/questions/219146/… – Jimmy Hoffa 2 hours ago declined - flags should only be used to make moderators aware of content that requires their intervention
 
user41796
I think it would be funnier to use as a custom reason on SO
 
user55340
Nov 21 at 22:59, by MichaelT
. o O ( Hmm.. some day, we'll make Jimmy a mod and then bleh all over him! )
 
8:09 PM
oh man. when are the next votes?
 
user55340
Nov 21 at 20:11, by MichaelT
BRB - flagging on SO...
 
user55340
Nov 21 at 20:12, by MichaelT
"Bleh! Leave this for Robert to deal with."
 
user41796
@Ampt That's the fun part of the whole "when I'm a mod game" -- there aren't any planned elections. And unlikely there will be one for some time.
 
user41796
So World can threaten us all he wants; ain't gonna happen. And I can blather all I want about it because ... it ain't gonna happen.
 
user41796
I feel like I just revealed there's no Easter bunny.
 
user55340
8:11 PM
If you were active on CodeReview, could have had a chance to get mod there... though only a slim one, it went to the right person.
 
user55340
10
Q: Please welcome your newest pro tem moderator

PopsI'm Pops, a Community Manager at Stack Exchange. As many of you know, one of your moderators recently stepped down for personal reasons. I'm happy to announce that a great new pro tem mod is about to take his place: Now, I could tell you about Jamal's contributions to the site, but it seems I ...

 
user41796
@MichaelT I don't have enough time to keep up with multiple sites on a regular basis
 
user55340
Their other mod did a 'grad school - industry' conversion and stepped down for lack of time.
 
@GlenH7 Iduno, you tempt the fates with statements like that, there's every possibility maple_shaft might be like "busy being puked on guys, I quit"
 
@GlenH7 damnit.... I need to grow 10k sock puppets to make it seem like programmers is massive so we can have elections and I can vote you, @MichaelT and @JimmyHoffa into office mahahaha
 
user55340
8:13 PM
Is that 10k sock puppets with 300 rep each? or one 10k sock puppet?
 
user41796
@JimmyHoffa this Fool will carelessly cast his lot into the hands of Fate then.
 
@MichaelT 10k puppets with 300 rep each obviously
 
Oct 16 at 20:31, by Jimmy Hoffa
I'm pretty sure that's how you get a diamond in fact, you go into the bathroom, close the door, look in the mirror and say...

I want to be an SE mod...
I want to be an SE mod...
I want to be an SE mod...
I want to be an SE mod...
I want to be an SE mod...and then...

Spolsky appears in your mirror and you find now *you're* the one in the mirror, and your plasticene replacement wanders off with spolsky to plug into your computer, where you are forever stuck on the other side of the mirror in an empty universe where you eventually starve to death
 
user41796
@MichaelT given that he can't get his main account past 3k yet... :-)
 
user41796
@JimmyHoffa Jeff escaped.
 
8:16 PM
@GlenH7 Says who? I think he just found a k-mart with ramen to subsist on, he's gathered others who've been trapped over there and in true maniacal end-of-days style he decided to get them together to write a forum in ruby ... ???
 
@GlenH7 Yeah but 300 rep isn't hard. I could just have them make trash answers and upvote eachother. the real problem here would be hiding that from the automated scripts
 
Nov 22 at 19:12, by Jimmy Hoffa
@gnat I couldn't be a mod, if I did I'd know what I do and I'd be forced to ban myself
 
user41796
@JimmyHoffa did he really pick ruby for his current project?
 
user41796
Hey @Undo is here! It wasn't an idle boast! Let the stale comment shredding begin!!!
 
@GlenH7 ..you didn't know? Discourse is an open source RoR forum.
 
8:19 PM
What's wrong with Ruby? :P
 
@GlenH7 You guys really want to do this?
 
user41796
@JimmyHoffa Oh, that's different since it's RoR....
 
user55340
Remember - kill all the comments on a year old question with no rep and no answers and you get community to sic the roomba on it
 
user41796
@Undo Yep. @MichaelT and @gnat would be up for clearing out old comments.
 
Hmm... Ok.
 
user41796
8:20 PM
Drives us nuts. And actually, I should leave gnat out so we can catch up with his flag counts.
 
@Undo You have no idea how serious they are here. P.SE is the promised land; we scorch the unclean here to ensure only xanadu remains.
2
 
user55340
That, and its always fun watching Yannis come into chat and go "holy flag-pocolipse!" or something of that nature.
 
user41796
@JimmyHoffa nearly just starred that, but realized it was pin worthy
 
Ok, I'll get the system set up :D
(I have a violin recital or something I'm being dragged off to, but when I get back...)
 
user41796
@Undo I'm curious to know how you pull the information and then identify the questions that need clearing
 
8:21 PM
we're cleaning out old comments?
 
user41796
@Ampt getting rid of link-only answers was merely the first step....
 
You guys are like Zealots
 
@GlenH7 Actually, I pull the comments out of the data explorer, through them into a DB, and apply magic liberally.
 
user41796
@Undo scroll back through the chat history and you'll see I'm quite comfortable with "magic happens here"
 
It's a Manish-Undo collaboration - the code is here.
 
user55340
8:23 PM
Actually, it was World that said it...
 
user55340
Aug 8 at 18:37, by World Engineer
Holy Flagpocalypse
 
user41796
@Undo Very cool. MichaelT has tweaked some of Manish's delete vote queries which we've put to good use
 
The magic is follow by the next step, profit (in the form of diamonds that I haven't seen yet).
 
user41796
@Undo 'round here they threaten us with diamonds, not reward.
3
 
(I'm missing context :P)
 
8:25 PM
@Undo The joke is that no one wants to be a mod
even though they do all the work for free
 
Oh, On Programmers... that's probably true :P
 
Whoa, what? I feel dizzy..
 
(does he always do that?)
 
Yes
 
user55340
@Undo Glen and I (moreso glen) get 'threatened' with being moderators. We're active, high rep-ish for the site, and involved with the community of the site...
 
user41796
8:26 PM
@Undo It's been kind of a running thing here. WorldEngineer started threatening some of us room owners with diamonds if we kept things up. We called his bluff and have yet to see the diamonds show up.
 
Lol
 
He's talking with Joel right now. just you wait
next thing you know they'll make you SO mods
`then you'll be sorry
 
Run!
 
user41796
@Ampt oh, there's several who frequent this room and have direct access to Joel. So no worries there.
 
user55340
I think they'd give that to Yannis first, so he could have a diamond on MSO to troll them better.
 
8:27 PM
I'm kinda worried that I'll flag too much stuff on SO and the mods will force-feed me a diamond to make me quit flagging stuff :P
(SO shudders)
 
user41796
yeah, not sure I would want to be a mod there.
 
user55340
Ahh, but they need to make up for making Andrew a mod.
 
user41796
as I would feel compelled to roll through the close review queue.
 
I wouldn't be able to stop closing things.
I would have to go on close-vote-review marathons. And comment-deletion marathons.
 
user41796
Yannis periodically goes through delete question marathons.
 
user55340
8:30 PM
Make us mods and you'll have your review queue problem solved... sure, you'll have the problems of people complaining about unilateral decisions by unelected mods... but those are easy to squelch handle.
2
 
My solution: Have Community just close everything in the queue.
 
user55340
And then vote to reopen?
 
No - leave everything closed.
 
user55340
Part of the reason that at P.SE, we're concerned about the SO review queue is that it spills over here. The questions that don't get closed fast enough so people repost them here.
 
Programmers is in SEDE, right?
 
user41796
8:32 PM
@Undo yes
 
There it is.
 
@Undo My solution: Close everything in the queue by automation, migrate everything in it to reopen queue, let the community decide whether stuff is worth reopening, and if they grow a stupid close queue again just start attacking people in the streets, because damnit what the hell? Ok this isn't very helpful is it? That's ok because violence is like chicken, I like chicken, now I need to go write some code..
 
user55340
^^ This is what Haskell does to the brain.
 
Currently priming Charcoal for use on Programmers.
 
user55340
Professors - don't let your students learn FP, or they'll never get in the industry and you'll have to figure out how to make grad students out of them... would you like fries with that?
2
 
user41796
8:36 PM
@Undo we gleefully await. I'm assuming there is a site we can regularly poke to see what questions (or answers) are showing up next as having the worst amount of comments to clear out?
 
user55340
(I wonder if a delete vote heuristic could be tossed in there to find where it would be easier to just have 10k'ers delete the question instead?)
 
user55340
@Maple_Shaft btw, I heard once you get the handle on kids puking and changing diapers, they'll make you a StackOverflow and Politics.SE mod.
 
user41796
@MichaelT That's just plain evil.
 
user41796
And implies that Yannis is unqualified for one of his roles.
 
user55340
@GlenH7 You'd be surprised how much you can vomit after a night of tequila...
 
user41796
8:40 PM
@MichaelT That assumes he cleans up after himself.
 
user55340
(Oh, that nice cold bathroom floor... I am not doing that again. Ever.)
 
user55340
The floor was so nice... you don't fall off it when laying down.
 
user41796
and folk either get that statement or ... they have no idea.
 
user55340
Its something to be experienced... or not. I don't recommend it.
 
@MichaelT It recommends itself, unfortunate though that is.
1
Q: Avoid too complex method - Cyclomatic Complexity

asyncwaitNot sure how to go about this method to reduce Cyclomatic Complexity. Sonar reports 13 whereas 10 is expected. I am sure nothing harm in leaving this method as it is, however, just challenging me how to go about obeying Sonar's rule. Any thoughts would be greatly appreciated. public static long...

ah crap I really wish I had time to sit here writing up a parser combinator to handle that declaratively for him... It wouldn't be hard but it would take more fiddling time than I presently have..
as well as considerably more explanation when he comments on my answer WAT?
 
user41796
8:50 PM
@JimmyHoffa aw, c'mon. What could be more important than imaginary integers? Reals? (pun intended)
 
user55340
I flagged it for possible migration to CR. Its working code, and they could handle it well too.
 
Aug 8 at 18:37, by World Engineer
Holy Flagpocalypse
I'm in! any flagging, any time. :)
 
user41796
@MichaelT I read the question as being more around the concept of "could I actually reduce this" and "if so, why bother?"
 
user55340
@GlenH7 that answer is in the flags again...
 
user41796
@gnat I almost regretted adding your name on the ping as it means MichaelT and I have no chance of catching up to you now.
 
8:54 PM
Easiest OO answer offhand: private static Dictionary<string,Func<string,long>> _mappingStringToParser; I'll leave the rest as an exercise for you (or someone with more spare time right now than I) — Jimmy Hoffa 10 secs ago
 
@GlenH7 I knew you'll be sorry the very moment I saw my name next to word flags
 
user41796
@gnat at least I still retain my standing in the close review queue....
 
user41796
many of which were fed up by you, yes
 
user55340
@GlenH7 I'm 1000 behind you... thats 50 days of reviews if you take a vacation.
 
user41796
@MichaelT You probably closed the gap somewhat this weekend. I had too many other things going on, so I didn't review any this weekend.
 
user55340
8:59 PM
> You could change

else if (sValue.endsWith("H") || sValue.endsWith("h")) {
to

else if (sValue.toUpper().endsWith("H")) {
 
user55340
This is the type of answer he's starting to get... which is a code review.
 
user55340
Though his real question is about the application of the Factory (ug) Pattern.
 
@MichaelT That answer is not befitting formdesigner's rep at all..
@MichaelT NEIN!
 
@MichaelT dude I love that pattern!
so useful! I use them everywhere I want to make an object!
 
user55340
Its the word "pattern" that I'm ug-ing at - not the factory.
 
user41796
9:01 PM
@Ampt so go write up an answer and we'll help get you closer to 3k
 
user55340
It is the right solution there... just I don't like feeding the Pattern People with encouragement.
 
user41796
@MichaelT pattern people are like camels. They can go incredibly long stretches between feedings.
 
user55340
0
Q: Creating classes according to a struct

EmetropI already put this question on stackoverflow forum but nobody has given answer me so I'm trying it here. I get a array via SOAP service, in the array in each value which is a struct is a description of any visual components (size, position, default value etc.) like CheckBox, RadioButton etc. And...

 
user55340
^^ Pattern people.
 
user55340
> And I wonder about how to write a code which will return instances of those any visual components according to the input parameter with usage a design pattern. Which design pattern is the best for this purpose?
 
9:05 PM
@GlenH7 I like Jimmy's suggestion but have never done function pointers in java
 
user41796
@Ampt pretend it's an interview - use whatever curly brace language you like. Pretend it's C#... :-)
 
@GlenH7 What am I, a .net consumerist? I'll use the one true language, Ruby.
Lol jk, I'll do it in python.
 
He's *really* asking for...

public class ParseThen<T>
{
  public Func<string,T> Invoke;

  public ParseThen()
  {
    Invoke = val => throw new Exception("end of the line and no matches made..");
  }

  public ParseThen<T> When(Func<string, bool> predicate, Func<string,T> then)
  {
    return new ParseThen<T>
    {
      Invoke = val =>
      {
        if (predicate(val))
          return then(val);
        else
          return Invoke(val);
      }
    }
  }
}
(or something like that)
(you're a bunch of bastards for baiting me into writing that)
 
user41796
@Ampt - be sure to thank Jimmy when you steal that and post as your answer
 
already have his name in the post mwahahaha
 
user41796
9:07 PM
@JimmyHoffa You know it's all love.
 
user55340
@JimmyHoffa I was thinking the baiting had nothing to do with it...
 
@GlenH7 it's still missing the consumption code which @Ampt couldn't come up with all on his own, if he did he might actually learn a thing or two ;P
 
shhh I'm thinking.
 
user55340
Would love if you could spare sometime on "monadic parsers" and how it can be applied to pretty small function like this one. And, this piece of code is from Java. — asyncwait 1 min ago
 
what is the => operator?
I've never seen that before?
 
user41796
9:10 PM
@Ampt in C# it creates a lambda expression or an anonymous function
 
user55340
And the poster also called out the answer as not that helpful
 
user41796
it's a way of declaring a function in the middle of your code without all of the overhead of a regular function
 
user55340
Not much of a use, sonar still complains. I am kind of trying it for fun, at least allows to learn one or two. Code is moved to staging though. — asyncwait 1 min ago
 
user55340
The Java docs (not javadocs, and no =>)... docs.oracle.com/javase/tutorial/java/javaOO/…
 
Is this honestly the easiest way to accomplish the goal?
couldn't we just use a map of functions?
use the string as the key
 
user55340
9:12 PM
How do you store the functions in Java?
 
function as the value
 
user41796
@Ampt That was Jimmy's initial suggestion with the Dictionary
 
thats the part I'm not sure how to do
@GlenH7 yeah and its easy enough to do in python. Java I'm not so sure
 
user55340
A function in java (old way) needs to be enclosed in a class... or something.
 
user41796
Java should stop being so afraid of pointers
 
9:12 PM
no function pointers in Java?
 
user55340
Not as such.
 
thats gross
 
user55340
It does have Lamdas with java 8 - docs.oracle.com/javase/tutorial/java/javaOO/…
 
user55340
Here's a Java 8 calculator:
 
user55340
public class Calculator {

    interface IntegerMath {
        int operation(int a, int b);
    }

    public int operateBinary(int a, int b, IntegerMath op) {
        return op.operation(a, b);
    }

    public static void main(String... args) {

        Calculator myApp = new Calculator();
        IntegerMath addition = (a, b) -> a + b;
        IntegerMath subtraction = (a, b) -> a - b;
        System.out.println("40 + 2 = " +
            myApp.operateBinary(40, 2, addition));
        System.out.println("20 - 10 = " +
 
user55340
9:14 PM
That '->' is the lambda.
 
doubt he's using java 8 unfortunately
 
user55340
Very doubtful.
 
user41796
when did Java add the ... symbol to indicate multiple parameters?
 
would it be bad form to answer in python? :P
 
user41796
9:15 PM
@Ampt he never tagged the answer with a specific language, so go for it
 
user41796
@MichaelT I should be paying closer attention to the language... Next thing I know they're going to deprecate 1.4.2.....
 
@Ampt You'll quickly realize the map doesn't perfectly give the flexibility to meet his particular predicates. Cheers.
 
user41796
@JimmyHoffa don't discourage him when we're trying to get his rep a little higher
 
yeah the fact that he has to accept all input sucks
 
user55340
It needs two parts - a predicable ordering of conditions, and the transformation. If else if, while ugly does that.
 
user41796
9:17 PM
@Ampt think of the domain of his problem though - he really doesn't. all of his inputs are time based so it's a fixed amount.
 
user41796
Solve the problem he has, not the problem you think he may have.
 
@GlenH7 lambda go home, it's Java
Would love if you could spare sometime on "monadic parsers" and how it can be applied to pretty small function like this one. And, this piece of code is from Java. — asyncwait 10 mins ago
 
user41796
@gnat but he hasn't tagged that in the question itself.
 
user55340
@gnat You can still do lambdas, just not as nice lambdas.
 
user55340
2
Q: Avoid too complex method - Cyclomatic Complexity

asyncwaitNot sure how to go about this method to reduce Cyclomatic Complexity. Sonar reports 13 whereas 10 is expected. I am sure nothing harm in leaving this method as it is, however, just challenging me how to go about obeying Sonar's rule. Any thoughts would be greatly appreciated. public static long...

 
user55340
9:18 PM
I see a java tag there...
 
user55340
(and yes, I know)
 
user41796
@gnat curse you!
 
user41796
It wasn't tagged java originally. Sheesh, talk about an edit that invalidates answers... I would have expected more from someone with such high rep. Poor editing form there...
 
return new ParseWhen<long>()
.When(val => val.EndsWith("ms"), ExtractMillis)
.When(val => val.EndsWith("s"), ExtractSecond)
.When(val => val.EndsWith("h"), ExtractHour)
[...]
.Invoke(sValue);

^-- this is what a fairly simple implementation (not the same as but similar to what I wrote above) would give you in a nice monadic API
 
user55340
The over designed way would be to make a bunch of classes, annotate them with the final character, use reflection to find the annotation, call the class to get the thing.
 
9:20 PM
@MichaelT I eat these for breakfast (AIC) and calling it not as nice is somehow too soft... up to the point that I'd seriously consider keeping that ugly chain of if's instead. Doug Lea style
 
@Ampt try and figure out how to create something that works as my description.
@gnat In C# generics can have constraints, does Java have that? There's a variety, you can put inheritance constraints, or a few like new() means it has a parameterless constructor
 
user55340
The other thing is that its a character (with the exception of 'ms') - a switch on the character, while not reducing the complexity of it much would be nicer IMHO.
 
@gnat Then Java can do be spun to get the API above that I wrote, doesn't even really need higher order functions with a couple simply tweaks and you have a nice fluent API
 
user55340
@asyncwait for what its worth, we're having a discussion of the code in Programmers Chat currently. Might be a better option for some of the nature of the question. — MichaelT 6 secs ago
 
9:24 PM
angelikalanger.com/GenericsFAQ/JavaGenericsFAQ.html Java generics FAQ by Langer is probably best reference for this stuff ever
 
user55340
We've already got the classes -- millis = new ExtractSecond(sValue).invoke();
 
user55340
So an annotation on ExtractSecond of "S" would then allow you to use one block of code to find the annotation and then invoke on that object.
 
user55340
(I'm looking at some code in my IDE that does exactly that...)
 
user55340
    private static Set<Class<?>> pullClasses(Class annotationFilter){
        Set<URL> urls = ClasspathHelper.forPackage("com.something.stuff");

        Reflections reflections = new Reflections(new ConfigurationBuilder()
                .filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix("com.something.stuff")))
                .setUrls(urls)
                .setScanners(new TypeAnnotationsScanner())
        );

        return reflections.getTypesAnnotatedWith(annotationFilter);
    }
 
I believe that chain of ifs indicates design problem, and Sonar caught the smell right. Problem root is likely in ExtractStuff classes
 
9:26 PM
0
A: Avoid too complex method - Cyclomatic Complexity

AmptThanks to @JimmyHoffa for his suggestions! First things first, you should really only accept known prefixes, that is either 'H' or 'h'. If you have to accept both, you should perform some operation to make it consistent to save room in your map. In python you could create a dictionary. EXTRACT...

 
user55340
And then the factory...
 
user55340
public static Generator generate(String key, String arg) throws ReflectiveOperationException{
    Constructor<?> con;
    for(Class<?> clazz : pullClasses(someString)){
        if(key.equals(clazz.getAnnotation(SomeString).value())){
            con = clazz.getDeclaredConstructor(String.class);
            return (Generator)con.invoke(arg);
        }
    }

    return null;
}
 
user55340
Or something like that (I tweaked some of the code that I've go there to not be my work code)
 
and now I go back to actual work haha
 
user55340
This approach does allow for the easy modification of the logic just by adding a new class when needed.
 
user55340
9:34 PM
@GlenH7 FWIW, this is going to be another Croissant question.
 
quite a pity that none of the answers explain what's wrong there. Though recently added code smells even stronger than chain of ifs
All ExtractXXX methods are defined as `static` inner classes. For example, like one below -

private static class ExtractHour {
private String sValue;

public ExtractHour(String sValue) {
this.sValue = sValue;
}

public long invoke() {
long millis;
millis = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 1)) * 60 * 60 * 1000);
return millis;
}
}
 
user55340
As I flagged, I really think that CR is a better place for that question... though now its gotten too many P.SE type answers to be a good migration.
 
@MichaelT agree, CR seems to be more appropriate. Working code is there, practical issue is there too
 
The appended code leads me a little further towards a simpler implementation: Your actual variance is the multiplyer. Create a map of these: Pull the alpha characters from the end of your sValue, use those as your key and then pull all until the alphas from the front for the value which you multiple by the mapped multiplyer. — Jimmy Hoffa 9 secs ago
 
user41796
@MichaelT I would hope not. It's only at 4 answers.
 
9:39 PM
everything he has is Double.Parse()d, all he needs to do is vary what he multiplies the result by.
 
user55340
@GlenH7 Currently. I'd bet it would make it to 8+ without too much trouble in a few hours.
 
@MichaelT what's a regexp to get the alphas at the end and another to get the digits at the front? Double.Parse(frontdigitsRegexp) * map[alphaCharsRegexp]
 
user55340
@JimmyHoffa /(\d+)\s*(\w+)$/
 
user55340
For Java, this would be:
 
@MichaelT Go post the proper java answer to smack @Ampt, or edit his to that so he reps closer to the 3k... in fact we should go edit and improve all of his answers to drag him kicking and screaming to 3k
 
user41796
9:42 PM
@MichaelT The challenge is that side discussions are evolving around each of the answers. So I see the concern. I'm not sure if it will explode or not though. Part of me thinks not.
 
user55340
Pattern foo = Pattern.compile(".*(\\d+)\\s*(\\w+)");
Matcher bar = foo.matches(string);
// bar.group(1) is the digits
// bar.group(2) is the string
 
@JimmyHoffa working on a java verison now
need a line that will strip away all the leading numbers and leave me with the string
 
@Ampt his default else is the if (!map.ContainsKey(bar.group(2)))
 
user55340
@Ampt What in my regex doesn't do what you want?
 
user55340
Got that Matcher slightly off.. thats what I get for writing code in the text box instead of an IDE.
 
user55340
9:50 PM
    Pattern foo = Pattern.compile(".*(\\d+)\\s*(\\w+)");
    Matcher bar = foo.matcher(arg);
    if(bar.matches()) {
        // bar.group(1) is digits
        // bar.group(2) is string
    }
 
that works lol
 
user55340
It may have appeared to work, but that first one was wrong. It would have done bad things and made you look silly.
 
good thing I'm using the second!
 
user55340
foo.match_er_(String arg) is the factory for the Matcher object.
 
wait
 
user55340
9:52 PM
bar.match_es_ is the "test if this regex matches the string".
 
arg should be the thing I want to match right?
 
user55340
Yep.
 
k awesome
 
user55340
Pattern foo = Pattern.compile(".*(\\d+)\\s*(\\w+)");
Matcher bar = foo.matcher("1234 ms");
if(bar.matches()) {
    // bar.group(1) is "1234"
    // bar.group(2) is "ms"
}
 
user55340
There.
 
9:53 PM
1
A: Avoid too complex method - Cyclomatic Complexity

AmptThanks to @JimmyHoffa for his suggestions! Python First things first, you should really only accept known prefixes, that is either 'H' or 'h'. If you have to accept both, you should perform some operation to make it consistent to save room in your map. In python you could create a dictionary. ...

BAM
JAVA
no monads needed
just re-use the same objects
 
user41796
@Ampt +1 for "and the monadic answer is more complicated than it needs to be"
 
Charcoal is primed for Programmers :D
 
user55340
Few tidbits to consider with Patterns, though that would get identified in another sonar rule (I hope). They are thread safe and immutable. Make them final static at the class level.
 
user41796
@Undo How do we use & abuse? And I hope the violin recital was enjoyable enough?
 
@GlenH7 Oh, it was great (the recital)!
 
user55340
9:58 PM
@GlenH7 can you imagine WE's face when he comes in to see some several hundred flags (I've got 80/day I think)...
 
And this is the worst part - I need an email address for everyone that wants in (I don't have a decent signup system).
 
user41796
@MichaelT in a word - gleeful.
 
If you aren't comfortable posting here (I don't blame you), go to www.erwaysoftware.com/<email here>
I'll rip it from the logs.
 
user55340
Since only mods and room owners can see it... and those watching now (who I'm not too concerned with... other than that @Ampt guy)
 
user41796
@Undo oooops, I just created a 404. :-)
 
9:59 PM
Gotit, @MichaelT :D
 
user55340
The joys of editing chat.
 
anyone can see edits @MichaelT
 

« first day (1179 days earlier)      last day (3810 days later) »