- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Admin
True story from a few days ago. Program compiles, test runs and hit a breakpoint. step a couple of lines and the value - from a database - i'm interested in is null. Ok. Check NHProfiler - wierd. It says 74 rows were returned. Check variables above. All are null. WTF! Session is null but it seemingly executed a BeginTransaction() call on the same session with no problem..... several hours and head banged into the wall later I find out that the codecoverage feature and unit test runner dont like eachother. So the code ran. But the debugger did not show the values. Thank you MS. FML.
Admin
If the failure of one sprint backlog item causes the whole sprint to fail, you're not agile. You've just got some weird compressed waterfall method.
That's why you try to follow the 70/30 guideline - the last 30% of the sprint should be items that are okay to ditch if absolutely necessary. Then they just go back to the product backlog for next time.
Admin
The Agile methodology is perfect and cannot fail, you can only fail Agile. The fact that mere humans are incapable of conforming to The Principles is irrelevant.
Admin
It isn't even a joke when it's explained.
Admin
Nobody expects the Spanish ternary operator.
Admin
[quote user="Jazz"][quote user="chubertdev"] Barry, does this make Ruby awesome? It does, Other Barry, it does.[/quote]
http://arstechnica.com/security/2013/01/extremely-crtical-ruby-on-rails-bug-threatens-more-than-200000-sites/
Does this make Ruby crap? Yes, Barry, it does.
Admin
... perhaps to discover that the offending sentence was written by Edward Bulwer. (He didn't change his surname to Bulwer-Lytton until some fourteen years later).
Admin
Admin
[quote user="Gunslinger"][quote user="Jazz"][quote user="chubertdev"] Barry, does this make Ruby awesome? It does, Other Barry, it does.[/quote]
http://arstechnica.com/security/2013/01/extremely-crtical-ruby-on-rails-bug-threatens-more-than-200000-sites/
Does this make Ruby crap? Yes, Barry, it does. [/quote] No, Barry, it doesn't, any more than a bug in Tomcat would make Java crap.
Admin
A thousand times, this. At my job people lose their shit if a story isn't completed by the end of a sprint. The sprint is said to have failed, period.
Admin
I don't know about the others, but in Java you can't hide a function call as an assignment. So, although the getter and setter could be far apart (still in the same class file), any reasonable IDE would have you ctrl-click the method and behold, there's the issue.
Admin
I'm actually just hoping that this whole story took about 5 minutes to debug.
Admin
Yes, a correct program won't die in either way, but a controlled termination sure beats an uncontrolled one. It's definitely the best way to report the error that “the programmer of the calling code is an idiot”…
Admin
OK, I'll share the "Never On Sunday" bug.
C, 1985: The guy's code should beep if something was wrong. He called my beep() function. He was supposed to call beep(VolumeLevelDesired) but instead he just called beep(). So it took the next word on the stack as the volume. The next word on the stack in his function was the day of the week, zero being Sunday. So it beeped, every day, except Sunday.
Admin
A constant "2" with a D decorator to tell the compiler that it's explicitly a decimal value, not whatever the compiler decides to make it based on the value.
Admin
You can change the setting so it will: you just uncheck "step over properties and operators" in the debugger settings.
Admin
Ruby also allows custom setter/getter implementations, yes? And if a custom setter did something weird with the parameter, exactly the same confusion would ensue, yes? And since VB has a shorthand for default setter/getter as well, there is in fact absolutely nothing that Ruby does better here.
Admin
(Defenestration goes beyond mere throwing-out-of-a-window to assassination-by-throwing-out-of-a-window.)
TRWTF here is a language that has spelling competitions. English spelling is based, often, on pronunciations that stopped being current over seven hundred years ago. That's a WTF.
Admin
What you have missed is that C# allows you to do things like this:
I don't know whether you can do this in ruby, but I find it somewhat useful.
Admin
Good for you!
Admin
This.
In prehistoric days you would write
Then in ancient times someone decided that it would be better to write
Today languages have syntactic sugar to allow you to write
Now, I get that the whole point of getters and setters are to allow you to do more than just get and set the value of the member(*), but what I don't get is why jump through all the extra hoops if all the implementation of setBar() does is
(*) Doesn't this violate the rule that a method should do one thing and one thing only anyway?
Aww, feugiat about it...
Admin
Bullshit! death is NOT a requirement of defenstration. Have you even been to any of the conventions?
Admin
An argument that simple public fields are NOT evil. They simply cannot go wrong.
Admin
But fair dues, the word has acquired a secondary meaning of throwing objects (including, in some other cases in Prague, corpses) from windows.
Admin
If not the code has more problems that just the missing function argument: if everything_is_fine beep() else beep() does not make much sense.
Admin
And although I am ready to admit that the first few times I saw one, I was always a bit unsure if "?" really corresponded to "then" and ":" to "else", a company that would set up coding rules like "don't use ternary operators, they are less intuitive to read than if ... else" would lead to a few raised eyebrows by me. Opting for the lowest common qualification level is usually not a good idea in software development.
Admin
Admin
I think it depends a good deal on the language in use as well. Properties really come into their own anytime your have dynamic typing. They give you an opportunity to do some duck-typing; validation. Oddly they are less important in Java, where they are very much a pillar in the code style cannon.
Admin
As Moss would say: amateur hour!
http://www.youtube.com/watch?v=ahKH19iN2SM
Admin
Yes, the Visual Basic code doesn't work as expected because of design flaws in Java. I hate it when that happens.
Admin
Well, in this case, I think the real moral of the story is, "Don't change working code just because you don't like the style. Ugly, working code beats pretty, not-working code."
Admin
Actually, I think that was a very good opening line for a story, quickly and clearly setting the desired mood ... the first time it was used. The problem is that it was so good that six bazillion other writers stole it and beat it to death.
Like that quote "the definition of insanity is doing the same thing and expecting different results". Whoever first said it -- whether it was Einstein or whomever -- was very clever and insightful. But I've heard it quoted so many times now that I just want to scream when I hear it again. Another definition of insanity is using the same quote for the ten thousandth time and expecting people to be just as impressed as they were the first time.
Admin
I get a laugh out of all the people who see the solution to a problem and announce, "Well that's obvious. That's the first thing I would have thought of."
Well, maybe so. And I'm sure that if only you had been alive in 1700 you would have thought of the Three Laws of Motion before Isaac Newton, and if only you'd been around in 1492 you could have told Columbus that he was not in India, and so on. But I'll be much more impressed when you find the solution BEFORE someone else tells you what it is. :-)
Admin
You are missing the point.
A class should not expose any of its variables to other classes except through a function call. Declaring a variable public and letting other classes get and set the variable violates this rule. But creating getter and setter functions that other classes can use to manipulate the variable indirectly, complies with the rule. Thus, problem solved.
Clearly:
is bad because any other class can directly manipulate this value outside of the class's control, by writing "someclass.foobar=7" or whatever.
But
is good because now other classes can only manipulate the value through the getter and setter, for example by writing "someclass.foobar=7".
Clearly, the property implementation eliminates all sorts of potential bugs. For example, with this version, well, umm, it's just better!
Why is it okay for other classes to access a variable through getter and setter functions but not by directly using the variable? Because that's the rule! Why is that a rule? Because somebody wrote it in a book. But why did they write it in a book? Because it's the rule. How stupid are you, anyway? How many times do we have to explain this?
Admin
Admin
The whole premise of properties is flaky. If you want a member variable, then use a member variable. If you want to do more with it, then use a setter method().
Admin
Admin
You're ignoring the hottest property on this site.
Irish setter is a dog.
Irish getter is a girl. I know what I'd give to retrieve that.
Admin
That's not a bus error. A bus error is when you try to use a processor instruction with an unaligned address for your cpu. Dereference of a null pointer results in a seg fault.
Admin
If you can guarantee that you won't want to produce an updated implementation of the class, ever, any time in the future, for example to add validation to the input value or change the internal representation, then go ahead. Otherwise, force everyone who uses your class to recompile at some arbitrary future time.
Admin
Admin
Exactly what I was thinking..
Admin
Whenever I'm near a window of an upper floor in a skyscraper, I prefer to remain fully fenestrated, thankyouverymuch.