controller
DESCRIPTION
TRANSCRIPT
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year
CONTROLLER
1
OBJECT ORIENTED
ANALYSIS AND DESIGN
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 2
DEFINITION
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.
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 3
PROBLEM
What first object beyond the UI layer receives and coordinates a system operation?
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 4
SOLUTION
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.
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 5
CONTD.,
2)Represents a Use Case Scenario
within which the system event occurs, often named
<usecaseName> Handler, <usecaseName> Coordinator, or <usecaseName> Session.
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 6
CONTD.,
(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).
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 7
EXAMPLE
Some System Operations of NextGen Pos Application
endsale()enterItem()makeNewSale()makePayment() …………………….
System
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 8
ItemID
Quantity
ENTER SAVE
:SaleJFrame
:?????
actionPerformed (actionEvent)
enterItem(itemID,qty)
UI Layer
Domain Layer
Presses Button
System Operation Messages
Which class of object should be responsible for receiving system event message?
Controller
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 9
ItemID
Quantity
ENTER SAVE
:SaleJFrame
:Register
actionPerformed (actionEvent)
UI Layer
Domain Layer
Presses Button
enterItem(itemID,qty)
System Operation Messages
Controller
:Sale
1:makeLineitem(itemID,qty)
Desirable Coupling of UI to domain Layer
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year
ItemID
Quantity
ENTER SAVE
:SaleJFrame
:Sale
actionPerformed (actionEvent)
UI Layer
Domain Layer
Presses Button
Sale Jframe should not send this message
10
1:makeLineitem(itemID,qty)
Less Desirable Coupling of User Interface to domain Layer
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 11
CONTROLLER CHOICES IN TERMS OF INTERACTION DIAGRAM
:Register
:ProcessSaleHandler
enterItem(id,quantity)
enterItem(id,quantity)
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 12
System Operations Discovered during system
behaviour analysis
Allocation of system operations during design
using one façade controller
endsale()enterItem()makeNewSale()makePayment()makeNewReturn()enterReturnItem() …………………….
System
endsale()enterItem()makeNewSale()makePayment()makeNewReturn()enterReturnItem() …………………….
Register……………………………….
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 13
DISCUSSION
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.
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 14
CONTD.,
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.
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 15
CONTD.,
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.
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 16
BENEFITS
Increased potential for reuse and pluggable interfaces.
Opportunity to reason about the state of the usecase.
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 17
RELATED PATTERNS
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.
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 18
CONTD.,
• 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)
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 19
IMPLEMENTATION
Java Technologies are used for implementation for the two reasons:
i. Rich Client in Java Swing.ii. Web UI with struts on the Server.
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 20
RICH CLIENT UIPackage.com.craiglarman.nextgen.ui.swing;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
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 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;}}
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 22
BLOATED CONTROLLERS
DEFINITIONPoorly designed, a controller class with have
low cohesion-unfocused and handling too many areas of responsibility, this is called a
Bloated Controller.
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 23
SIGNS OF BLOATING
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.
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 24
CONTD.,
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.
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 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.
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 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.
Use Case Controllers
Make Reservation Handler
Make Schedules Handler
Make Fares Handler
Apr 10, 2023 Controller - K.INIYA CSE Prefinal Year 27
THANK YOU