Key Principles and Practices of Software Development

01/31/10

Permalink 11:32:45 am, by truewill Email , 677 words, 155 views   English (US)
Categories: Testing, Agile, Quality

Key Principles and Practices of Software Development

With all the discussions of software craftsmanship and SOLID principles lately, I’d like to list the guidelines (not absolute rules!) I find most useful. These are listed in order of importance, highest to lowest.

Key Principles and Practices of Software Development

  1. Never stop learning. Strive for continuous improvement everywhere. Be passionate about your profession.
  2. Source control. Unless you like writing novels in the sand. Check in frequently (but compile and test first). Learn to use branching effectively.
  3. DRY (Don’t Repeat Yourself). Remove duplication every chance you get.
  4. OOP. Encapsulate. Resist the lure of procedural code. Favor composition over inheritance. Also be aware of alternatives, such as functional programming.
  5. TDD (Test-driven development/design). Automated unit testing of classes in isolation is the most useful practice I have learned in the last ten years. Many other practices build on this. Test-first is a major aid to designing usable APIs (you’re eating your own dog food). TDD requires training and practice, but it is a skill worth acquiring.
  6. Refactoring. Keep improving code quality. Requires tests to do properly. Make one small change at a time, then test. Best done with automated tools. Leave the “campground” cleaner than you found it.
  7. Single Responsibility Principle (SRP). “…a class or module should have one, and only one, reason to change.” – Robert C. Martin, Clean Code. If you end up with small, focused methods and classes that are easy to understand, you’re probably doing it right.
  8. Favor simplicity. The goal is not to show how clever you are.
  9. Know your domain. Gather clear, testable requirements before you start coding. Get frequent feedback from customers, domain experts, and other developers. Do not “go dark.”
  10. DI / IoC (Dependency Injection / Inversion of Control). Decouple your classes and make dependencies explicit to support SRP and testability. Interfaces are your friends.
  11. Automate routine tasks. Continuous Integration (CI) is a great example of this. Computers excel at performing repetitive tasks; developers don’t.

Frequent Anti-patterns of Software Development

  1. Technical Debt. You will not clean it up tomorrow. Do it right, now. Your future self will thank you. “You can make very short-term gains (days or weeks) by deliberately sacrificing quality, but the cost – human, business, and technical – is enormous.” – Kent Beck, Extreme Programming Explained
  2. Premature Optimization. Favor maintainable code over fast code. If you must optimize, profile first to find the bottlenecks.
  3. Copy and paste coding. Instead, DRY and refactor to remove duplication.
  4. Deploying code that’s not in source control. If everything you need to build and debug the current production version isn’t checked in, you have a sword hanging over your head.
  5. Not Invented Here. Avoid reinventing wheels. Rolling your own security/encryption code is particularly unwise. Also consider the source; copying and pasting untested code from the Internet carries risks. Finally, insure the solution is a good fit.
  6. Zealotry. Few methodologies work for every team on every project. Consider other viewpoints. Be open to change. Even methodologies evolve.
  7. Large classes and long methods. See Martin Fowler’s book Refactoring.
  8. Singleton Pattern, static classes, and other forms of global data and/or tight coupling.
  9. Not understanding exceptions. Error codes and null return values can lead to unstable code. “A good rule of thumb is that if a method does not do what its name suggests, it should be considered a method-level failure, resulting in an exception.” – Jason Clark, Cwalina & Abrams’ Framework Design Guidelines
  10. Unit tests that are really integration tests. Not that there’s anything wrong with integration tests, but you need to understand the difference.
  11. Excessive comments. If your code expresses intent, comments are often superfluous. And why comment out sections of code that’s under source control? Just delete it!
  12. Using the wrong tool for the job, such as parsing HTML or XML with Regular Expressions. Also, dismissing a tool (such as Regular Expressions) entirely because some developers misuse it.

Remember that the right answer is often “it depends.” Almost everything is a trade-off. Use your own judgment. Think!

Thanks to everyone who reviewed my initial draft, and to Robert ("Uncle Bob") Martin for inspiration.

Comments are welcome.

Comments, Pingbacks:

Comment from: Jesse Gibbs [Visitor] Email · http://www.atlassian.com
Disclaimer: I work for Atlassian, a vendor of software development tools.

Great post. The recommended principles and practices here focus on what can be done either individually or automatically.

Any thoughts on how best to tackle problems that require/benefit from interaction between multiple people? It seems that the "social" element of software development is becoming more and more discussed these days, especially with the emerging popularity of dev tools like Github that have features influenced by 'consumer' social networks.
PermalinkPermalink 02/08/10 @ 20:45
Comment from: truewill [Member] Email · http://www.truewill.net
To Jesse Gibbs:

Thanks!

Actually a friend of mine mentioned that I left out Pair Programming.

Code reviews, project retrospectives, pairing, collective code ownership, daily stand-ups, regular customer interaction, code katas, conferences, user groups, lunch and learn - any and all of these can help with the interactive elements of development. I've seen the benefits of some of these, but have minimal experience with others (such as pairing). I'd like to learn more.

Martin Fowler had a nice post on conversational stories recently: http://martinfowler.com/bliki/ConversationalStories.html
PermalinkPermalink 02/08/10 @ 21:13
Comment from: Ryan [Visitor] Email · http://www.laptopreviewsarchive.com/
I would also add to the list speed. You need to try and get the product out to market as quickly as possible to see if it will generate sales. The quicker you know, the better off you are and the more money you will save.
PermalinkPermalink 02/11/10 @ 16:17

Leave a comment:

Your email address will not be displayed on this site.
Your URL will be displayed.

Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>
(Line breaks become <br />)
(Set cookies for name, email and url)
(Allow users to contact you through a message form (your email will NOT be displayed.))
The name truewill is composed of two other words. What is the SECOND word?

Development Central

Development Central is the blog of Bill Sorensen, a professional software developer. Much of this will relate to C#, .NET, and OOP in general.

Disclaimer
These postings are provided "AS IS" with no warranties and confer no rights.

Search

Categories

Linkblog

b2evolution

contributors

XML Feeds

What is RSS?

Who's Online?

  • Guest Users: 5

powered by b2evolution free blog software