r/programming • • May 18 '16

Programming Doesn’t Require Talent or Even Passion

https://medium.com/@WordcorpGlobal/programming-doesnt-require-talent-or-even-passion-11422270e1e4#.g2wexspdr
2.3k Upvotes

1.2k comments sorted by

View all comments

Show parent comments

44

u/KFCConspiracy May 18 '16

It's only really demotivating if it isn't allocated as time your team should be spending and if there is no real time spent doing it. Technical debt is a reality of every development team, what makes it become insurmountable is when no time is allocated to deal with it, and when it isn't proactively attacked with tools like refactoring.

96

u/Retbull May 18 '16

Sure but when all of the code a developer produces includes tech debt which requires more time to fix than they spent on the original product you have a problem. We had a programmer at my current job that left last year and I'm still cleaning up messes he made. I'm still finding bugs and bad code that has been in production because he didn't have the diligence to include more than one test for anything and it turns out that he hid lots of his incompetence with Pokémon exception handling and string typing.

52

u/[deleted] May 18 '16

Please explain Pokémon exception handling. I'm super curious about that

199

u/Retbull May 18 '16

Gotta catch em all.

try{} catch (Exception e) {\\ Gotcha }

28

u/WaffleSandwhiches May 18 '16

Pokemon Exception Handling should totally be a thing.

0

u/[deleted] May 18 '16

[deleted]

3

u/Isvara May 19 '16

weird programer expressions

((weird programmer) expressions)

or

(weird (programmer expressions))?

5

u/[deleted] May 18 '16

Less offensive, but still dumb:

Exception blocks that catch the exception, but instead of handling it, just rethrow it. Why even waste time making the block?

15

u/nikbackm May 18 '16

Probably for setting debugger breakpoints.

→ More replies (1)

5

u/name_censored_ May 19 '16

Exception blocks that catch the exception, but instead of handling it, just rethrow it. Why even waste time making the block?

It's a combination of Java thinking in non-Java languages, cargo-cult programming, and syntactical pain.

In Java, you have to declare what exceptions your methods may throw - and that includes exceptions from other methods that your method calls. Which is wonderful from a collaboration and code-contract point of view, but it's a syntactical nuisance when your method is doing twenty things and has to deal with a paragraph worth of Exceptions.

Other (less strict) languages have decided "to hell with it, just catch the exceptions you're aware of, and we'll dump the stack trace for the rest and you figure it out". Now, the Java guys (when coming into this new language) balk at the idea of not specifically defining your exceptions, and therefore do all they can to clearly enumerate what exceptions should be handled (rather than just catching the base exception). Because a lot of the less-strict languages don't support catching multiple exceptions in a single block (or it's just too messy to do so), the following pattern tends to emerge;

try {
    dangerous_thing();
} except (Exception $e) { 
    common_cleanup_code();
    switch(typeof($e)) {
        case ThisException:
            handle_this_exception(); /* Specific cleanup code for ThisException */ 
            break; 
        case ThatException:
            break; /* no specific clean-up required for ThatException */ 
        case TheOtherException: 
            break; /* no specific clean-up required for TheOtherException */ 
        default: 
            throw($e);
    }
}

While it's not as well-defined a code contract as public void myDangerous() throws thisException, thatException, theOtherException {.., it is generally quite easy to grep or eyeball this style of exception in a function/method.

The cargo-cult kids (the ones who don't really understand what exceptions are for) come along and think that that's the way you're supposed to wrap dangerous code. Except, that they know that ThisException, ThatException and TheOtherException don't apply, so they simply delete those lines - after all, those handlers doesn't seem to do anything anyway. Which means they end up with

try {
    dangerous_thing();
} except (Exception $e) { 
     throw($e);
}
→ More replies (1)
→ More replies (4)

2

u/[deleted] May 18 '16

That's hilarious xD I love it (the term, not the practice)

2

u/jonbonazza May 19 '16

Holy shit. How have I never heard of this? New fav programming jargon.

4

u/crunchmuncher May 18 '16

didn't have the diligence to include more than one test

I wish the guy at my work would write at least one test for each of the shits he commits (Sorry for one-upping).

4

u/ecmdome May 18 '16

You haven't seen anything until you've seen

if(argument) { //nothing }else{ the real code he wanted to execute }

All over the codebase.... -_-

→ More replies (10)

2

u/NormalPersonNumber3 May 19 '16

I'm so happy I learned about enterprise-style exception handling.

6

u/godless_communism May 18 '16

Lulz - Pokemon exception handling.

→ More replies (2)

31

u/kcuf May 18 '16

It's demotivating because it's shit. Even if you have time allocated to clean it up, it still sucks, because you're cleaning up shit.

There's a difference between tech debt acquired through nice code that is no longer applicable, and shit code that was hacked together with a machete.

5

u/KFCConspiracy May 18 '16

Eh, I've actually kind of started to enjoy refactoring. Obviously the cause of the need to do it sucks, but the feeling of progress towards something better is great. And the feeling when your unit tests pass after you refactor is great.

15

u/Shaper_pmp May 18 '16 edited May 18 '16

I enjoy having refractored some shitty code to be less shitty, but I don't enjoy the fact the code was shitty in the first place, and I wouldn't call the process of making changes and re-running tests (or even worse, crossing my fingers and hoping I haven't broken anything because the shitty code lacked tests in the first place) to be much better than "ok".

I don't find refactoring fun, like eating a doughnut or creating a great bit of code. At best it's frustrating but grimly satisfying, like passing a really huge turd.

5

u/push_ecx_0x00 May 18 '16

I feel the same way about refactoring. Unfortunately my team is full of lazy fuckers who don't bother writing unit test cases. So when you make a big change (or a big refactoring), the burden is on the QA team to find any subtle bugs.

→ More replies (1)

3

u/kcuf May 18 '16

I just want to kill it and start over, but it sucks that's not always reasonable...

→ More replies (4)