unified modeling language (uml), object-oriented programming concepts & design patterns
TRANSCRIPT
![Page 1: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/1.jpg)
Unified Modeling Language (UML),
Object-Oriented Programming
Concepts &
Design Patterns
M. Isuru Tharanga Chrishantha PereraAssociate Technical Lead at WSO2
Co-organizer of Java Colombo Meetup
![Page 2: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/2.jpg)
2
Agenda
● UML– What is UML?
– Use Case, Activity, Class, Object, Sequence & State Machine Diagrams
– UML Tools
● OOP Concepts & Principles● Software Design Principles● Design Patterns
![Page 3: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/3.jpg)
3
What is UML?
● Unified Modeling Language™ (UML®)– Object Management Group's (OMG) most-used
specification
– Objective is to "provide system architects, software engineers, and software developers with tools for analysis, design, and implementation of software-based systems as well as for modeling business and similar processes"
● UML is a standard modeling language, not a software development process.
![Page 4: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/4.jpg)
4
UML Versions
● Current version is 2.5 (Released in 2015)
● The first versions of UML were created by "Three Amigos" (1990s)– Grady Booch (creator of Booch method)
– Ivar Jacobson (Object-Oriented Software Engineering, OOSE)
– Jim Rumbaugh (Object-Modeling Technique, OMT).
![Page 5: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/5.jpg)
5
UML Diagrams
● Structural Modeling Diagrams– Structure diagrams define the static
architecture of a model.
● Behavioral Modeling Diagrams– Behavior diagrams capture the varieties of
interaction and instantaneous states within a model as it 'executes' over time; tracking how the system will act in a real-world environment, and observing the effects of an operation or event, including its results.
![Page 6: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/6.jpg)
6
Structural Modeling Diagrams
● Package Diagrams● Component Diagrams● Class or Structural Diagrams● Deployment Diagrams● Composite Structure Diagrams● Object Diagrams● Profile Diagrams
![Page 7: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/7.jpg)
7
Behavioral Modeling Diagrams
● Use Case Diagrams● Sequence Diagrams● Activity Diagrams● Timing Diagrams● State Machine Diagrams● Interaction Overview Diagrams● Communication Diagrams
![Page 8: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/8.jpg)
8
UML 2.5 Diagrams
![Page 9: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/9.jpg)
9
Use Case Diagrams
● The use case model captures the requirements of a system.
![Page 10: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/10.jpg)
10
Activity Diagrams
● An activity diagram is used to display the sequence of activities
![Page 11: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/11.jpg)
11
Class Diagrams
● The class diagram shows the building blocks of any object-orientated system.
![Page 12: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/12.jpg)
12
The Entity-Control-Boundary Pattern
● The ECB Pattern is a variation of the Model-View-Controller Pattern.– Entities (model)
● Objects representing system data, often from the domain model.
– Boundaries (view)● Objects that interface with system actors (e.g. a user or external
service). Windows, screens and menus are examples of boundaries that interface with users.
– Controls (controller)● Objects that mediate between boundaries and entities. These
serve as the glue between boundary elements and entity elements, implementing the logic required to manage the various elements and their interactions.
![Page 13: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/13.jpg)
13
ECB Pattern Rules
● Actors can only talk to boundary objects.
● Boundary objects can only talk to controllers and actors.
● Entity objects can only talk to controllers.
● Controllers can talk to boundary objects and entity objects, and to other controllers, but not to actors
![Page 14: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/14.jpg)
14
Object Diagrams
● Object diagrams show how instances of structural elements are related and used at run-time.
![Page 15: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/15.jpg)
15
Sequence Diagrams
● Focuses on the sequence of messages interchanged among lifelines of objects
![Page 16: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/16.jpg)
16
State Machine Diagrams
● Understanding the instant to instant condition, or "run state" of a model when it executes
![Page 17: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/17.jpg)
17
UML Tools
● UMLet– Free UML Tool for Fast UML Diagrams
– http://www.umlet.com/
● Astah Community– Another free tool
– http://astah.net/editions/community
– Samples: http://astah.net/fundamentals
![Page 18: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/18.jpg)
18
OOP Concepts
● Object– An object is a software bundle of related state
and behavior
● Class– A class is a blueprint or prototype from which
objects are created.
● Inheritance– Inheritance provides a powerful and natural
mechanism for organizing and structuring your software.
![Page 19: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/19.jpg)
19
OOP Concepts
● Interface– An interface is a contract between a class and
the outside world
● Package– A package is a namespace for organizing
classes and interfaces in a logical manner.
![Page 20: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/20.jpg)
20
OOP Principles
● Polymorphism– The ability of an object to take on many forms.
– when a parent class reference is used to refer to a child class object
● Inheritance– A class is based on another class.
● Encapsulation– A process of binding or wrapping the data and the codes
that operates on the data into a single entity.
– This keeps the data safe from outside interface and misuse.
![Page 21: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/21.jpg)
21
Software Design Principles
● A set of guidelines that helps us to avoid having a bad design.– The design principles are associated to Robert Martin who
gathered them in "Agile Software Development: Principles, Patterns, and Practices".
● 3 important characteristics of a bad design– Rigidity
● It is hard to change because every change affects too many other parts of the system.
– Fragility● When you make a change, unexpected parts of the system break.
– Immobility● It is hard to reuse in another application because it cannot be
disentangled from the current application.
![Page 22: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/22.jpg)
22
Open Close Principle
● Software entities like classes, modules and functions should be open for extension but closed for modifications.
![Page 23: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/23.jpg)
23
Dependency Inversion Principle
● High-level modules should not depend on low-level modules. Both should depend on abstractions.
● Abstractions should not depend on details. Details should depend on abstractions.
![Page 24: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/24.jpg)
24
Interface Segregation Principle
● Clients should not be forced to depend upon interfaces that they don't use.
![Page 25: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/25.jpg)
25
Single Responsibility Principle
● A class should have only one reason to change.
![Page 26: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/26.jpg)
26
Liskov's Substitution Principle
● Derived types must be completely substitutable for their base types.
● Liskov's Substitution Principle was introduced by Barbara Liskov in a 1987 Conference on Object Oriented Programming Systems Languages and Applications, in Data abstraction and hierarchy
![Page 27: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/27.jpg)
27
Design Patterns
● Creational● Behavioral● Structural
![Page 28: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/28.jpg)
28
Creational Design Patterns
● Singleton– Ensure that only one instance of a class is created
– Provide a global access point to the object.
● Factory– Creates objects without exposing the instantiation logic to the client
– Refers to the newly created object through a common interface
● Factory Method– Defines an interface for creating objects, but let subclasses to
decide which class to instantiate
● Abstract Factory– Offers the interface for creating a family of related objects, without
explicitly specifying their classes.
![Page 29: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/29.jpg)
29
Behavioral Design Patterns
● Command– Encapsulate a request in an object, Allows the parameterization of clients with
different requests and Allows saving the requests in a queue.
● Iterator– Provide a way to access the elements of an aggregate object sequentially without
exposing its underlying representation.
● Observer– Define a one-to-many dependency between objects so that when one object changes
state, all its dependents are notified and updated automatically.
● Strategy– Define a family of algorithms, encapsulate each one, and make them interchangeable.
Strategy lets the algorithm vary independently from clients that use it.
● Template Method– Define the skeleton of an algorithm in an operation, deferring some steps to
subclasses / Template Method lets subclasses redefine certain steps of an algorithm without letting them to change the algorithm's structure.
![Page 30: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/30.jpg)
30
Structural Design Patterns
● Adapter– Convert the interface of a class into another
interface clients expect.
● Decorator– Add additional responsibilities dynamically to
an object.
● Proxy– Provide a “Placeholder” for an object to control
references to it.
![Page 31: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/31.jpg)
31
Recommended Books
● Head First Design Patterns● Design Patterns: Elements of
Reusable Object-Oriented Software by the Gang of Four (GoF)
![Page 32: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/32.jpg)
32
Resources
● UML
– http://www.uml.org/
– http://www.omg.org/spec/UML/Current/
– http://www.sparxsystems.com/resources/uml2_tutorial/index.html
– http://www.uml-diagrams.org
– http://www.agilemodeling.com/essays/umlDiagrams.htm
– http://www.tutorialspoint.com/uml/index.htm
● Java Tutorials
– https://docs.oracle.com/javase/tutorial/index.html
● Object Oriented Design
– http://www.oodesign.com/
● Head First Design Patterns (Sample code available as a zip file)
– http://www.headfirstlabs.com/books/hfdp/
![Page 33: Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns](https://reader031.vdocument.in/reader031/viewer/2022020314/58edb8d61a28ab8c678b4655/html5/thumbnails/33.jpg)
33
Thank you!