Friday, September 3, 2010

Design priciple from "Better fast lighter java"

Not all requirements can or should be anticipated. Building simple software often means waiting to incorporate future requirements until they're needed. You don't have to completely write off the future, though. By making good decisions, you can make it easy to extend your frameworks in ways you might not have originally intended. You do so by following good design principles:


Expose the right methods, with the right granularity

Methods should be fine-grained and handle a single concept. If your methods bundle up too many concepts, you won't be able to extend the class by overriding the method.


Use Java interfaces

Providing general Java interfaces separates the interface from implementation details. If you see a service or capability that's buried in a class definition, break it out into a separate interface.


Loosen coupling between key concepts

This concept always comes up in good Java programming books for a reason. It works.


Keep designs clear and simple

Code that's hard to read and understand will be hard to extend.


Publish the code under an open source license

An application with source that can be examined and modified is much easier to extend then a closed-source application.


No comments:

Post a Comment