- Write the tests before writing the code.
- Use static analysis tools.
- Practice "good citizenship" by paying attention to how well your objects interact with the outside world. "Never let them exist in an invalid state."
- Avoid indulging in speculative software development. "The goal should be to build the simplest thing we need right now."
- Simplify essential complexity and kill accidental complexity.
- Challenge programming conventions, such as writing long, unreadable test names, and blindly following the JavaBean specification to the detriment of your code.
- Embrace single level of abstraction principle (SLAP). From Kent Beck's book Smalltalk Best Practices and Patterns: every public method should be as short as possible, and should consist of steps, each one of which is a private method. "Don't make abstraction leaps in your code."
- Leverage existing platforms with languages targeted at specific problems and applications.
- Learn every nuance of the languages you're using.
- Change your perspective and consider "antiobjects." An antiobject is a kind of object that appears to do the opposite of what we think it should do. The object metaphor sometimes impedes the solution "by making us try to create objects that are too inspired by the real world."
2008-03-10
10 ways to improve your code
A summary of Neil Ford's Software Development West 2008 "advanced code hygiene" presentation, 10 Ways to Improve Your Code, aimed originally at Java programmers, but with wisdom for coders of many [or any!] stripes. (Ford is a senior application architect and "meme wrangler" at ThoughtWorks, an IT consultant that specializes in development and delivery of software, and that is home to object-oriented development, refactoring and agile authority Martin Fowler.) From Reg Developer:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment