SlideShare a Scribd company logo
1 of 15
Designing Classes

1.   Designing classes
2.   Designing protocols and class visibility
3.   The UML object Constraint language
4.   Designing methods
Introduction
• Designer has to know
  – Specification of the class
  – interaction of that class with other classes
Object oriented design philosophy
• Designing class with reusability in mind ->
  more gain in productivity and reduce the time
  for developing new application
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
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
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
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
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
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
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
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
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
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
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):
Packaging and managing classes

More Related Content

What's hot

Local variables Instance variables Class/static variables
Local variables Instance variables Class/static variablesLocal variables Instance variables Class/static variables
Local variables Instance variables Class/static variablesSohanur63
 
Abstract class and Interface
Abstract class and InterfaceAbstract class and Interface
Abstract class and InterfaceHaris Bin Zahid
 
OOPs Concepts - Android Programming
OOPs Concepts - Android ProgrammingOOPs Concepts - Android Programming
OOPs Concepts - Android ProgrammingPurvik Rana
 

What's hot (7)

Local variables Instance variables Class/static variables
Local variables Instance variables Class/static variablesLocal variables Instance variables Class/static variables
Local variables Instance variables Class/static variables
 
Abstract class and Interface
Abstract class and InterfaceAbstract class and Interface
Abstract class and Interface
 
[OOP - Lec 01] Introduction to OOP
[OOP - Lec 01] Introduction to OOP[OOP - Lec 01] Introduction to OOP
[OOP - Lec 01] Introduction to OOP
 
Object oriented programming With C#
Object oriented programming With C#Object oriented programming With C#
Object oriented programming With C#
 
2. Basics of Java
2. Basics of Java2. Basics of Java
2. Basics of Java
 
OOPs Concepts - Android Programming
OOPs Concepts - Android ProgrammingOOPs Concepts - Android Programming
OOPs Concepts - Android Programming
 
Better Understanding OOP using C#
Better Understanding OOP using C#Better Understanding OOP using C#
Better Understanding OOP using C#
 

Similar to Unit4 desiging classes (20)

c++ Unit I.pptx
c++ Unit I.pptxc++ Unit I.pptx
c++ Unit I.pptx
 
8 oo approach&uml-23_feb
8 oo approach&uml-23_feb8 oo approach&uml-23_feb
8 oo approach&uml-23_feb
 
C++ppt. Classs and object, class and object
C++ppt. Classs and object, class and objectC++ppt. Classs and object, class and object
C++ppt. Classs and object, class and object
 
General oop concept
General oop conceptGeneral oop concept
General oop concept
 
Design patterns-sav
Design patterns-savDesign patterns-sav
Design patterns-sav
 
Data abstraction and object orientation
Data abstraction and object orientationData abstraction and object orientation
Data abstraction and object orientation
 
CS1Lesson13-IntroClasses.pptx
CS1Lesson13-IntroClasses.pptxCS1Lesson13-IntroClasses.pptx
CS1Lesson13-IntroClasses.pptx
 
Object-oriented Analysis, Design & Programming
Object-oriented Analysis, Design & ProgrammingObject-oriented Analysis, Design & Programming
Object-oriented Analysis, Design & Programming
 
1unit-120324103142-phpapp02.pdf
1unit-120324103142-phpapp02.pdf1unit-120324103142-phpapp02.pdf
1unit-120324103142-phpapp02.pdf
 
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)
 
OMTanalysis.ppt
OMTanalysis.pptOMTanalysis.ppt
OMTanalysis.ppt
 
OMTanalysis.ppt
OMTanalysis.pptOMTanalysis.ppt
OMTanalysis.ppt
 
Analysis
AnalysisAnalysis
Analysis
 
Oracle forms les23
Oracle forms  les23Oracle forms  les23
Oracle forms les23
 
c++ Unit III - PPT.pptx
c++ Unit III - PPT.pptxc++ Unit III - PPT.pptx
c++ Unit III - PPT.pptx
 
Design Patterns - GOF
Design Patterns - GOFDesign Patterns - GOF
Design Patterns - GOF
 
VB.net&OOP.pptx
VB.net&OOP.pptxVB.net&OOP.pptx
VB.net&OOP.pptx
 
03 classes interfaces_principlesofoop
03 classes interfaces_principlesofoop03 classes interfaces_principlesofoop
03 classes interfaces_principlesofoop
 
Introducing object oriented programming (oop)
Introducing object oriented programming (oop)Introducing object oriented programming (oop)
Introducing object oriented programming (oop)
 
m211c25.ppt
m211c25.pptm211c25.ppt
m211c25.ppt
 

More from gopal10scs185 (20)

Os5
Os5Os5
Os5
 
Os4
Os4Os4
Os4
 
Os1
Os1Os1
Os1
 
Os8
Os8Os8
Os8
 
Os8
Os8Os8
Os8
 
Os7
Os7Os7
Os7
 
Os6
Os6Os6
Os6
 
Os4
Os4Os4
Os4
 
Os3
Os3Os3
Os3
 
Os2
Os2Os2
Os2
 
Unit three identifying actors
Unit three  identifying actorsUnit three  identifying actors
Unit three identifying actors
 
Unit 5 testing
Unit 5 testingUnit 5 testing
Unit 5 testing
 
Unit 5
Unit 5Unit 5
Unit 5
 
Unit 5 usability and satisfaction test
Unit 5 usability and satisfaction testUnit 5 usability and satisfaction test
Unit 5 usability and satisfaction test
 
Unit 5 testing -software quality assurance
Unit 5  testing -software quality assuranceUnit 5  testing -software quality assurance
Unit 5 testing -software quality assurance
 
Unit 4
Unit 4Unit 4
Unit 4
 
Unit 4 designing classes
Unit 4  designing classesUnit 4  designing classes
Unit 4 designing classes
 
Unit 3 object analysis-classification
Unit 3 object analysis-classificationUnit 3 object analysis-classification
Unit 3 object analysis-classification
 
Unit 3 attributes, methods, relationships
Unit 3 attributes, methods, relationshipsUnit 3 attributes, methods, relationships
Unit 3 attributes, methods, relationships
 
Unit 3
Unit 3Unit 3
Unit 3
 

Recently uploaded

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 

Recently uploaded (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 

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):