News for hackers. Stuff that matters.
Re:How to reduce the cognitive load of your code by protonfish on Tuesday March 29, 2016 @10:32AM (#11381704)
In my experience, most bad code is written by dogmatic cargo cult programmers that are more interested in writing code that adheres to their pet development philosophy or framework instead of programming to solve a problem in the simplest way possible.
Re:How to reduce the cognitive load of your code by jernfrost on Tuesday March 29, 2016 @05:06PM (#11384868)
Think we all got different experiences there. My main problems have been with people who insist on just churning out features in the most straightforward way without doing any kind of upfront thinking. You end up with reams of copy past coding, code duplication and so much code that it is very hard to keep track of what is going on.

Like e.g. if you are parsing a file, and it is complicated you can save a lot of time and give a lot more clarity if e.g. you use some form of state machine or look into a little bit of theory of textual transformations and representations.

I mean I have seen people managing a forrest of state variables and who have never heard about regular expressions or any kind of methodology on how to deal with text formats.

You end up with a crap load of messy unmaintainable code.

But of course it is also a problem when people turn every operation into a ceremony involving factories, command objects and any design pattern you can think of. In the Java world that seems like a common problem. I think my own philosophy aligns more with how Go libraries are written. They are pretty simple and straight forward. They use smart approaches were needed but don't insist on adding indirections, encapsulation etc everywhere.

Re:How to reduce the cognitive load of your code by protonfish on Wednesday March 30, 2016 @10:36AM (#11389547)
I am jealous of you. It is fairly straightforward to clean up quickly written, first version code. (In fact, this is probably the best way to develop, if you don't shirk the responsibility to refactor it yourself.) But if you have an over-architected, obfuscated mess, where do you even start? You should appreciate your fellow developers more. Maybe buy them a fruit basket or something?
Re:How to reduce the cognitive load of your code by koder2016 on Tuesday March 29, 2016 @11:15AM (#11382048)
A fashionable framework on your CV will get you an interview, while claiming that the code was simple won't. It's as immoral as objective reality is.
Re:How to reduce the cognitive load of your code by batguano on Tuesday March 29, 2016 @12:30PM (#11382669)
Good point. It's similar to the fallacy of measuring coder productivity by "lines of code written."

Reminds me of the anecdote about Bill Atkinson: His manager required a "productivity" form that asked "how many lines of code did you write this week?" Having just refactored QuickDraw, with vast gains in speed and simplicity, answered "-2000."

http://www.folklore.org/StoryView.py?story=Negative_2000_Lin...

Re:How to reduce the cognitive load of your code by to3m on Tuesday March 29, 2016 @04:01PM (#11384409)
That's quite poetic. But I assume you mean "amoral"?
Re:How to reduce the cognitive load of your code by koder2016 on Wednesday March 30, 2016 @04:08AM (#11387672)
Being a pessimist I consider it immoral.
Re:How to reduce the cognitive load of your code by JoeAltmaier on Tuesday March 29, 2016 @10:40AM (#11381761)
Isn't that just another philosophy? Lets be more charitable. Engineers are given limited time to do any job (time == money). So they do what they can. Mostly on a budget.
Re:How to reduce the cognitive load of your code by protonfish on Tuesday March 29, 2016 @10:51AM (#11381875)
The bad code I see isn't because someone was in a rush - it's because somebody spent a lot of time and effort to make it a mess. I swear 80% of developers don't know the difference between clear, elegant, readable, and modular code and a giant pile of mess. This is why I've stopped encouraging team members to refactor; the end result is most often worse.
Re:How to reduce the cognitive load of your code by st3v3r on Tuesday March 29, 2016 @01:45PM (#11383302)
Part of that is that any 3 developers will have 4 different opinions on what is clear, elegant, and modular, and what is a giant pile of mess.
Re:How to reduce the cognitive load of your code by Fargren on Tuesday March 29, 2016 @12:40PM (#11382742)
Have you tried doing code reviews? If a refactoring sucks you should be able to catch before it goes into master(or however your main branch is called), and educate the programmer. Teaching our coworkers to write better code is part of our jobs.