Exploring the Future Potential of AI-Enabled Smartphone Processors
Â
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):