Take control of your SAP testing with UiPath Test Suite
Unit4 desiging classes
1. Designing Classes
1. Designing classes
2. Designing protocols and class visibility
3. The UML object Constraint language
4. Designing methods
2. Introduction
• Designer has to know
– Specification of the class
– interaction of that class with other classes
3. Object oriented design philosophy
• Designing class with reusability in mind ->
more gain in productivity and reduce the time
for developing new application
4. UML Object Constraint Language(OCL)
• The rules and semantics of UML are expressed using OCL
• OCL
– Specification language
– Uses simple logic to specify the properties of the system
• UML modeling constructs requires expression. some example as follow
– Item.selector
• Item -> object
• Selector -> attribute
• Ex : kathir.regno
– Item.selextor[qualifier-value]
• Qualifier is uesd to select related values
• Ex:
– Kathir.phone[2]
– Set->select ( Boolean expression)
• Company.employee->salary>20000
5. Designing classes : process
• Apply design axioms to design calsses , their
atribute, methods and association , structures,
amd protocols
– Refine and complete the static uml class diagrams by
adding details to that design
• Refine attribute
• Design methods and protocols
– Uses uml activity diagram to represent algorithm
• Refine the association bw classes
• Refine class hierarchy and design with inheritance
– Iterate and refine
6. Class visibility: desiging well defined
public , private and protected
protocols
• 2 problems in designing methods or attributes
of class
– Protocol or interface to the class operation and its
visibility
– How it is implemented
• Protocol layers
– Private protocol
– Protected protocol
– Public protocol
7. Internal layer
• Defines the implementation of the object
• Apply axioms and corollaries ( corollary 1) to
decide what to private
• Private protocol
– Includes messages that should not be sent from other
objects
– Accessible to only operations of that class
• Protected protocol
– Methods and attributes can be used by class itself or
its subclass
8. External layer
• Design the functionality of the object
• Public protocol
– Defined to pass message bw associated classes
– Interpretation and implementation of each
message is up to the individual classes
9. Encapsulation leakage
• lack of well designed protocol leads to this
problem
• Encapsulation leakage occurs when details
about classes internal implementation are
disclosed through the interface
10. Refining attribute
• Attribute
– Represents the state of the object
• Analysis phase -> name of the attribute is sufficient
• Design phase -> detailed information must
be added
• Attribute types
– Single valued attribute
• Ex: dob of the student
– Multiplicity or multivalue attribute
• Subjects handled by the staff
– Reference to another object or instance connection
• Person hold the account
11. UML attribute presentation
• OCL is used in the design phase to define the
class attributes
• Attribute presentation
– Visibility name : type-expression = initial-value
– Visibility
• Public visibility : +
• Protected visibility : #
• Private visibility : -
– Type expression
• Language dependent specification of the type
– Initial value
• Language dependent expression for the initial value
12. Designing methods and protocols
• Specifying the algorithm for methods
– By using formal structure (ex uml activity diag) with
OCL
• Types of methods
– Constructor
– Destructor
– Conversion method
– Copy method
– Attribute set
– Attribute get
– IO methods
– Domain specific
13. Design issues : avoiding pitfalls
• Better to have Large set of simple classes than
few large , complex classes
– Initially class might be too bid
– Apply design axioms and corollary
• to reduce the size
• Improve reusability
14. UML Operation presentation
• Visibility name: (Parameter list ) : return-type-expression
– Visibility
• Public visibility : +
• Protected visibility : #
• Private visibility : -
– Name
• Name of the operation
– Parameter list
• List of parameters each specified by
– Name : type expression = default value
– Return type expression
– Ex:
• + withdraw(amount:type):