Your SlideShare is downloading. ×

Unit4 desiging classes

144
views

Published on

Published in: Technology, Education

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
144
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Designing Classes1. Designing classes2. Designing protocols and class visibility3. The UML object Constraint language4. 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):
  • 15. Packaging and managing classes