Coding expert: Assume your code is wrong and improve design

Coding expert: Assume your code is wrong and improve design

on Sep 11, 13 • by Chris Bubinas • with No Comments

Should developers assume there will be mistakes in their code? According to Nathan Marz, a speaker at the NoSQL 2013 conference and developer of the Storm real-time distributed computation system, they should - because adopting this mindset will ultimately help them design better software...

Home » Code Review » Coding expert: Assume your code is wrong and improve design

Should developers assume there will be mistakes in their code? According to Nathan Marz, a speaker at the NoSQL 2013 conference and developer of the Storm real-time distributed computation system, they should – because adopting this mindset will ultimately help them design better software.

“I’d like to start off by making the claim that your code is wrong,” Marz said during a talk at the San Jose, Calif., conference, InfoWorld reported. He later added, “To design better software, you have to consider what are all the possible impacts of your code being wrong.”

By treating code as something that may or may not work, developers are forced to consider which elements of a program might fail as others go out, Marz said, according to InfoWorld. He recommended using more immutable objects – an increasingly viable possibility with the diminishing cost of cloud storage – which help ensure that key data doesn’t get deleted or changed by a rogue function. In general, developers should minimize dependencies in their design.

As developer Yossi Kreinin explained in a post on his blog, programmers should expect that code that isn’t self-contained will get tied to other faulty modules that can introduce errors. While writing code to decrease the dependencies may introduce some superfluous lines, doing so can ultimately lead to a more failsafe design.

“Redundancy is bad, but dependencies can actually paralyze you,” Kreinin wrote. “I say – kill dependencies first.”

Ideally, developers will write code with minimal redundancies, dependencies and errors. While assuming code will contain mistakes forces programmers to think more holistically about their design principles, the best way to make software foolproof is to eliminate both design and code flaws through the use of approaches such as code review. Organizations that prompt programmers to review their peers’ code can better catch errors while enabling collaboration to solve design challenges. In other words, assuming the code is wrong is only the first step – next, developers need to make sure it isn’t.

Software news brought to you by Klocwork Inc., dedicated to helping software developers create better code with every keystroke.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Scroll to top