Architecture and design patterns Jonathan Einav. Lecture Objectives Open a window to the architecture and design patterns world, explain why are they.

Slides:



Advertisements
Similar presentations
Spring, Hibernate and Web Services 13 th September 2014.
Advertisements

Computer Monitoring System for EE Faculty By Yaroslav Ross And Denis Zakrevsky Supervisor: Viktor Kulikov.
2 Object-Oriented Analysis and Design with the Unified Process Objectives  Explain how statecharts can be used to describe system behaviors  Use statecharts.
IEG3080 Tutorial 7 Prepared by Ryan.
Advanced Object-Oriented Programming Features
System Architecture Lecture 3 CSE 111 Spring /22/20151Copyright William E. Howden.
Satzinger, Jackson, and Burd Object-Orieneted Analysis & Design
Application Architectures Vijayan Sugumaran Department of DIS Oakland University.
ECE 355 Design Patterns Tutorial Part 2 (based on slides by Ali Razavi) Presented by Igor Ivković
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
Design Patterns academy.zariba.com 1. Lecture Content 1.What are Design Patterns? 2.Creational 3.Structural 4.Behavioral 5.Architectural 6.Design Patterns.
Chapter 26 Applying Gang of Four Design Patterns 1CS6359 Fall 2012 John Cole.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Systems Analysis and Design in a Changing World, Fifth Edition
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Singleton Christopher Chiaverini Software Design & Documentation September 18, 2003.
Systems Analysis and Design in a Changing World, Fifth Edition
Design Patterns.
An Introduction to Software Architecture
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 07. Review Architectural Representation – Using UML – Using ADL.
ECE 452 / CS 446 / SE464 Design Patterns: Part 2 - Answers A Tutorial By Peter Kim Partially based on the tutorial by Michał Antkiewicz.
12 Systems Analysis and Design in a Changing World, Fifth Edition.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 09. Review Introduction to architectural styles Distributed architectures – Client Server Architecture – Multi-tier.
Design Patterns Part two. Structural Patterns Concerned with how classes and objects are composed to form larger structures Concerned with how classes.
ISP666 MVC & Design Patterns. Outline Review Event Programming Model Model-View-Controller Revisit Simple Calculator Break Design Patterns Exercise.
Chapter 26 GoF Design Patterns. The Adapter Design Pattern.
Patterns in programming 1. What are patterns? “A design pattern is a general, reusable solution to a commonly occurring problem in software. A design.
GoF Design Patterns (Ch. 26). GoF Design Patterns Adapter Factory Singleton Strategy Composite Façade Observer (Publish-Subscribe)
95-843: Service Oriented Architecture 1 Master of Information System Management Service Oriented Architecture Lecture 3: SOA Reference Model OASIS 2006.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 05. Review Software design methods Design Paradigms Typical Design Trade-offs.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
CS 210 Adapter Pattern October 19 th, Adapters in real life Page 236 – Head First Design Patterns.
Unit 4 Object-Oriented Design Patterns NameStudent Number CAI XIANGHT082182A KYAW THU LINHT082238Y LI PENGFEIHT082220L NAUNG NAUNG LATTHT082195L PLATHOTTAM.
.  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.
Patterns in programming1. 2 What are patterns? Answers to common design problems. A language used by developers –To discuss answers to design problems.
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
Title Carolina First Steering Committee October 9, 2010 Online Voting System Design Yinpeng Li and Tian Cao May 3, 2011.
Design Patterns Yonglei Tao. Design Patterns  A design pattern describes a recurring design problem, a solution, and the context in which that solution.
Review Class Inheritance, Abstract, Interfaces, Polymorphism, GUI (MVC)
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Design Pattern. Definition: A design pattern is a general reusable solution to a commonly occurring problem within a given context in software design.
Gang of Four Patterns 23 total 15 useful How are they different from GRASP Patterns?
Design Patterns Introduction
Design Patterns SE464 Derek Rayside images from NetObjectives.com & Wikipedia.
Java Design Patterns Java Design Patterns. What are design patterns? the best solution for a recurring problem a technique for making code more flexible.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31. Review Creational Design Patterns – Singleton Pattern – Builder Pattern.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
University of Southern California Center for Systems and Software Engineering Architecture and Design Patterns CSCI577A Fall2015 Kan Qi, Bo Wang.
© Drexel University Software Engineering Research Group (SERG) 1 The OASIS SOA Reference Model Brian Mitchell.
CS 325: Software Engineering March 19, 2015 Applying Patterns (Part B) Code Smells The Decorator Pattern The Observer Pattern The Template Method Pattern.
Proxy Pattern defined The Proxy Pattern provides a surrogate or placeholder for another object to control access to it by creating a representative object.
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
Watching the movie the hard way…. Page 256 – Head First Design Patterns.
Architecture, Design Patterns and Faithful Implementation David Woollard University of Southern California Software Architecture Group NASA Jet Propulsion.
1 SOA Seminar Seminar on Service Oriented Architecture SOA Reference Model OASIS 2006.
11 Systems Analysis and Design in a Changing World, Fifth Edition.
J2EE Platform Overview (Application Architecture)
Patterns in programming
MPCS – Advanced java Programming
OO Methodology OO Architecture.
Part 3 Design What does design mean in different fields?
Presented by Igor Ivković
GoF Design Patterns (Ch. 26). GoF Design Patterns Adapter Factory Singleton Strategy Composite Façade Observer (Publish-Subscribe)
Design and Maintenance of Web Applications in J2EE
Lecture 1: Multi-tier Architecture Overview
An Introduction to Software Architecture
GoF Design Patterns (Ch. 26)
Model, View, Controller design pattern
Presented by Igor Ivković
GoF Patterns Ch. 26.
Presentation transcript:

Architecture and design patterns Jonathan Einav

Lecture Objectives Open a window to the architecture and design patterns world, explain why are they needed and where did they came from, and give some examples and real world tastes of chosen DP and architectures not a programming language oriented lecture, we will mainly discuss the paradigms and uses with examples in various programming languages.

Programming paradigms Evolution Block Programming Procedural programming Object Oriented Component Oriented SOA (?)

What are design patterns? The Beginning - “Gang of four” (Gama et al 1995) What's the difference between an architecture and a Design patterns? Patterns sub types: Creational Creational Structural Structural Behavioral Behavioral

Observer design patterns Behavioral Pattern one-to-many dependency model, so that when one object changes state, all its dependents are notified and updated automatically without coupling the notifying object to the objects that are notified. Example: Button expose a clicked event that encapsulate click state, thus publish himself as an observable. Clients that are interested in this event register to it, thus becomes observers. Observer and observable are bonded in a contract and can be completely loosely coupled from one another.

Singleton design pattern Creational pattern ensure that a class has only one instance, and to provide a global point of access to it Example: Class SomeClass { static SomeClass singleTonInstance = null; static SomeClass GetInstance() { if(singleTonInstance == null) singleTonInstance = new SomeClass() singleTonInstance = new SomeClass() return singleTonInstance; }}

Factory design patterns (abstract\method\Lightweight) Creational pattern Can be given to client (abstract), pass construction parameters or read creation types from configuration or system environment Can use object pool (Lightweight)

Factory design pattern - example abstract class GUIFactory { public static GUIFactory getFactory() { int sys = readFromConfigFile("OS_TYPE"); return sys == 0 ? new WinFactory() : new OSXFactory(); } public abstract Button createButton(); public abstract Button createButton();} class WinFactory:GUIFactory { public override Button createButton() { return new WinButton(); }} class MacFactory:GUIFactory { public override Button createButton(){ return new MacButton(); }} abstract class Button { public string caption; public abstract void paint(); }

class WinButton:Button { public override void paint() { // paint a button with Win API…} } class MacButton:Button { public override void paint() { // paint a button Mac style… } } class Application { static void Main(string[] args) { GUIFactory aFactory = GUIFactory.getFactory(); Button aButton = aFactory.createButton(); aButton.caption = "Play"; aButton.paint(); }} Factory design pattern - example

Façade design pattern Structural Pattern Provide a unified interface to a set of interfaces in a subsystem without damaging the genric form of the sub system.

Decorator design pattern Structural Pattern Avoid excessive sub-classing and gain run time flexibility Example: Java.IO package BufferedReader br = new BufferedReader( new InputStreamReader( new FileInputStream(inFile))); All derives from abstract io.Reader

Strategy design pattern Behavioral Pattern defines a family of interchangeable encapsulated algorithms that receives the same input type and provides the same output type in different manners that can be determined in run-time. static void Main( { SortedList studentRecords = new SortedList(); studentRecords.Add("Samual"); studentRecords.Add("Jimmy"); studentRecords.Add("Sandra"); studentRecords.SetSortStrategy(new QuickSort()); studentRecords.Sort(); studentRecords.SetSortStrategy(new ShellSort()); studentRecords.Sort(); SortedList studentRecords = new SortedList(); studentRecords.Add("Samual"); studentRecords.Add("Jimmy"); studentRecords.Add("Sandra"); studentRecords.SetSortStrategy(new QuickSort()); studentRecords.Sort(); studentRecords.SetSortStrategy(new ShellSort()); studentRecords.Sort(); }

Strategy design pattern - example abstract class SortStrategy { public abstract void Sort(ArrayList list) } class QuickSort : SortStrategy { public override void Sort(ArrayList list) { list.Sort(); // Default is Quicksort public override void Sort(ArrayList list) { list.Sort(); // Default is Quicksort }} class ShellSort : SortStrategy { public override void Sort(ArrayList list) { //list.ShellSort(); not-implemented public override void Sort(ArrayList list) { //list.ShellSort(); not-implemented } }

class SortedList { private ArrayList list = new ArrayList(); private SortStrategy sortstrategy; public void SetSortStrategy(SortStrategy sortstrategy) { this.sortstrategy = sortstrategy; } public void Add(string name) { private ArrayList list = new ArrayList(); private SortStrategy sortstrategy; public void SetSortStrategy(SortStrategy sortstrategy) { this.sortstrategy = sortstrategy; } public void Add(string name) { list.Add(name); } public void Sort() { public void Sort() { sortstrategy.Sort(list); sortstrategy.Sort(list); }} Strategy design pattern - example

Consumer/Producer Concurrency Pattern This design pattern coordinates the concurrent production and consumption of information among producer and consumer objects that are working on different threads. This pattern is used with some type of semaphore

Consumer/Producer - example static AutoResetEvent eventProducerDone = new AutoResetEvent(false); static AutoResetEvent eventConsumerDone = new AutoResetEvent(false); static int currentNum = 0; static void produce(object stateInfo) { eventProducerDone.Set(); eventProducerDone.Set(); while (true) while (true) { //wait for the consumer //wait for the consumer eventConsumerDone.WaitOne(); eventConsumerDone.WaitOne(); currentNum++; currentNum++; eventProducerDone.Set(); eventProducerDone.Set(); }}

static void Main(string[] args) { ThreadPool.QueueUserWorkItem(new ThreadPool.QueueUserWorkItem(newWaitCallback(produce)); for (int i = 0; i < 20; i++) for (int i = 0; i < 20; i++) { eventProducerDone.WaitOne(); eventProducerDone.WaitOne(); System.Diagnostics.Debug.WriteLine(currentNum); System.Diagnostics.Debug.WriteLine(currentNum); eventConsumerDone.Set(); eventConsumerDone.Set(); }} Consumer/Producer - example

Model View Controller The Model-View-Controller (MVC) pattern separates the modeling of the domain, the presentation, and the actions based on user input into three separate classes The controller changes the model The View Listens to Model Changed events and update itself Recursive MVC

N tier Architecture The n tier architecture is based on the concept of separating a system to different layers (usually 3) Each layer interacts with only the layer directly below, and has specific function that it is responsible for. Classic for IT systems

N tier Architecture 3 Tier architecture: Presentation Layer Presentation Layer is the layer responsible for displaying user interface. Presentation Layer Presentation Layer is the layer responsible for displaying user interface. Business Tier Business Tier is the layer responsible for accessing the data tier to retrieve, modify and delete data to and from the data tier and send the results to the presentation tier. This layer is also responsible for processing the data retrieved and sent to the presentation layer. Business Tier Business Tier is the layer responsible for accessing the data tier to retrieve, modify and delete data to and from the data tier and send the results to the presentation tier. This layer is also responsible for processing the data retrieved and sent to the presentation layer. BLL and DAL Often this layer is divided into two sub layers: the Business Logic Layer (BLL), and the Data Access Layers (DAL). Business Logic Layers are above Data Access Layers, meaning BLL uses DAL classes and objects. DAL is responsible for accessing data and forwarding it to BLL. Data Tier Data tier is the database or the source of the data itself. Data Tier Data tier is the database or the source of the data itself. Common mistakes – tightly coupling layers in technology and writing business logic in presentation tier

Hexagon Architecture Allow an application to equally be driven by users, programs, automated test or batch scripts.

SOA SOA is an architectural style whose goal is to achieve loose coupling among interacting software agents. A service is a unit of work done by a service provider to achieve desired end results for a service consumer in SOA, services are the mechanism by which needs and capabilities are brought together.

SOA - Principles Visibility – the ability for a service consumer to “see” a service provider (Awareness, willingness and Reachability) Interaction - the activity of using a capability. (usually message exchange - by contracts, constraints and policies, for example Web Service Description Language) Effect – the result of an interaction

SOA - example

Component Manager and EXE Runner paradigm Why should the GUI client have the EXE main thread? Why shouldn’t we have a visual and easy to use interface for configuring and\or adding\removing physical components? Solution: Component Manager – drag and drop assemblies and connect functionality using events and delegate signatures, eventually compile an XML file that will represent all assemblies and connections Component Manager – drag and drop assemblies and connect functionality using events and delegate signatures, eventually compile an XML file that will represent all assemblies and connections EXE Runner – Run the XML file with the EXE main thread loading the application assemblies and connecting relations in run-time EXE Runner – Run the XML file with the EXE main thread loading the application assemblies and connecting relations in run-time

Components Vs namespaces Vs Classes Classes separation OOP concepts Namespace separation -Logical domain considerations (functional) Assembly separation - Physical domain considerations (maintenance, usability)

Thin, rich and smart clients Thin client – web Rich client – full blown application Smart client – components on demand in click-once deployment and update approach

Code and configuration separation Hard Code AS LITTLE AS POSSIBLE Pros – Extensibility, less bugs (less code changes), different suite support under the same code base with less administrative overhead (documentation, deployment, QA etc.) Cons – performance, coding overhead EL 2.0 Configuration application block Near future - XAML of Avalon

About me B.A with honors in CS. Assumed different industrial positions such as R&D Manager, chief Architect and Projects manager in Various industry domains such as the Medical, Education and the Security domains. Consultant to various companies in software management, architecture and MS.NET issues Member of the Microsoft.NET Fight Club.