Balinenipraveen.files.wordpress.com



WEEK-1:AIM: To create a UML diagram of ATM APPLICATION.Class Diagram for ATM APPLICATION:Documentation:Different Classes identified in this Class Diagram are:Class name: ATM machineAttributes: system id, locationOperations: display pin no screen, display menu, issue cash and check balanceRelationships: association with Client and AtmCard and aggregated with AtmCardReader, AtmDisplay, AtmKeyboardClass name: ClientAttributes: name, account numberOperations: insert card , enter pin, select transactionRelationships: association with account type and AtmMachineClass name: ATM TransactionsAttributes: TId , client nameRelationships: Associated with ATM card and base classes for Withdraw ,Change Pin ,Transfer Money ,Check BalanceClass name: ATM CardAttributes: card, typeRelationships: Associated with ATM Machine and base classes for Credit Card ,Debit CardUseCase Diagram for ATM APPLICATION:Documentation:The UseCase diagram consists of different usecases like:withdraw ,check balance, do charity ,pay bills, deposit with the corresponding Actor as the Customer.Forward and Reverse Engineering for ATM APPLICATION:Forward Engineering:Steps to be followed for forward engineering:Create a new folder in any of the drive.Select Tools menu from the menu bar.In Tools menu select Java/J2EE.Select Project Specification .Specify the path in which the new folder has been created. Click OK.Select the Class Diagram.Select Tools -> Java/J2EE -> Generate Code.Java code is generated for every class with methods, constructors.Code Generated For Different Classes:public class AccountType { private String type; private String name; public Client theClient; public AccountType() { }}public class AtmCard { private Integer cardNumber; private String type; public AtmTransactions theAtmTransactions; public AtmMachine theAtmMachine; public AtmCard() { }}public class AtmCardReader { public AtmMachine theAtmMachine; public AtmCardReader() { }}public class AtmDisplay { public AtmMachine theAtmMachine; public AtmDisplay() { }}public class AtmKeyboard { public AtmMachine theAtmMachine; public AtmKeyboard() { }}public class AtmMachine { private String location; private Number SystemId; public AtmCard theAtmCard; public Client theClient; public AtmCardReader theAtmCardReader; public AtmDisplay theAtmDisplay; public AtmKeyboard theAtmKeyboard; public AtmMachine() { } public Integer displayPin() { return null; } public String displayMenu() { return null; }public Integer issueCash() { return null; } public Integer checkBalance() { return null; }}public class AtmTransactions { private Number Tid; private String cname; public AtmCard theAtmCard; public AtmTransactions() { }}public class ChangePin extends AtmTransactions { private Integer pin; public ChangePin() {} public void pinChange() { }}public class CheckBalance extends AtmTransactions { private Integer pinNo; public CheckBalance() { } public Integer checkBalance() { return null; }}public class Client { private String name; private Integer accountNo; public AccountType theAccountType; public AtmMachine theAtmMachine; public Client() { }public void insertCard() { } public Integer enterPin() { return null; } public void selectTransaction() { }}public class CreditCard extends AtmCard { public CreditCard() { }}public class CurrentAccount extends AccountType { private Integer accountNo; public CurrentAccount() { }}public class DebitCard extends AtmCard{ public DebitCard() { }}public class SavingsAccount extends AccountType { private Integer accountNo; public SavingsAccount() { }}public class TransferMoney extends AtmTransactions { private Integer accountNo; private Integer amount; public TransferMoney() { } public void moneyTransfer() { }}public class Withdraw extends AtmTransactions { private Integer Amount; private Integer pin; public Withdraw() { } public void moneyWithdrawl() { }}Reverse Engineering: Steps to be followed for Reverse Engineering:Create a new Class Diagram and a component.Select Tools ->Java/J2EE ->Reverse Engineer.Here select all the .java files and click on Add.The files get imported to the second part.Click on Select All and then click Reverse.If any errors occur check the log and deselect those files from the list and continue the above steps.Open the new Class Diagram.Right click on the component and select open specificationSelect Realizes tab and drag the respective classes onto the new class diagram. Thus the classes and their relationships are shown.Sequence /Collaboration Diagrams for ATM APPLICATION: Sequence diagram for GetMiniStatement:Collaboration Diagram for GetMiniStatement:Sequence Diagram for Check Balance :Collaboration Diagram for Check Balance:Sequence Diagram for Transfer Money:Collaboration Diagram for Transfer Money:Sequence Diagram for Pay Bills:Collaboration Diagram for PayBills:Sequence Diagram for Withdraw Money:Collaboration Diagram For Withdraw Money:Activity Diagram for ATM APPLICATION:State Chart Diagram for ATM APPLICATION:Component Diagram for ATM APPLICATION:Deployment Diagram for ATM APPLICATION:WEEK-2:AIM: To create a UML diagram of LIBRARYMANAGEMENT SYSTEM.Class Diagram for LIBRARY MANAGEMENT SYSTEM:Documentation:Different Classes identified in this Class Diagram are:Class name: LibraryAttributes: name ,locationRelationships: association with books ,librarian, membersClass name: BooksAttributes: typeRelationships: base classes for magazines ,journal, branch booksClass name: MembersAttributes: loginOperations: borrow books ,replace books, read booksRelationships: base classes for student ,facultyClass name: LibrarianAttributes: name, idOperations: issue book, impose fine, receive bookRelationships: base classes for clerk ,assistant librarianFORWARD /REVERSE ENGINEERING:Forward engineering:Steps to be followed for forward engineering:Create a new folder in any of the drive.Select Tools menu from the menu bar.In Tools menu select Java/J2EE.Select Project Specification .Specify the path in which the new folder has been created. Click OK.Select the Class Diagram.Select Tools -> Java/J2EE -> Generate Code.Java code is generated for every class with methods, constructors.Code Generated for Different classes:public class Clerk extends Librarian { private String name; private Ineteger Id; public Library theLibrary; public Clerk() { }}public class Faculty extends Members { private Integer id; private String name; public Faculty() { }}public class Journalls extends Books { private string name; private Integer id; public Journalls() { }}public class Librarian { private string name; private Integer id; public Library theLibrary; public Librarian() { } public void issueBooks() { } public void recieveBook() { }}public class Student extends Members { private Integer id; private String name; public Members theMembers; public Student() { }}public class SubjectBooks extends Books { private string name; private Integer id; public SubjectBooks() { }}public class Systems { private integer no; public Systems() { }}REVERSE ENGINEERING:Steps to be followed for Reverse Engineering:Create a new Class Diagram and a component.Select Tools ->Java/J2EE ->Reverse Engineer.Here select all the .java files and click on Add.The files get imported to the second part.Click on Select All and then click Reverse.If any errors occur check the log and deselect those files from the list and continue the above steps.Open the new Class Diagram.Right click on the component and select open specificationSelect Realizes tab and drag the respective classes onto the new class diagram. Thus the classes and their relationships are shown. USECASE Diagram for LIBRARY MANAGEMENT SYSTEM:Documentation:The UseCase diagram consists of different usecases like:Read newspapers, book search , issue book, book renewal, book penaltySEQUENCE/COLLABORATION DIAGRAMS for LIBRARY MANAGEMENT SYSTEM:Sequence Diagram for book penaltyCollaboration Diagram for book penalty:Sequence Diagram for read newspapers:Collaboration Diagram for read news papers:Sequence Diagram for Book Renewal:Collaboration Diagram for Book Renewal:Sequence Diagram for Book Issue:Collaboration Diagram for Issue Book:Activity Chart Diagram for LIBRARY MANAGEMENT SYSTEM:State Diagram for LIBRARY MANAGEMENT SYSTEM:Component Diagram for LIBRARY MANAGEMENT SYSTEM:Deployment Diagram for LIBRARY MANAGEMENT SYSTEM:WEEK-3:AIM: To create a UML diagram of ONLINE BOOK STORE.Class Diagram for ONLINE BOOK STORE:Documentation:Different Classes identified in this Class Diagram are:Class name: online book storeAttributes: name, idOperations: book deliveryRelationships: association with book order, customer ,shipment, invoice ,transactionsClass name: customerAttributes: name, id, passwordOperations: book search, get shipping status, add book to cart, remove book from cartRelationships: association with shopping cart Class name: book orderAttributes: book ,quantityOperations: add book, display, get priceRelationships: association with book and aggregated with order, shopping cartClass name: TransactionsAttributes: name, payment modeOperations: commit, roll back, is successfulRelationships: association with online book storeClass name: invoiceAttributes: invoice noOperations: generate invoiceRelationships: association with online book storeClass name: bookAttributes: title ,publisher, year published, isbn , price, book idRelationships: base classes for text, magazines, journalsForward and Reverse Engineering:Forward Engineering:Steps to be followed for forward engineering:Create a new folder in any of the drive.Select Tools menu from the menu bar.In Tools menu select Java/J2EE.Select Project Specification .Specify the path in which the new folder has been created. Click OK.Select the Class Diagram.Select Tools -> Java/J2EE -> Generate Code.Java code is generated for every class with methods, constructors.Code Generated For Different Classes:public class Address { private String street; private String city; private String state; private String country; private Number code; public Customer theCustomer; public Address() { }} public class Book { private String title; private String publisher; private Number yearpublished; private Number ISBN; private Number price; private Number bookId; public Book() { }}public class BookOrder { private String book; private Number quantity; public Order theOrder; public Book theBook; public ShoppingCart theShoppingCart; public OnlineBookStore theOnlineBookStore; public BookOrder() { } public void addBook() { } public void display() { } public Float getPrice() { return null; }}public class Customer { private String Name; private Number CustomerID; private String Password; public Address theAddress; public ShoppingCart theShoppingCart; public OnlineBookStore theOnlineBookStore; public Customer() { } public void bookSearch() { } public void getShippingStatus() { } public void addBookToCart() { } public void removeBookFromCart() { }}public class Invoice { private Number invoiceno; public OnlineBookStore theOnlineBookStore; public Invoice() { } public Number genInvoice() { return null; }}public class Journals extends Book { private String name; private Integer Id; public Journals() { }}public class Magazines extends Book { private String name; private Integer Id; public Magazines() { }}public class OnlineBookStore { private String name; private Integer id; public Customer theCustomer; public Order theOrder; public BookOrder theBookOrder; public Transactions theTransactions; public Shipment theShipment; public Invoice theInvoice; public OnlineBookStore() { } public void bookDelivery() { }}public class Order { private Number salesTax; private Number ShippingFee; private Number total; public BookOrder theBookOrder; public OnlineBookStore theOnlineBookStore; public Order() { }}public class Shipment { public OnlineBookStore theOnlineBookStore; public Shipment() { } public void booksSent() { }}public class ShoppingCart { public Customer theCustomer; public BookOrder theBookOrder; public ShoppingCart() { } public void addBook() { } public void display() { } public void save() { }}public class Texts extends Book { private String name; private Integer id; public Texts() { }}public class Transactions { private String paymentmode; private int name; public OnlineBookStore theOnlineBookStore; public Transactions() { } public void commit() { } public void rollback() { } public void issuccessful() { }}Reverse Engineering:Steps to be followed for Reverse Engineering:Create a new Class Diagram and a component.Select Tools ->Java/J2EE ->Reverse Engineer.Here select all the .java files and click on Add.The files get imported to the second part.Click on Select All and then click Reverse.If any errors occur check the log and deselect those files from the list and continue the above steps.Open the new Class Diagram.Right click on the component and select open specificationSelect Realizes tab and drag the respective classes onto the new class diagram. Thus the classes and their relationships are shown.UseCase Diagram for ONLINE BOOK STORE:Documentation:The UseCase diagram consists of different usecases like:Browse books, check availability ,register ,place order ,payment with the corresponding actors customer, database.SEQUENCE/COLLABORATION Diagrams for ONLINE BOOK STORE:Sequence Diagram for online Registration:Collaboration Diagram for online Registration:Sequence Diagram for Browse Books:Collaboration Diagram for Browse Books:Sequence Diagram for Availability:Collaboration Diagram for Availability:Sequence Diagram for Place Order/add or remove from cart:Collaboration Diagram for Place Order/add or remove from cart:State Chart Diagram for ONLINE BOOK STORE:Activity Diagram for ONLINE BOOK STORE:Component Diagram for ONLINE BOOK STORE:Deployment Diagram for ONLINE BOOK STORE:WEEK-4:AIM: To create a UML diagram of RAILWAY RESERVATION SYSTEM.Class Diagram for RAILWAY RESERVATION:Documentation:Different Classes identified in this Class Diagram are:Class name: Railway Reservation SystemAttributes: Station nameOperations: trains available , book ticket , cancel ticketRelationships: association with Train ,Payment, Passenger and TicketClass name: TrainAttributes: train name ,train no ,arrival ,departure, start, destinationRelationships: association with Railway ReservationS ystemClass name: PaymentAttributes: payment modeRelationships: association with Railway Reservation System and aggregated with Manual and OnlineClass name: PassengerAttributes: name, ageOperations: Book_tickets ,Cancel_ticketsRelationships: association with Railway Reservation SystemClass name: TicketAttributes: PNR,train_name ,arrival_date ,Station, Train_numOperations: Book_tickets ,Cancel_ticketsRelationships: association with Railway Reservation SystemClass name: ManualAttributes: Operations: Fill_form, BookingRelationships: association with Clerks and aggregated with PaymentClass name: PassengerAttributes: name, ageOperations: Book_tickets ,Cancel_ticketsRelationships: association with Railway Reservation SystemClass name: OnlineAttributes: Card_type, Card_numOperations: Book_ticket, Cancel_ticketRelationships: aggregated with PaymentClass name: ClerksAttributes: Clerk_name, Clerk_idOperations: BookTicket, ReceivePaymentRelationships: association with ManualForward and Reverse Engineering for RAILWAY RESERVATION SYSTEM:Forward Engineering:Steps to be followed for forward engineering:Create a new folder in any of the drive.Select Tools menu from the menu bar.In Tools menu select Java/J2EE.Select Project Specification .Specify the path in which the new folder has been created. Click OK.Select the Class Diagram.Select Tools -> Java/J2EE -> Generate Code.Java code is generated for every class with methods, constructors.Code Generated for the classes:public class Clerks { private String Clerk_name; private Number Clerk_id; public Clerks() { } public void BookTicket() { } public void RecievePayment() { }}public class Manual extends Payment { public Clerks theClerks; public Manual() { } public void Fill_form() { } public void Booking() { }}public class Online extends Payment { private String Card_type; private Number Card_no; public Online() { } public void Book_ticket() { } public void Cancel_Ticket() { }}public class Passenger { private String name; private Number age; public Passenger() { } public void Book_tickets() { } public void Cancel_tickets() { }}public class Payment { private String payment_mode; public Payment() { }}public class RailwayReservationSystem { private String StationName; public Train theTrain; public Payment thePayment; public Ticket theTicket; public Passenger thePassenger; public RailwayReservationSystem() { } public void bookTicket() { } public void cancelTicket() { } public Integer trainsAvailable() { return null; }}public class Ticket { private Number PNR; private String train_name; private Number arrival_date; private String Station; private Number Train_num; public Ticket() { }}public class Train { private String trainName; private Number trainNo; private String arrival; private String departure; private String start; private String destination; public Train() { }}REVERSE ENGINEERING:Steps to be followed for Reverse Engineering:Create a new Class Diagram and a component.Select Tools ->Java/J2EE ->Reverse Engineer.Here select all the .java files and click on Add.The files get imported to the second part.Click on Select All and then click Reverse.If any errors occur check the log and deselect those files from the list and continue the above steps.Open the new Class Diagram.Right click on the component and select open specificationSelect Realizes tab and drag the respective classes onto the new class diagram. Thus the classes and their relationships are shown.USECASE Diagram for RAILWAY RESERVATION SYSTEM:Documentation:The UseCase diagram consists of different usecases like:check for train availability ,check seat availability ,fill form ,submit form ,receive payment ,issue/cancel ticket ,book/cancel ticket corresponding to the actor Passenger.check for train availability ,check seat availability ,receive payment ,issue /cancel ticket with respect to the actor RRS.SEQUENCE/ COLLABORATION DIAGRAM for RAILWAY RESERVATION SYSTEM:Sequence Diagram for SEAT AVAILABILITY:Collaboration Diagram for SEAT AVAILABILITY:Sequence Diagram for Book/Cancel Ticket:Collaboration Diagram for Book/Cancel Ticket:Sequence Diagram Online Reservation :Collaboration Diagram for Online Reservation:STATE CHART Diagram for RAILWAY RESERVATION SYSTEM:ACTIVITY Diagram for RAILWAY RESERVATION SYSTEM:Component Diagram for for RAILWAY RESERVATION SYSTEM:Deployment Diagram for RAILWAY RESERVATION SYSTEM:WEEK-5:AIM: To create a UML diagram for BANKING SYSTEM.Class Diagram for BANKING SYSTEM:Documentation:Different Classes identified in this Class Diagram are:Class name: BankAttributes: name, branchOperations: Relationships: association with Employee ,Account, Customer ,Transactions, Loan Class name: EmployeeAttributes: name, id Operations: openAccount ,closeAccount ,loanRequests ,provideInformationRelationships: association with BankClass name: CustomerAttributes: name ,idOperations: openAccount , closeAccount ,withdrawMoney ,DepositMoney, transferMoney, applyforLoan, chequebookRequestRelationships: association with BankClass name: AccountAttributes: id, typeOperations: Relationships: association with Bank Class name: TransactionsAttributes: id ,integerOperations: Relationships: association with Bank and aggregated with Deposit,Withdraw,TransferClass name: LoanAttributes:id,A/C no,purposeOperations: applyLoan,loanSanctioned,loanRejectedRelationships: association with Bank FORWARD /REVERSE ENGINEERING for BANKING SYSTEM:Forward Engineering:Steps to be followed for forward engineering:Create a new folder in any of the drive.Select Tools menu from the menu bar.In Tools menu select Java/J2EE.Select Project Specification .Specify the path in which the new folder has been created. Click OK.Select the Class Diagram.Select Tools -> Java/J2EE -> Generate Code.Java code is generated for every class with methods, constructors.Code Generated for different classes are:public class Account { private Integer id; private String type; public Bank theBank; public Account() { }}public class Bank { private String name; private String branch; public Employee theEmployee; public Transactions theTransactions; public Account theAccount; public BankManager theBankManager; public Customer theCustomer; public Loan theLoan; public Bank() { } public void transactions() { } public void updatedetails() { } public void provideLoan() { }}public class BankManager { private String managerName; private Integer ID; private Boolean isSanctioned; public Bank theBank; public BankManager() { } public void loanSanctioned() { } public void loanRejected() { }}public class Employee { private String name; private Integer id; public Bank theBank; public Employee() { } public void openAccount() { } public void closeAccount() { } public void loanRequests() { } public void provideInformation() { }}Reverse Engineering:Steps to be followed for Reverse Engineering:Create a new Class Diagram and a component.Select Tools ->Java/J2EE ->Reverse Engineer.Here select all the .java files and click on Add.The files get imported to the second part.Click on Select All and then click Reverse.If any errors occur check the log and deselect those files from the list and continue the above steps.Open the new Class Diagram.Right click on the component and select open specificationSelect Realizes tab and drag the respective classes onto the new class diagram. Thus the classes and their relationships are shown.USECASE Diagram for BANKING SYSTEM:Documentation:The UseCase diagram consists of different usecases like:--open account corresponding to the actor Clerk--deposit money ,withdraw money ,transfer money ,check balance ,loan application with respect to actor Customers--deposit money ,withdraw money ,transfer money corresponding to the actor Cashierloan application with respect to the actor ManagerSEQUENCE / COLLABORATION Diagrams for BANKING SYSTEM:Sequence Diagram for Deposit Money:Collaboration Diagram for Money Deposit:Sequence Diagram for Loan:Collaboration Diagram for Loan:Sequence Diagram for Open Account:Collaboration Diagram for Open Account:Sequence Diagram for Transfer Money:Collaboration Diagram for Transfer Money:Sequence Diagram for Withdraw Money:Collaboration Diagram for Withdraw Money:STATE CHART Diagram for BANKING SYSTEM:ACTIVITY Diagram for BANKING SYSTEM:Component Diagram for BANKING SYSTEM:Deployment Diagram for BANKING SYSTEM:WEEK-7:Using UML design Abstract factory design pattern:Pattern Classification:The Abstract Factory design pattern comes under the Creational Object Pattern.Intent:Provide an interface for creating families of related or dependent objects withoutspecifying their concrete classes.Also Known As:This pattern is also known as Kit, ToolKit.Motivation:Forward /Reverse Engineering:Forward Engineering:Source Code:public class AbstractFactory { public AbstractFactory() { }public Shapes getShape() { return null; } public color getColor() { return null; }}public class AbstractFactoryDemo { public FactoryClass theFactoryClass; public AbstractFactoryDemo() { } public void main() { }}public class Blue extends Colors { public Blue() { } public void fillColor() { }}public class Circle extends Shapes { public Circle() { } public void draw() { }}public class ColorFactory extends AbstractFactory { public Colors theColors; public ColorFactory() { } public color getColor() { return null; }}public class Colors { public Colors() { } public void fillColor() { }}public class FactoryClass { public AbstractFactory theAbstractFactory; public FactoryClass() { } public abstractFactory getFactory() { return null; }}public class Green extends Colors { public Green() { } public void fillColor() { }}public class Rectangle extends Shapes { public Rectangle() { } public void draw() { }}public class Red extends Colors { public Red() { } public void fillColor() { }}public class ShapeFactory extends AbstractFactory { public Shapes theShapes; public ShapeFactory() { } public shape getShape() { return null; }}public class Shapes { public Shapes() { } public void draw() { }}public class Square extends Shapes { public Square() { } public void draw() { }} Reverse Engineering:Applicability:Use the Abstract Factory pattern whenA system should be independent of how its products are created, composed,and represented.A system should be configured with one of multiple families of products.A family of related product objects is designed to be used together, andyou need to enforce this constraint.You want to provide a class library of products, and you want to reveal just their interfaces, not their implementations.Structure:Consequences: The Abstract Factory pattern has the following benefits and liabilities:1. It isolates concrete classes.2. It makes exchanging product families easy.3. It promotes consistency among products.4. Supporting new kinds of products is difficult.Known Uses:ET++ uses the Abstract Factory pattern to achieve portability across different window systems. InterViews uses the "Kit" suffix to denote Abstract Factory classes.Related Patterns:Abstract Factory classes are often implemented with factory methods but they can also be implemented using Prototype.WEEK-8:Using UML design Builder Design pattern:Pattern Classification:The Builder design pattern comes under the Creational Object Pattern.Intent:Separate the construction of a complex object from its representation so that the same construction process can create different representations.Parse a complex representation ,create one of several targets.Motivation:The RTF Reader class with a Text Converter object that converts RTF to another textual representation. Text Converter objects are responsible both for performing the data conversion and for representing the token in a particular format.Subclasses of TextConverter specialize in different conversions and formats . A TeXConverter, on the other hand, will implement operations for all requests in order to produce a TeX representation that captures all the stylistic information in the text. A TextWidgetConverter will produce a complex user interface object that lets the user see and edit the text.Forward & Reverse Engineering:Source Code:public class AsciiText { public AsciiText() {}}public class ASCIITextConvertor extends TextConvertor { public ASCIITextConvertor() { } public char convertCharacter() { return 0; } public void getASCIIText() { }}public class RTFReader { public TextConvertor theTextConvertor; public RTFReader() { } public void parseReader() { }}public class TextConvertor { public TextConvertor() { } public char convertCharacter() { return 0; } public font convertFont() { return null; } public string convertParagraph() { return null; }}public class TexTextConvert { public TexTextConvert() { }}public class TexTextConvertor extends TextConvertor { public TexTextConvertor() { } public char convertCharacter() { return 0; } public font convertFontChange() { return null; } public void getTexText() { }}public class TextWidgetConvertor extends TextConvertor { public TextWidgetConvertor() { } public char convertCharacter() { return 0; } public font convertFont() { return null; } public void getTextWidget() { }}Reverse Engineering:Applicability:Use the Builder pattern whenThe algorithm for creating a complex object should be independent of the parts that make up the object and how they're assembled.??????????????The construction process must allow different representations for theobject that's constructed.Structure:Consequences: Here are key consequences of the Builder pattern:1. It lets you a vary a product’s internal representation.2. It isolates code for construction and representation.3. It gives finer control over construction process.Known Uses:The RTF converter application is from ET++. Its text building block uses a builder to process text stored in the RTF format.Builder is a common pattern in Smalltalk-80.Related Patterns:Abstract Factory is similar to Builder in that it too may construct complex objects.A Composite is what the builder often builds.WEEK-9Using UML design Facade Design pattern:Pattern Classification:The Facade design pattern comes under the Structural Object Pattern.Intent:Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.Motivation:Structuring a system into subsystems helps reduce complexity. A common designgoal is to minimize the communication and dependencies between subsystems.One way to achieve this goal is to introduce a facade object that provides a single, simplified interface to the more general facilities of a subsystem.Consider an example of Home Theatre .The Home Theatre Fa?ade is an interface which has different sub systems where the Home Theatre Client delegates various requests to the sub system objects.Forward & Reverse Engineering:Forward Engineering:Source Code:public class Amplifier { private DVDPlayer DvdPlayer; private CDPlayer cdPlayer; private Tuner tuner; public Amplifier() { } public void on() { } public void off() { } public void setDvd() { } public void setCd() { } public void setSurroundSound() { } public void setVolume() { } public void setTuner() { }}public class CDPlayer private Amplifier amplifier; public Amplifier theAmplifier; public CDPlayer() { } public void on() { } public void off() { } public void play() { } public void pause() { } public void eject() { } public void stop() { }}public class DVDPlayer { private Amplifier amplifier; public Amplifier theAmplifier; public DVDPlayer() { } public void on() { } public void off() { } public void play() { } public void pause() { } public void eject() { } public void stop() { }}public class HomeTheatreClient { public HomeTheatreFacade theHomeTheatreFacade; public HomeTheatreClient() { } public void main() { }}public class HomeTheatreFacade { private Amplifier amplifier; private Tuner tuner; private DVDPlayer Dvd; private CDPlayer Cd; private TheatreLights lights; private projector screen; public Screen theScreen; public TheatreLights theTheatreLights; public Amplifier theAmplifier; public Tuner theTuner; public CDPlayer theCDPlayer; public DVDPlayer theDVDPlayer; public Projector theProjector; public HomeTheatreFacade() { } public void watchMovie() { } public void endMovie() { } public void listenToCd() { } public void endCd() { } public void listenRadio() { } public void endRadio() { }}public class Projector { private DVDPlayer DvdPlayer; public DVDPlayer theDVDPlayer; public Projector() { } public void on() { } public void off() { } public void tvMode() { } public void wideScreenMode() { }}public class Screen { public Screen() { } public void up() { } public void down() { }}public class TheatreLights{ public TheatreLights() { } public void on() { } public void off() { } public void dim() { }}public class Tuner { private Amplifier amplifier; public Amplifier theAmplifier; public Tuner() { }public void on() { } public void off() {} public void setFrequency() { }}Reverse Engineering:Applicability:Use the Facade pattern whenYou want to provide a simple interface to a complex subsystem.There are many dependencies between clients and the implementation classes of an abstraction.You want to layer your subsystems. Use a facade to define an entry point to each subsystem level.Structure:Consequences:The Facade pattern offers the following benefits:1. It shields clients from subsystem components, thereby reducing the number of objects that clients deal with and making the subsystem easier to use.2. It promotes weak coupling between the subsystem and its clients.3. It doesn't prevent applications from using subsystem classes if they need to. Thus you can choose between ease of use and generality.Known Uses:The compiler example in the Sample Code section was inspired by theObjectWorks\Smalltalk compiler systemIn the ET++ application framework , an application can have built-inbrowsing tools for inspecting its objects at run-time. This facade defines operations such as InspectObject and InspectClass for accessing the browsers.The Choices operating system uses facades to compose many frameworksinto one.Related Patterns:Related Patterns for Fa?ade are Abstract Factory, Mediator, Singleton.WEEK-11:Using UML design Decorator Design pattern:Pattern Classification:The Decorator design pattern comes under the Structural Object Pattern.Intent:Attach additional responsibilities to an object dynamically. Decorators providea flexible alternative to subclassing for extending functionality.Also Known As:The Decorator design pattern is also known as Wrapper.Motivation:The decorator conforms to the interface of the component it decorates so that its presence is transparent to the component's clients. The decorator forwards requests to the component and may perform additional actions before or after forwarding. Transparency lets you nest decorators recursively, thereby allowing an unlimited number of added responsibilities.Consider a Coffee Shop with various Beverages with different costs. To these beverages various condiments(Decorator) could be added. Forward & Reverse Engineering:Forward Engineering:Source Code:public class Beverage { public Beverage() { } public String getDescription() { return null; } public double cost() { return 0; }}public class CondimentDecorator extends Beverage { public Beverage theBeverage; public CondimentDecorator() { } public String getDescription() { return null; }}public class DarkRoaste extends Beverage { public DarkRoaste() { } public double cost() { return 0; }}public class Decafe extends Beverage { public Decafe() { } public double cost() { return 0; }}public class Espresso extends Beverage { public Espresso() { } public double cost() { return 0; }}public class IcedEskimo extends Beverage { public IcedEskimo() { } public double cost() { return 0; }}public class Milk extends CondimentDecorator { public Milk() { }}public class Mocha extends CondimentDecorator { public Mocha() { }}public class Soya extends CondimentDecorator { public Soya() { }}public class Whipp extends CondimentDecorator { public Whipp() { }}Reverse Engineering:Applicability:Use Decorator,To add responsibilities to individual objects dynamically and transparently, that is, without affecting other objects.For responsibilities that can be withdrawn.When extension by subclassing is impractical. Sometimes a large number of independent extensions are possible and would produce an explosion of subclasses to support every combination. Or a class definition may be hidden or otherwise unavailable for subclassing.Structure:Consequences:The Decorator pattern has at least two key benefits and two liabilities:1. More flexibility than static inheritance.2. Avoids feature-laden classes high up in the hierarchy.3. A decorator and its component aren't identical. 4. Lots of little objects.Known Uses:Many object-oriented user interface toolkits use decorators to add graphicalembellishments to widgets.Related Patterns:The related patterns of Decorator are Adapter ,Composite ,Strategy. ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download