The difficult definition of professional software development

Here are some of the contradictory phrases (and a few paraphrases) I’ve overheard used to define what is “good” and “bad” code.

  • Code should always be well commented
  • Maintainable code has unit tests and well named methods therefore needs little if any comments
  • Class explosion is to be avoided at all costs
  • Many small simple well named classes are the key to well organized code
  • Unit tests really don’t test anything useful
  • Dependency injection leads to an unusable mess
  • Dependency Injection is a very useful tool for making your code extensible and easily reused”
  • Inheritance leads to solid code reuse
  • Inheritance is the strongest coupling of your code you can have
  • Functional programming simplifies and minimizes the complexity of your code
  • Functional programing just makes my eyes bleed!
  • Static global references are ‘just programming’ and something you have to learn how to manage to make simple easy to understand code
  • Static global spiderwebs are crippling to maintenance and program lifetime

 

The part that is most difficult about that list for me is while I agree with half of it strongly and respect the people who said those things, the other half that list I do not agree with, has all come from people I respect and who overall do some pretty impressive things. They’ve certainly created things by all measures more impressive than anything I’ve ever produced

This leads me to question how much do software principles matter when taking them out of the context of yourself but viewing it in a bigger picture. Thinking about it, 95% of the software that I actually like probably wasn’t using any TDD at any point in time and certainly violates a number of things that I would consider required for “professional software”. I keep reinforcing this fact every time I checkout the source of a major software project I’ve used for years and gasp in horror at the spaghetti code I find.

Worse still the different schools of thought are not compatible in the slightest, and one side views the other side as wholly unprofessional (granted for different reasons) to the point that I’ve realized I myself was perceived as the one being “amateur” by those with a different definition of what makes good and bad software. I of course unfortunately often thought the same of them, regardless of how I felt about them personally.

Anyway, this is all food for thought and I have not yet come to any conclusion what it all means. It’s just easily the most frustrating thing about our profession and has on more than a few occasions had me long to return to being a sysadmin (too bad I really love making things). I know I’ve tried coding under other schools of thought and while through practice I was able to deliver well enough, I’m far slower and more error prone with no TDD, big mega classes, and avoiding dependency injection

Related Articles:

    Post Footer automatically generated by Add Post Footer Plugin for wordpress.

    About Ryan Svihla

    I consider myself a full stack polyglot, and I have been writing a lot of JS and Ruby as of late. Currently, I'm a solutions architect at DataStax
    This entry was posted in Craftsmanship. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
    • http://scottdepouw.com Scott DePouw

      I think that phrases like this cannot be applied to every situation. Indeed, I tend to think that some of those phrases do not lead to quality code most of the time, but I do respect that they can apply some of the time. I find it difficult to take any of these statements at face value 100% of the time. Sometimes some of the phrases apply; other times the opposite ones do; and all the time it’s a varied mix of the phrases that apply to the given situation at hand.

      Taken out of context, these phrases don’t make any sense when they’re all put together like this, since half of them contradict the other half. However, I believe that it takes a good software craftsman to be able to decide which idioms to follow for the project at hand. If someone were to strike up a conversation with one of the above phrases, I would want some good follow-up on why one would say something like that, not simply take it to mean that one would think that it’s the end-all be-all mantra to go by.

      At the end of the day, what matters is the software produced. Consumers are not going to care how elegantly code was written, if it’s under test, etc. They just want they paid for. That’s not saying that some of the phrases used above aren’t a means to that end. It’s simply the fact that the only people that will see the code (barring open source projects, naturally) are the developers. Beyond that, the world merely witnesses the product. Is a piece of code considered high quality because it’s elegant, follows best practices, and so on? Or is it high quality because it does what it was written to do and does not have to be altered in the future?

    • http://www.lostechies.com/members/chadmyers/default.aspx chadmyers
    • http://www.lostechies.com/members/rssvihla/default.aspx Ryan Svihla

      @Scott
      re: Is a piece of code considered high quality because it’s elegant, follows best practices, and so on? Or is it high quality because it does what it was written to do and does not have to be altered in the future

      good questions for thought and I do not have an immediate answer. I’ve tended to view high quality software as something that behaves as expected. But obviously more often that not software ages out of use. the problem it was solving was no longer as important, or the technology it was written in was “deprecated” so how much engineering is needed is contextual and not really known at the time.

      I respect how you’re viewing that particular list as a toolkit for a particular project. In reality though most of us get very dogmatic about a particular style we’ve stumbled onto and hold it for dear life. This makes teamwork and craftsmanship difficult, and occasionally impossible. Now I agree it shouldn’t be that way and people should be willing to adapt and adjust, but it’s not always the case.

      There is just so much more potential for conflict among those that are otherwise capable in their own right than I’m entirely happy about.

    • http://www.lostechies.com/members/gregorylong/default.aspx gregorylong

      @Ryan
      re: In reality though most of us get very dogmatic about a particular style we’ve stumbled onto and hold it for dear life.

      I won’t even touch the definition of professional software development, but this statement hits what I think may be one of the biggest enemies to improvement in our profession. People have too many beliefs in our business. Beliefs are a crutch, a way to halt our learning process, declare we have found The Truth, and hide our heads in the sand.
      It would be better to realize we all just have ideas. Those ideas only have merit if they help us solve the problem at hand. If two different ideas result in two equally acceptable solutions – what’s the fuss?

    • http://www.lostechies.com/members/rssvihla/default.aspx Ryan Svihla

      @Chad I remember those posts well and if you look back far enough I even commented on one of those posts (pre los techies). This is definitely an area we are in perfect agreement, and truthfully you’ve helped shape those ideas.

      @Gregory Agree about beliefs, people (myself included) carry it too far. However, I still struggle with what you say about “equally acceptable solutions”, Who is it acceptable too? From my perspective I’m struggling to understand where the line is to be drawn from “you’re going to reap terrible results from this in the future” to “this is acceptable for the way the organization works”. There are cases where both are true, does that make it an acceptable way to approach things? Especially when what someone else would call “terrible results” to someone else is “just the way software development works”

    • http://simpleprogrammer.com John Sonmez

      Perhaps combining most of these statements together creates the clearer picture… Here is my crack at it, I think I have filled in the missing pieces..

      Code should always be well commented… one way to do this is to instead have unit tests and well named methods .
      Seemingly random class explosion is to be avoided at all costs, but many small simple well named classes are the key to well organized code.
      Unit tests really don’t test anything useful unless they have a clear purpose are easily understandable and are written in a way to not be brittle.
      Using dependency injection everywhere leads to an unusable mess, but Dependency Injection is a very useful tool for making your code extensible and easily reused.
      Inheritance leads to solid code reuse, but inheritance is also the strongest coupling of your code you can have, so only use it when composition doesn’t make sense.
      Functional programming simplifies and minimizes the complexity of your code, but Functional programing can make your eyes bleed, so try to use good naming and simple constructs over doing things “clever”.
      Static global references are ‘just programming’ and something you have to learn how to manage to make simple easy to understand code, but Static global spiderwebs are crippling to maintenance and program lifetime so only use them where they make the code much simpler.

    • http://www.lostechies.com/members/gregorylong/default.aspx gregorylong

      @Rayn
      Re:I still struggle with what you say about “equally acceptable solutions”
      So, as long as we’re being very general – e.g. the broadest possible context or no context – then I’m comfortable with this statement. I’m not smart enough to possibly process every realistically plausible context and prove one approach would definitively be better than another.
      If we get more specific, put it into an actual context, I’m more inclined to believe the only way two solutions would be equally acceptable would be that they were only slightly different. If I could play back a conversation from work last week I could demonstrate this idea. A co-worker didn’t particularly like a solution to a problem and we discussed alternatives. The code in question will be part of an enterprise solution and must be highly flexible. His initial suggestion would require us to a)re-write a portion of a method if our rules for processing changed or b)create a new object for each set of rules. The second choice wasn’t too bad except that the application of the rules were only one of the roles of that object.
      In the end we arrived with “two equally acceptable solutions”:
      1)A solution I favored – an abstraction for the role of evaluating and applying rules that depended on an injected collection of rules objects. Rules would be changed by changing the injected collection via our IoC.
      2)His favored approach – an abstraction for the role of evaluating and applying rules that explicitly called a known set of rules objects in a know sequence (e.g. hard-coded). Rules would be changed by creating new processing classes that possessed a new sequence.
      I liked mine better because we’ll have – in my opinion – less code to write when the rules change. But both support the end goal. Mine would fit more closely into the composition, non-functional side of your list but that’s where most of my favorite ideas live so . . . meh. I respect my co-worker a great deal and so I’m willing to use his approach if it matters more to him. If we find his solution to be an issue later, it could be rapidly re-factored into mine so . . . why get too wound up about it?

    • Jim Cooper

      @Scott

      These are worrying questions of yours:

      “Is a piece of code considered high quality because it’s elegant, follows best practices, and so on? Or is it high quality because it does what it was written to do and does not have to be altered in the future?”

      This seems to be an expression of a common meme:

      “Just make the code work as soon as you can. It doesn’t matter if it’s rubbish code because the customer doesn’t care about code”

      That POV is wrong. The quickest way to get anything beyond the most trivial software in the hands of customers is to write the code well. Crufty code slows you down, sometimes within hours. Write crappy code and that release date will slip. The customer tends to care about that.

      Most code also has a long life. You pay dearly when you need to change poor, “quick” code. The customer cares that you can’t make changes in a timely fashion and that the software keeps breaking when you try.

      Also, I’d like to see how you guarantee code will “not have to be altered in the future”. That sort of predictive power would be better used to pick lottery numbers, surely! :-)

      By definition, best practices are not things that slow down delivery. If they do, they clearly aren’t best practices! (At least not the way they’re being done.)

      For example. how do you tell your code “does what it was written to do”? Maybe unit testing would help? Or do you think that that is going to slow you down? (If it does, you aren’t doing it right.)

      All my 20+ years of professional experience in this business tell me that the way to write code the fastest, is to write good quality code.

      Customers may not care what the code looks like, but they certainly care about the effects bad code has on them.

    • http://agileotter.blogspot.com/ Tim Ottinger

      Of course there are contradictory rules. People come at things from different angles. Comments and clean code are both shooting at “readable” in different ways. Inheritance used well will improve extensibility, but used poorly will make the system a mess because it is the strongest dependency. Functional programming is both cryptic and structurally simple (simple and clear are not the some concept).

      My take was to try to reach past the practices and approaches and pick out the virtues they’re reaching for. It helps me understand different approaches better. http://agileinaflash.blogspot.com/2010/02/seven-code-virtues.html

      I’m not the first to do that, and I may not have done it best, but knowing why people make these statements always helps me to make decisions. I think we all want good product, delivered on a timely basis, and which does not create problems in the future but options instead.

      I hope this helps.

    • http://agileotter.blogspot.com/ Tim Ottinger

      @ryan:

      You say “re: Is a piece of code considered high quality because it’s elegant, follows best practices, and so on? Or is it high quality because it does what it was written to do and does not have to be altered in the future.”

      I agree with two caveats:

      I don’t believe in “once and for all” for any project people are going to use and maintain going forward. “Easy to understand and change” trumps any “once and for all” in my opinion.

      “Does what it is written to do” is a platitude, really. All code operates as it was written. ;-) If the code does something really useful (value to end user) it can be elegant, but of course 60% of all features are never used, so code could be internally elegant and not particularly useful.

      So “it does something people need it to do”, “does a good job” (performant, etc), and “is easy to change without breaking anything” would be pretty high on my list of qualities for elegant code.