authorized: m.v jahan, r shaibani demo chapter vafaeijahan ... · uml dip abstract server servise +...

19
Authorized: M.V Jahan, R Shaibani Demo Chapter VafaeiJahan.com [email protected]; [email protected]

Upload: others

Post on 30-Apr-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Authorized: M.V Jahan, R Shaibani Demo Chapter VafaeiJahan ... · UML DIP Abstract Server Servise + Client A methods + C... + Client B methods + +... + Client C methods + ... Client

Authorized: M.V Jahan, R ShaibaniDemo Chapter

[email protected]; [email protected]

Page 2: Authorized: M.V Jahan, R Shaibani Demo Chapter VafaeiJahan ... · UML DIP Abstract Server Servise + Client A methods + C... + Client B methods + +... + Client C methods + ... Client

UML

Authorized: M.V Jahan, R ShaibaniDemo Chapter

[email protected]; [email protected]

Page 3: Authorized: M.V Jahan, R Shaibani Demo Chapter VafaeiJahan ... · UML DIP Abstract Server Servise + Client A methods + C... + Client B methods + +... + Client C methods + ... Client

(OCP)

OCP

OCP

LogOn

Modem:: Type

Struct Modem { enum Type { hayes, courrier, ernie} type; }; Struct Hayes { Modem:: Type type; // Hayes related stuff }; Struct Courrier { Modem:: Type type; // Courrier related stuff }; Struct Ernie { Modem:: Type type; // Ernie related stuff };

void LogOn ( Modem& m, string& pno, string& user, string& pw ) { if ( m.type == Modem:: hayes ) DialHayes ( ( Hayes& ) m, pno );

else if ( m.type == Modem:: courrier ) DialCourrier ( ( Courrier& ) m, pno);

else if ( m.type == Modem:: ernie ) DialErnie ( ( Ernie& ) m, pno )

}

Authorized: M.V Jahan, R ShaibaniDemo Chapter

[email protected]; [email protected]

Page 4: Authorized: M.V Jahan, R Shaibani Demo Chapter VafaeiJahan ... · UML DIP Abstract Server Servise + Client A methods + C... + Client B methods + +... + Client C methods + ... Client

UML

elseifswitch

HayesCourrier

if ( modem.type == Modem:: ernie ) SendErnie ( ( Ernie& ) modem, c ); else SendHayes ( ( Hayes& ) modem, c );

OCPModem

LogOnModemLogOn

« interface » Modem

+ Dial( pno ) + Send( char ) + Recv(): char + Hangup()

Courrier Modem

Hayes Modem

Ernie's Modem

OCP

OCP

« function » LogOn

class Modem { public: virtual void Dial( const string& pno ) = 0; virtual void Send( char ) = 0; virtual char Recv() = 0; virtual void Hangup() = 0; }; void LogOn( Modem& m, string& pno, string& user, string& pw ) { m.Dial ( pno ) }

Authorized: M.V Jahan, R ShaibaniDemo Chapter

[email protected]; [email protected]

Page 5: Authorized: M.V Jahan, R Shaibani Demo Chapter VafaeiJahan ... · UML DIP Abstract Server Servise + Client A methods + C... + Client B methods + +... + Client C methods + ... Client

OCP

TemplateC++

OCP

LogOn

template < typename MODEM > void LogOn( MODEM& m, string& pno, string& user, string& pw ) { m.Dial(pno); }

OCP

(LSP)

user base

derived

Derived

Base

User

Authorized: M.V Jahan, R ShaibaniDemo Chapter

[email protected]; [email protected]

Page 6: Authorized: M.V Jahan, R Shaibani Demo Chapter VafaeiJahan ... · UML DIP Abstract Server Servise + Client A methods + C... + Client B methods + +... + Client C methods + ... Client

UML

SetFoci

Circle

void Circle:: SetFoci ( const Point& a, const Point& b ) { itsFocusA = a; itsFocusB = a; }

LSP

OCP

Ellipse

Circle

Ellipse

- itsFocusA : Point - itsFocusB : Point - itsMajorAxis : double

+ Circumference() : double + Area() : double + GetFocusA() : Point + GetFocusB() : Point + GetMajorAxis() : double + GetMinorAxis() : double + SetFoci( a: Point, b: Point ) + SetMajorAxis( double )

4SetFociCircle

Authorized: M.V Jahan, R ShaibaniDemo Chapter

[email protected]; [email protected]

Page 7: Authorized: M.V Jahan, R Shaibani Demo Chapter VafaeiJahan ... · UML DIP Abstract Server Servise + Client A methods + C... + Client B methods + +... + Client C methods + ... Client

void f ( Ellipse& e ) {

if ( typeid ( e ) == typeid ( Ellipse ) ) {

Point a ( -1,0 ); Point b ( 1,0 ); e.SetFoci ( a, b ); e.SetMajorAxis ( 3 ); assert ( e.GetFocusA () == a ); assert ( e.GetFocusB () == b ); assert ( e.GetMajorAxis () == 3 );

} else throw NotAnEllipse ( e ); }

(DIP)

COMCORBA

EJB

5

Authorized: M.V Jahan, R ShaibaniDemo Chapter

[email protected]; [email protected]

Page 8: Authorized: M.V Jahan, R Shaibani Demo Chapter VafaeiJahan ... · UML DIP Abstract Server Servise + Client A methods + C... + Client B methods + +... + Client C methods + ... Client

UML

COM

COM

String.hء

C

ANSI

String.hUnicode

Authorized: M.V Jahan, R ShaibaniDemo Chapter

[email protected]; [email protected]

Page 9: Authorized: M.V Jahan, R Shaibani Demo Chapter VafaeiJahan ... · UML DIP Abstract Server Servise + Client A methods + C... + Client B methods + +... + Client C methods + ... Client

Abstract Factory

(ISP)

(COM)

Client AClient BClient C

ISP

Servise

+ Client A methods + ... + Client B methods + ... + Client C methods + ...

Client B

Client C

Client A

Authorized: M.V Jahan, R ShaibaniDemo Chapter

[email protected]; [email protected]

Page 10: Authorized: M.V Jahan, R Shaibani Demo Chapter VafaeiJahan ... · UML DIP Abstract Server Servise + Client A methods + C... + Client B methods + +... + Client C methods + ... Client

UML

DIP

ServerAbstract

Servise

+ Client A methods + ... + Client B methods + ... + Client C methods + ...

Client A

interface Servise A

+ Client A methods + ...

Client B

interface Servise B

+ Client B methods + ...

Client C

interface Servise C

+ Client C methods + ...

interface Resource Manager

Consumer

Resource Manager I

Authorized: M.V Jahan, R ShaibaniDemo Chapter

[email protected]; [email protected]

Page 11: Authorized: M.V Jahan, R Shaibani Demo Chapter VafaeiJahan ... · UML DIP Abstract Server Servise + Client A methods + C... + Client B methods + +... + Client C methods + ... Client

Abstract Factory Builder Prototype Singleton

Adapter( object ) Bridge Composite Decorator Facade Flyweight Proxy Wrapper

Chain of Responsibility Command Iterator Mediator Memento Observer State Strategy Visitor

Wrapper

TSampleWrapperTSampleSample

TSample

TSample = class ( TObject )

private FSomeValue: Integer; public function SomeAction( const Data: string ): Boolean; property SomeValue: Integer read FSomeValue write FSomeValue; end;

TSampleWrapper = class ( TComponent )

private FSample: TSample; protected function GetSomeValue: Integer; procedure SetSomeValue( Value: Integer ); public function SomeAction ( const Data: string ): Boolean; property Sample: TSample read FSample; property SomeValue: Integer read GetSomeValue write SetSomeValue; end;

Authorized: M.V Jahan, R ShaibaniDemo Chapter

[email protected]; [email protected]

Page 12: Authorized: M.V Jahan, R Shaibani Demo Chapter VafaeiJahan ... · UML DIP Abstract Server Servise + Client A methods + C... + Client B methods + +... + Client C methods + ... Client

UML

function TSampleWrapper.GetSomeValue: Integer; begin Result := Sample.SomeValue; end;

function TSampleWrapper.SomeAction ( const Data: string ): Boolean; begin Result := Sample.SomeAction ( Data ); end;

procedure TSampleWrapper.SetSomeValue ( Value: Integer ); begin Sample.SomeValue := Value; end;

Visitor

Visitor

MemberMemeberVisitor

Member

MemberVisitor

MemberVisitor

Mamber

Property Method

Mamber

PropertyMethod

MemberVisitor

Visitor

Authorized: M.V Jahan, R ShaibaniDemo Chapter

[email protected]; [email protected]

Page 13: Authorized: M.V Jahan, R Shaibani Demo Chapter VafaeiJahan ... · UML DIP Abstract Server Servise + Client A methods + C... + Client B methods + +... + Client C methods + ... Client

Member = class ( TObject ) public procedure AcceptMemberVisitor ( Visitor: MemberVisitor ); virtual; end;

Method = class ( TMember )

public procedure AcceptMemberVisitor ( Visitor: MemberVisitor ); override; end;

Property = class ( TMember )

public procedure AcceptMemberVisitor ( Visitor: MemberVisitor ); override; end;

MemberVisitor = class ( TObject )

public procedure VisitMember ( Instance: Member ); virtual; public procedure VisitMethod ( Instance: Method ); virtual; public procedure VisitProperty ( Instance: TProperty ); virtual; end;

// implementation : { M e m b e r }

procedure Member. AcceptMemberVisitor ( Visitor: MemberVisitor );

begin

Visitor.VisitMember( Self );

end;

{ M e t h o d }

procedure Method. AcceptMemberVisitor ( Visitor: MemberVisitor );

begin

Visitor.VisitMethod( Self ); end;

{ P r o p e r t y }

procedure Property. AcceptMemberVisitor ( Visitor: MemberVisitor );

begin Visitor.VisitProperty ( Self ); end;

{ M e m b e r V i s i t o r }

procedure MemberVisitor.VisitMember ( Instance: Member );

begin end;

procedure MemberVisitor.VisitMethod ( Instance: Method );

begin end;

procedure MemberVisitor.VisitProperty ( Instance: Property );

begin end;

Authorized: M.V Jahan, R ShaibaniDemo Chapter

[email protected]; [email protected]

Page 14: Authorized: M.V Jahan, R Shaibani Demo Chapter VafaeiJahan ... · UML DIP Abstract Server Servise + Client A methods + C... + Client B methods + +... + Client C methods + ... Client

UML

MemberVisitorMemberMethodProperty

VisitMember

MemberModem

HayesErnie

ModemUnixVisitor

PropertyMethod

ModemVisitor

ConfigureForUnixModem

HayesErniesUnix

Modem

Modem

Modem

AcceptVisitor( ModemVisitor )

HayesErnie

MamberVisitor

Visit( Hayes )

Visit( Ernie )

ConfigureForUnix

Visitor

Authorized: M.V Jahan, R ShaibaniDemo Chapter

[email protected]; [email protected]

Page 15: Authorized: M.V Jahan, R Shaibani Demo Chapter VafaeiJahan ... · UML DIP Abstract Server Servise + Client A methods + C... + Client B methods + +... + Client C methods + ... Client

Abstract Factory

DIP

Abstract Factory

ModemFactory

theFactoryMake

Modem FactoryIModemFactoryMain

GtheFactory

IModemFactorymain

IModemFactory

user

Abstract Factory

interface Modem Factory

+ Make( string ):Modem *

interface Modem

Hayes

Courrier

Ernie

user

Modem Factory I main program

main

« creates »

« creates »

« creates »

« global »

theFactory

Authorized: M.V Jahan, R ShaibaniDemo Chapter

[email protected]; [email protected]

Page 16: Authorized: M.V Jahan, R Shaibani Demo Chapter VafaeiJahan ... · UML DIP Abstract Server Servise + Client A methods + C... + Client B methods + +... + Client C methods + ... Client

UML

Visitor

DIP

IModemFactoryAbstract Factory

ObserverProxy

Abstract Factory

Visitor

AbstractFactory

createProduct() : AbstractProduct

ConcreteFactory

createProduct() : AbstractProduct

AbstractProduct

Product

makeProduct()

Visitor

visitConcreteElement( element : Element )

ConcreteElement

Element

accept( visitor : Visitor )

ConcreteVisitor

Authorized: M.V Jahan, R ShaibaniDemo Chapter

[email protected]; [email protected]

Page 17: Authorized: M.V Jahan, R Shaibani Demo Chapter VafaeiJahan ... · UML DIP Abstract Server Servise + Client A methods + C... + Client B methods + +... + Client C methods + ... Client

[Alhir03] Sinan Si Alhir, “Learning UML: Communicating Software Design Graphically”

Copyright © 2003 by O’Reilly

[Bennett01] Simon Bennett, John Skelton, Ken Lunn “ Schaum’s Out Line of UML”

Copyright © 2001 by John Wiley & Sons, Inc

[Boggs02] Wendy Boggs, Michael Boggs “Mastering UML with Rational Rose 2002”

Copyright © 2002 by Sybex

[Booch98] James Rumbaugh, Ivan Jacobson, Grady Booch

“The Unified Modeling Language Reference manual”

Copyright © 1998 by Addison-Wesley

[Britton00] Carol Britton, Jill Doake

“Object Oriented Systems Development: A gentle Introduction”

Copyright ©2000 by McGraw-Hill International

[Coad91] Coad P, Yourdon E, “Object Oriented Design”

Copyright © 1991 by Yourdon Press

[Coleman94] Coleman D, Arnold P, Bodoff S, Dolin C, Gilchrist H, Hayes F, Jeremaes P

“Object-Oriented Development: The Fusion Method”

Copyright © 1994 by Prentice Hall

[Cantor98] Murray Cantor, “Object-Oriented Project Management with UML”

Copyright © 1998 by John Wiley & Sons, Inc

[Emmerich00] Wolfgang Emmerich, “Engineering Distributed Objects”

Copyright © 2000 by John Wiley & Sons, Ltd

[Evans04] Gary Evans, “Getting from use cases to code Part 1: Use-Case Analysis”

The Rational Edge, Jul 2004

[Fowler99] Martin Fowler, Kendall Scott

“A Brief Guide to the Standard Object Modeling Language”

Copyright © 1999 by Addison-Wesley

Authorized: M.V Jahan, R ShaibaniDemo Chapter

[email protected]; [email protected]

Page 18: Authorized: M.V Jahan, R Shaibani Demo Chapter VafaeiJahan ... · UML DIP Abstract Server Servise + Client A methods + C... + Client B methods + +... + Client C methods + ... Client

[Favre03] Liliana Favre “UML and the unified process”

Copyright © 2003 by IRM Press

[Gamma98] Erich Gamma, Richard Helm, Ralph Jonson, John Vlissides

“Design Patterns: Elements of reusable Object Oriented Software”

Copyright © 1995 by Addison-Wesley

[Jacobson98] James Rumbaugh, Ivan Jacobson, Grady Booch

“The Unified Modeling Language User Guide”

Copyright © 1998 by Addison-Wesley

[Jacobson92] Ivan Jacobson, Magnus Christenson, Patrick Jonson

“Object Oriented Software Engineering: a Use case Driven Approach”

MA: Addison-Wesley Publishing Company, 1992

[Larman02] Craig Layman, “Applying UML and Patterns”

Copyright © 2002 by prentice hall PTR, Prentice Hall, inc

[Martin98] Robert C. Martin, Dirk Riehle, Frank Buchman

“Pattern Languages of Program Design 3”, 1998

[Marin99] Robert C.Martin “Designing Object Oriented Applications Using UML”

2nd Edition, Prentice Hall,1999

[Oberg00] Roger Oberg, Leslee Probasco, Maria Ericsson

“Applying Requirement Management With Use Cases”

Copyright © 2000 by Rational Software Corporation

[OmgSPEM02] Object Management Group

“Software Process Engineering MetaModel Specification”

version 1.0, formal/02-11-14, November 2002

[OclUml03] Object Management Group

“UML 2.0 OCL Specification” version 2.0, ptc/03-10-14, October 2003

[OmgUml03] Object Management Group

“Unified Modeling Language (UML) Specification: Infrastructure”

version 2.0, ptc/03-09-15, December 2003

Authorized: M.V Jahan, R ShaibaniDemo Chapter

[email protected]; [email protected]

Page 19: Authorized: M.V Jahan, R Shaibani Demo Chapter VafaeiJahan ... · UML DIP Abstract Server Servise + Client A methods + C... + Client B methods + +... + Client C methods + ... Client

UML

[Pressman94] Pressman Roger S, “Software Engineering: a Practitioner’s Approach”

Copyright © 1994 by Addison-Wesley

[Priestley00] Mark Priestley, “Practical Object Oriented Design with UML”

Copyright © 2000 by McGraw-Hill

[Reed02] Paul R. Reed, “Developing Application with JAVA and UML”

Copyright © 2002 by Addison-Wesley

[Rowlett01] Tom Rowlett, “The Object Oriented Development Process”

Copyright © 2001 by Prentice Hall, Inc

[Royce98] Royce, “Software Project Management: A unified framework”

Copyright © 1998 by Addison Wesley Longman, Inc

[Rumbaugh91] Rumbaugh, Balaha, Premerlani, Loren son

“Object Oriented Modeling and Design”

Copyright ©1991 by Prentice Hall

[Sammerville94] Summerville Ian, “Software Engineering”, 4th ed. 1992 Addison-Wesley

[Schach99] Stephen R. Schacht

“Classical and Object Oriented Software Engineering with UML and Java”, 4th Edition

Copyright © 1999 by McGraw-Hill

[Schmidtla96] Douglas C. Schmidt, “Using Design Patterns to Develop High-Performance

Object-Oriented Communication Software Frameworks”, Proceedings of the 8 Annual

Software Technology Conference, Salt Lake City, Utah, April 21–26, 1996

[Shalloway00] Shalloway

“Design Pattern Explained: A New Perspective on Object Oriented Design”

Copyright © 1998 by Addison Wesley, inc

[SWEBOK01] “Guide to the Software Engineering Body of Knowledge (SWEBOK)”

Copyright © 2001 by The Institute of Electrical and Electronics Engineers, Inc

[Whitten01] Jeffry L. Whitten, Lonnie D. Bentley, Kevin C. Dittman

“Systems Analysis and Design Methods” 5th Edition

Copyright © 2001 by McGraw-Hill

Authorized: M.V Jahan, R ShaibaniDemo Chapter

[email protected]; [email protected]