[08/24/2010] Design patterns, part 1.

DESIGN PATTERN IN JAVA – OVERVIEW

The idea: write down and catalog common interactions between objects that programmers have frequently found useful.

23 patterns are divided into 3 types:
Creational patterns: ones that create objects for you, rather than having you instantiate objects directly. This gives your program more flexibility in deciding which objects need to be created for a given case.

Structural patterns help you compose groups of objects into larger structures, such as complex user interfaces or accounting data.

Behavioral patterns help you define the communication between objects in your system and how the flow is controlled in a complex program.

The Learning Process

1. Acceptance.
2. Recognition.
3. Internalization.

Notes on OO Approaches
– The fundamental reason for using varies design patterns is to keep classes separated and prevent them from having to know too much about one another. (encapsulation & inheritance)
– DP suggests that you always Program to an interface and not to an implementation: the top of any class hierarchy with an abstract class, which implements no methods but simply defines the methods that class will support.Then in all of your derived class you have more freedom to implement these methods as most suits your purposes.
Favor object composition over inheritance: object composition or encapsulation of several objects inside another one. Your new object can have the interface that is best for what you want to accomplish without having all the methods of the parent classes.

(from Design Patterns – Java Companion | James W. Cooper)

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