Introduction to Design Patterns

A pattern is a general reusable solution to a commonly occuring problem. Different types of patterns in software engineering include Architectural Patterns, Design Patterns, Idioms etc. 

Architectural patterns specify the system-wide structural properties of an application, and have an impact on architecture of its subsystems. The Model-View-Controller pattern is one of the best-known examples of an architectural pattern. 

Design patterns are medium-scale patterns that focusses on subsystems or components of the overall software architecture, or the relationships between them. Like architecrual patterns, design patterns are also programming language agnostic. Examples include GoF Patterns, GRASP Patterns etc. 

Idioms are mostly programming language specific patterns. Examples include wait-loop idiom in Java, double loop idiom and holder idiom for implementing singleton pattern in Java etc. 


Benefits of Patterns

  • Consider that someone had a architecture or design problem and found a solution. They document it as a pattern so others can reuse them. Thus patterns help us in solving design problems faster.

  • Patterns also give a shared name for a problem-solution combo. You can use this name in various design discussions to refer to this problem-solution combo. This helps you to maximize tha value of your communication by conveying more relavent information with less words. 


Effectively Using Patterns

Effectively using a design pattern involves understanding its name, type, intent, alternate names, use, examples, structure (through diagrams), participants (and their roles), interactions of participants, consequences (or side effects), implementation details and even it comparisons with any related patterns. 

You should also keep in mind certain consequences of using design patterns:

  • As reusability is often obtained by introducing encapsulation or delegations, the design may affect the performance and may also increase overall complexity

  • There is a tendency to learn few patterns and try to force all design problems or code into those patterns. By forcing a problem or code into a design pattern wrongly may also create further problems.


Object Oriented Design Principles

All design patterns are based on one or more of the Object Oriented Design principles. Having thorough understanding of the design principles will help you understand the design paterns better and faster, and will even help you solve many design scenarios if you can't find a design pattern fitting that scenario. So learn design principles first, followed by patterns, to be a good designer faster.


UML Diagrams

A picture can speak thousand words. UML diagrams are those pictures which can speak all those words about your design.

There are many categories of UML diagrams. Most important ones for your object oriented design are the class diagrams.

References and notes: 


  3. Head First Design Patterns By Eric Freeman, Elisabeth Freeman, Bert Bates, Kathy Sierra

Quick Notes Finder Tags

Activities (1) advanced java (1) agile (3) App Servers (6) archived notes (2) Arrays (1) Best Practices (12) Best Practices (Design) (3) Best Practices (Java) (7) Best Practices (Java EE) (1) BigData (3) Chars & Encodings (6) coding problems (2) Collections (15) contests (3) Core Java (All) (55) course plan (2) Database (12) Design patterns (8) dev tools (3) downloads (2) eclipse (9) Essentials (1) examples (14) Exception (1) Exceptions (4) Exercise (1) exercises (6) Getting Started (18) Groovy (2) hadoop (4) hibernate (77) hibernate interview questions (6) History (1) Hot book (5) http monitoring (2) Inheritance (4) intellij (1) java 8 notes (4) Java 9 (1) Java Concepts (7) Java Core (9) java ee exercises (1) java ee interview questions (2) Java Elements (16) Java Environment (1) Java Features (4) java interview points (4) java interview questions (4) javajee initiatives (1) javajee thoughts (3) Java Performance (6) Java Programmer 1 (11) Java Programmer 2 (7) Javascript Frameworks (1) Java SE Professional (1) JPA 1 - Module (6) JPA 1 - Modules (1) JSP (1) Legacy Java (1) linked list (3) maven (1) Multithreading (16) NFR (1) No SQL (1) Object Oriented (9) OCPJP (4) OCPWCD (1) OOAD (3) Operators (4) Overloading (2) Overriding (2) Overviews (1) policies (1) programming (1) Quartz Scheduler (1) Quizzes (17) RabbitMQ (1) references (2) restful web service (3) Searching (1) security (10) Servlets (8) Servlets and JSP (31) Site Usage Guidelines (1) Sorting (1) source code management (1) spring (4) spring boot (3) Spring Examples (1) Spring Features (1) spring jpa (1) Stack (1) Streams & IO (3) Strings (11) SW Developer Tools (2) testing (1) troubleshooting (1) user interface (1) vxml (8) web services (1) Web Technologies (1) Web Technology Books (1) youtube (1)