Design Principles

Here are the Design Principles that resonate with me – (From the Head first Series and other valuable resources)

– Identify the parts of the program that vary from the parts that stay the same. Move everything that varies into its own class.

– Program to an interface, not to an implementation

– Prefer composition over inheritance (I love the Decorator pattern – its a fascinating way to extend functionality at runtime without changing code thats tested. It combines the best of composition and inheritance)

– Classes should be open for extension and closed for modification. [ It sounds obvious, but a majority of designs do not adhere to this principle]

Finally, I have realized – Design is an “art” as much as it is a “computational science”. It seems to come naturally to gifted programmers.

Also, complex designs are not necessarily the best. They end up violating at least one of the above principles.  As Steve McConnel rightly points out, a programmer’s biggest challenge is to manage complexity. Creating an elegant, simple model of a real-world scenario with all their intricate interactions using a set of interfaces and classes is not a walk in the park!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: