Important UML Diagrams Required to Work with Design Patterns

There is a saying that 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. However this note will contain only those class diagram components that are really required for representing your design decisions, design patterns and principles.

UML Diagrams may be classified as static and dynamic. Static diagrams include class diagram, object diagram, use case diagram. Implementation model diagrams, which are a subset of static diagrams include component diagram, deployment diagram, package diagram. Dynamic diagrams include sequence diagram, communication diagram, state diagram and activity diagram. Agile development practice recommends developing models in parallel working on static and dynamic models at the same time.

Knowledge of UML is required for both waterfall and agile approaches. While we do diagrams in a common doc and get approval in waterfall, we may simply draw them in whiteboards in Agile during project discussions. People may even take a picture of it in mobile and send it across or leave the boards with the drawings until the design process is over. Drawing diagrams is the best way to learn a design pattern. To be a good designer, you need to keep drawing as much as possible.

 

Common Class Diagram notations for working with design patterns

Class Diagram

 

Visibility / Access modifiers (public, private, protected and default) are denoted using below symbols

 

Class Diagram Example with attributes, methods, their naming convention etc.

 

Abstract classes are denoted using italic names or specific stereotypes

 

More stereotype examples

 

We can denote Realization (or interface implementation) as:

 

Interfaces have additional notations than using stereotypes

While the first one on left say that CA implements IA or CA provides IA, the second one on right say that CA consumes IA or CA has reference to interface IA.

 

Generalization (or extends) is shown as below.

Association and dependencies can be shown as below.

This say that CB contains a direct reference to CA.

This says that CB contains a dependency to CA and CA may be injected.

 

Multiplicity may be shown as below.

Employee can be part of 1,2 or 3 department.

Note that no array may be shown in bidirectional relationship.

 

Inner classes are shown as below.

 

Procedures for operations can be shown as below.

 

It is a good practice to shown the usage as well. For example, how would you use your design from say a main method.

Special thanks for Sneha for drawing the diagrams for this note.

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)