Skip to main content

Posts

Showing posts with the label humor

How (Not) to Handle Different Exceptions

Came across this sample from a certain multi-billion-dollar company, purporting to show how to implement exception handling. I slightly changed a few cosmetic details to make it anonymous. try { // ... } catch (GeneralException e) { if (e instanceof SpecificExceptionA){ // ... } else if (e instanceof SpecificExceptionB){ // ... } } This is a true actual story--you can't make this stuff up. Yeah, I thought it was pretty hilarious; so I felt like I had to share it.

7 Things Development Managers Know in 2017

Here is a list of 7 things you need to know, in order to be a manager of software developers, within any significant modern company. See how many you already know. Beauty = Value Functionality = Quality Quantity = Usefulness Physical Labor = Knowledge Genetic Makeup = Technical Literacy Hype = Skill Results = Magic Details: Beauty = Value Technical competence is not necessary to judge software quality Always attribute inherent value to software with a cosmetically appealing presentation Applying hype makes software more valuable If hype is present, so is the associated value Functionality = Quality If it seems to work how it should, then it really does People who have been doing it longer must be better at it Quantity = Usefulness Usefulness can be measured by quantity of output The more people working on software development, the faster it will get done Physical Labor = Knowledge Expect workers to create a comprehensive, accurate, detailed plan befor...

true, false... or *other*?

This was taken from real code :D The identifiers have been changed. if (isCertainCondition()) { // Fine so far... } else if (!isCertainCondition()) { // Are you kidding me?? // ... // Now for the clincher... } else { // ... }

if not a and not b or not b and not a...

I just found this code that I thought was humorous (identifiers changed to protect intellectual property): private boolean allFoosAreBarsOrBazs() { for (Foo foo: foos) { if (!(foo instanceof Bar)) { if (!(foo instanceof Baz)) { return false; } } if (!(foo instanceof Baz)) { if (!(foo instanceof Bar)) { return false; } } } return true; }

if x, foreach x

Here's another winner I found in actual (PHP) code that I was working on: if ($groups) { foreach($groups as $group) { /* ... */ } } Good thing they wrapped that foreach loop in that if , eh? We wouldn't have wanted to waste time looping through the whole ( empty ) array, if the array were empty in the first place, now would we?? :-D

Funny Programming Mistake

I thought you might find this programming mistake I made to be somewhat humorous. public MyJSplitPane getMyJSplitPane() { MyListener myListener; MyArray[] myArray; myArray = source1.getMyArray(); if (myJSplitPane == null) { myListener = getMyListener(); myJSplitPane = new MyJSplitPane(myArray, myListener); } return myJSplitPane; } /** * @return Returns the myListener. */ private MyListener getMyListener() { MyJSplitPane myJSplitPane; if (myListener == null) { myJSplitPane = getMyJSplitPane(); myListener = new MyListener(source2, myJSplitPane, this); } return myListener; }

3 digit for loop

Would you believe that this is almost exactly the same as some JavaScript code that I found, that somebody actually wrote? Tell me, what's wrong with this code? Could you think of any more concise way to write it? All we need is the highest version number we can use to create the activex object without throwing an exception. var curr = -1; for (var n1 = 1; n1 >= 1 && curr == -1; --n1) { for (var n2 = 9; n2 >= 0 && curr == -1; --n2) { for (var n3 = 9; n3 >= 0 && curr == -1; --n3) { for (var n4 = 9; n4 >= 0 && curr == -1; --n4) { for (var n5 = 9; n5 >= 0 && curr == -1; --n5) { var version = "" + n1 + n2 + n3 + "_" + n4 + n5; try { var versioned = new ActiveXObject( "JavaPlugin." + version); curr = new Number( "" + n1 + n2 + n3); ...

Extreme Driving (XD)

If you've never heard of Extreme Programming (XP) , you probably just won't get it. As a matter of fact, you might not get it anyway, but that's ok. XD is a deliberate and disciplined approach to driving motor vehicles. If everybody just tries to drive whatever way, it will take longer to get anywhere, and there's more of a danger of a crash. That's why you must have and follow a driving methodology . First of all, it's absolutely essential to have lots of "Call Up Meetings," which involve everybody calling and talk to each other on cellphones while driving. Never drive without them. "Collective Mechanical Ownership" is another critically important concept of XD. It means that any driver must have access to change the mechanics in the vehicle at any time. So if one person wants to get in and rewire the starter, or another person decides to change the spark plugs, there doesn't have to be centralized oversight of all that. And don't...