Guest lecture at Informatics Institute of Technology (http://www.iit.ac.lk/) on 04th December 2015.
This lecture covered following UML 2.5 Diagrams: Use-Case, Activity, Class, Object, Sequence, State Machine.
I also showed some tools I have used: UMLet and Astah Community. Astah is the main tool I used when I was studying.
Then I focused on OOP Concepts, Software Design Principles and some Design Patterns.
I have included links to all related content in the 32nd slide.
Sending Calendar Invites on SES and Calendarsnack.pdf
Unified Modeling Language (UML), Object-Oriented Programming Concepts & Design Patterns
1. Unified Modeling Language (UML),
Object-Oriented Programming
Concepts &
Design Patterns
M. Isuru Tharanga Chrishantha Perera
Associate Technical Lead at WSO2
Co-organizer of Java Colombo Meetup
2. 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
3. 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.
4. 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).
5. 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.
11. 11
Class Diagrams
● The class diagram shows the building
blocks of any object-orientated
system.
12. 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.
13. 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
14. 14
Object Diagrams
● Object diagrams show how instances
of structural elements are related and
used at run-time.
16. 16
State Machine Diagrams
● Understanding the instant to instant
condition, or "run state" of a model
when it executes
17. 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
18. 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.
19. 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.
20. 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.
21. 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.
22. 22
Open Close Principle
● Software entities like classes,
modules and functions should be open
for extension but closed for
modifications.
23. 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.
26. 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
28. 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.
29. 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.
30. 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.
31. 31
Recommended Books
● Head First Design Patterns
● Design Patterns: Elements of
Reusable Object-Oriented Software by
the Gang of Four (GoF)
32. 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/