Design Modeling

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 22

Design & Modeling

Design Patterns and Architecture


• Design Pattern
• a known arrangement of software components that solves a particular
problem.
• These structures provide both a known terminology and known
implementation such that once the particular problem is identified, the
known structure can be applied.
• First defined Design Patterns: Elements of Reusable Object-Oriented
Software (1994), sometimes referred to as the “Gang of Four” (GoF)
because of the four original authors (Erich Gamma/Richard
Helm/Ralph Johnson/John Vlissides)
Design Patterns
• The GoF Pattern includes 23 patterns in 3 categories
• Creational Pattern
• Different mechanisms to create an object
• Abstract Factory, Builder, Factory Method, Prototype and Singleton
• Structural Pattern
• Class and object composition and relationships between those objects
• Adapter, Bridge, Composite, Decorator, Façade, Flyweight and Proxy
• Behavioral Pattern
• Communication between those object
• Chain of responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer,
State, Strategy, Template method and Visitor
Singleton Pattern
• is used to restrict the number of instances of a class to a single object, so it
is a way to use a single instance of an object in the application.
• In languages such as Java and C#, this is accomplished through a
combination of a private constructor and static Create() or getInstance()
method.
• Rather than create a new instance each time, this method returns a
reference to an existing instance such that all clients share a single instance.
• This would be useful for security gateway applications or classes that are
extremely resource-heavy and would be expensive to continually create
and destroy.
…Singleton Pattern
public class SO {
private static SO instance = new SO();
private SO(){}
public static SO getInstance(){
return instance;
}
public void showMessage(){
System.out.println("Hello World!");
}
}

public class SPDemo {


public static void main(String[] args) {
SO object = SO.getInstance();
object.showMessage();
}
}
Façade Pattern
• is to simplify the external interface to a complex internal system.
• This allows the internal system to be modularized and broken into
independent components with other patterns for performance,
testing, or additional purposes.
• A client of the system, using the façade, has a much simpler interface.
…Façade Pattern
Observer Pattern
• AKA “publish-subscribe,”
• consists of two components. One entity known as the “subject” will
expose an event that other entities, known as “observers,” can
register to listen for and receive notification when the event happens.
• The observers can also unregister when they are no longer interested
in being notified of the event.
• In most implementations, the observer implements an interface that
is defined by the subject.
…Observer Pattern
…Observer Pattern
• Optionally, if the subject is to provide information to the observer(s) it
may also implement an interface so that the observers can use that
interface to communicate with the subject.
• The subject interface typically exposes additional internal information
so that, after a notification, an observer may call back into the subject
for further status.
…Observer Pattern

Application?
…Observer Pattern
• Chat rooms,
• Instant messaging, and
• Live weather updates are all examples of an observer who registers
with a subject to be notified of changes within the subject.
Enterprise Patterns
MVC (Model-View-Controller)
and
Inversion of Control
…Enterprise Patterns (MVC)
• Originally developed in the Smalltalk language, this pattern is
extremely prevalent today, especially with the proliferation of web
and mobile applications.
• Model—represents the data and optionally the business logic of the
system.
• View—accepts inputs to the system and displays results to the client.
This is typically some type of GUI but doesn’t necessarily have to be a
human interface.
• Controller—accepts input from the view and requests data from the
model; determines actions for both the view and model based on
programmed logic.
…Enterprise Patterns (MVC)
…Enterprise Patterns (MVC)

Advantages?
…Enterprise Patterns (Inversion of Control)
• IoC, aka Dependency Injection (DI), is a very important pattern for
systems that have many distributed components and must be tested
separately.
• It extends the concept of “separation of duties”.
• If a class makes use of the services of another class, the consumer of
the service should NOT create instances of the provider of the service.
Rather, the provider should define an abstraction (typically an
interface) and the consumer should use that.
…Enterprise Patterns (Inversion of Control)
Reading Assignment
All Design patterns,
Architecture Pattern: N-Tier
Structural Modeling
• Unlike Behavioral Modeling, Structural modeling never describes the dynamic
behavior of the system.
• It captures the static features of a system and represents the framework for
the system.

• Class Diagram
• Object Diagram
• Component Diagram
• Deployment Diagram
• Package Diagram
• Composite Structure Diagram
Class Diagram Example

You might also like