Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide


  1. 1. 9-Oct-13 1Controller - K.INIYA CSE Prefinal Year
  2. 2. 9-Oct-13 2 It is the first object beyond the UI Layer responsible for receiving or handling a system operation message. The controller pattern assigns the responsibility of dealing with system events to a non class that represents the overall system or a use case scenario. Controller - K.INIYA CSE Prefinal Year
  3. 3. 9-Oct-13 3 What first object beyond the UI layer receives and coordinates a system operation? Controller - K.INIYA CSE Prefinal Year
  4. 4. Assigning the responsibility to a class representing one of the following option 1)representing the overall system a root object, a device that the software is running within or a major subsystem. These are the variations of facade controller. 9-Oct-13 4Controller - K.INIYA CSE Prefinal Year
  5. 5. 2)Represents a Use Case Scenario within which the system event occurs, often named <usecaseName> Handler, <usecaseName> Coordinator, or <usecaseName> Session. 9-Oct-13 5Controller - K.INIYA CSE Prefinal Year
  6. 6. (a) Use the same controller class for all system events in the same usecase scenario. (b) Informally, a session is an instance of a conversion with an actor. Sessions can be of any length but are often organized in terms of usecases (use case Sessions). 9-Oct-13 6Controller - K.INIYA CSE Prefinal Year
  7. 7. 9-Oct-13 7 Some System Operations of NextGen Pos Application endsale() enterItem() makeNewSale() makePayment() ……………………. System Controller - K.INIYA CSE Prefinal Year
  8. 8. 9-Oct-13 8Controller - K.INIYA CSE Prefinal Year
  9. 9. ItemID Quantity ENTER SAVE :SaleJFrame :Regi st er actionPerformed (actionEvent) UI Layer Domain Layer Presses Button 9-Oct-13 9 enterItem(itemID,qty) System Operation Messages Controller :Sale 1:makeLineitem(itemID,qty) Desirable Coupling of UI to domain Layer Controller - K.INIYA CSE Prefinal Year
  10. 10. Controller - K.INIYA CSE Prefinal Year ItemID Quantity ENTER SAVE :SaleJFrame :Sal e actionPerformed (actionEvent) UI Layer Domain Layer Presses Button Sale Jframe should not send this message 9-Oct-13 10 1:makeLineitem(itemID,qty) Less Desirable Coupling of User Interface to domain Layer
  11. 11. 9-Oct-13 11 :Register :ProcessSaleHandler enterItem(id,quantity) enterItem(id,quantity) Controller - K.INIYA CSE Prefinal Year
  12. 12. System Operations Discovered during system behaviour analysis Allocation of system operations during design using one façade controller 9-Oct-13 12 endsale() enterItem() makeNewSale() makePayment() makeNewReturn() enterReturnItem() ……………………. System endsale() enterItem() makeNewSale() makePayment() makeNewReturn() enterReturnItem() ……………………. Register …………………… …………. Controller - K.INIYA CSE Prefinal Year
  13. 13. UI Layer does not contain Application Logic rather UI Layer Objects must delegate work requests to another layer. System receives external input events ,that involves GUI operated by a Person. 1) Other inputs are external messages. 2) For example: in a call processing telecommunications switch or signals from sensors. 9-Oct-13 13Controller - K.INIYA CSE Prefinal Year
  14. 14. A controller then suffers from bad (low) cohesion violating the principle of High Cohesion. Facade controller are suitable when there are “too many” system events, or when the User Interface (UI) cannot redirect system event messages to alternating controllers, such as in a message processing system. 9-Oct-13 14Controller - K.INIYA CSE Prefinal Year
  15. 15. Boundary, Entity, Control classes in UP. (a)Boundary objects are abstractions of the interfaces. (b)Entity objects are the application independent domain software objects. (c)Control objects are use Case handlers as in Controller Pattern. 9-Oct-13 15Controller - K.INIYA CSE Prefinal Year
  16. 16. Increased potential for reuse and pluggable interfaces. Opportunity to reason about the state of the usecase. 9-Oct-13 16Controller - K.INIYA CSE Prefinal Year
  17. 17. Command- In a message handling system, each message may be represented and handled by a separate command object. Façade- A façade controller is a kind façade. Layers- Placing domain logic in the domain Layer rather than the Presentation Layer is the part of the Layers. 9-Oct-13 17Controller - K.INIYA CSE Prefinal Year
  18. 18. • Pure Fabrication- A use case Controller is a kind of Pure Fabrication. (Pure Fabrication is a class that does not represent a concept in the problem Domain, specially made up to achieve low coupling, high cohesion and reuse potential) 9-Oct-13 18Controller - K.INIYA CSE Prefinal Year
  19. 19. Java Technologies are used for implementation for the two reasons: i. Rich Client in Java Swing. ii. Web UI with struts on the Server. 9-Oct-13 19Controller - K.INIYA CSE Prefinal Year
  20. 20.; Public class ProcessSaleJFrame extends Jframe { Private Register register; Public ProcessSaleJFrame(Register_register) { register=_register; } Private Jbutton BTN_ENTER_ITEM() Private Jbutton getBTN_ENTER_ITEM() { If (BTN_ENTER_ITEM!=null) return BTN_ENTER_ITEM; else 9-Oct-13 20Controller - K.INIYA CSE Prefinal Year
  21. 21. BTN_ENTER_ITEM=new Jbutton(); BTN_ENTER_ITEM.setText(“ENTER”) BTN_ENTER_ITEM.addActionListener(newActionListener() { Public void actionPerformed(ActionEvent e) { ItemID id=Transformer.toItemID(getTXT_ID().getText()); Int qty=Transformer.toInt(getTXT_QTY().getText()); register.enterItem(id,qty); } }); return BTN_ENTER_ITEM; } } 9-Oct-13 21Controller - K.INIYA CSE Prefinal Year
  22. 22. DEFINITION Poorly designed, a controller class with have low cohesion-unfocused and handling too many areas of responsibility, this is called a Bloated Controller. 9-Oct-13 22Controller - K.INIYA CSE Prefinal Year
  23. 23. There is only a Single Controller class receiving all system events in the system. This sometimes happens if a façade controller is chosen. The Controller itself performs many of the tasks necessary to fulfill the system event. This usually involves a violation of Information Expert and High Cohesion. 9-Oct-13 23Controller - K.INIYA CSE Prefinal Year
  24. 24. A Controller has many attributes and it maintains significant information about the system or domain, which should have been distributed to other objects, or it duplicates information found elsewhere. 9-Oct-13 24Controller - K.INIYA CSE Prefinal Year
  25. 25. Among the cures for a bloated controller are these two: 1)Add more controllers- a system does not have to need only one. For example: consider the application with many system events, such as an Airline Reservation System. 9-Oct-13 25Controller - K.INIYA CSE Prefinal Year
  26. 26. It may contain the following Controllers 2) Design the controller so that it primarily delegates the fulfillment of each system operation responsibility to other objects. 9-Oct-13 26 Use Case Controllers Make Reservation Handler Make Schedules Handler Make Fares Handler Controller - K.INIYA CSE Prefinal Year
  27. 27. 9-Oct-13 27Controller - K.INIYA CSE Prefinal Year