unified modeling language (uml), object-oriented programming concepts & design patterns

Post on 12-Apr-2017

1.556 Views

Category:

Software

3 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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

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

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

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

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.

6

Structural Modeling Diagrams

● Package Diagrams● Component Diagrams● Class or Structural Diagrams● Deployment Diagrams● Composite Structure Diagrams● Object Diagrams● Profile Diagrams

7

Behavioral Modeling Diagrams

● Use Case Diagrams● Sequence Diagrams● Activity Diagrams● Timing Diagrams● State Machine Diagrams● Interaction Overview Diagrams● Communication Diagrams

8

UML 2.5 Diagrams

9

Use Case Diagrams

● The use case model captures the requirements of a system.

10

Activity Diagrams

● An activity diagram is used to display the sequence of activities

11

Class Diagrams

● The class diagram shows the building blocks of any object-orientated system.

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

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

Object Diagrams

● Object diagrams show how instances of structural elements are related and used at run-time.

15

Sequence Diagrams

● Focuses on the sequence of messages interchanged among lifelines of objects

16

State Machine Diagrams

● Understanding the instant to instant condition, or "run state" of a model when it executes

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

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

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

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

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

Open Close Principle

● Software entities like classes, modules and functions should be open for extension but closed for modifications.

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.

24

Interface Segregation Principle

● Clients should not be forced to depend upon interfaces that they don't use.

25

Single Responsibility Principle

● A class should have only one reason to change.

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

27

Design Patterns

● Creational● Behavioral● Structural

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

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

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

Recommended Books

● Head First Design Patterns● Design Patterns: Elements of

Reusable Object-Oriented Software by the Gang of Four (GoF)

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/

33

Thank you!

top related