SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

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
 

Tendances (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#
 

En vedette

Give your heart a break
Give your heart a breakGive your heart a break
Give your heart a breakMary Miranda
 
Basic html training national
Basic html training nationalBasic html training national
Basic html training nationalNeedanuts
 
The project gutenberg e book of grimms' fairy tales, by the brothers grimm
The project gutenberg e book of grimms' fairy tales, by the brothers grimmThe project gutenberg e book of grimms' fairy tales, by the brothers grimm
The project gutenberg e book of grimms' fairy tales, by the brothers grimmAndrei Hortúa
 
Ch01-Introduction About Software Engineering
Ch01-Introduction About Software EngineeringCh01-Introduction About Software Engineering
Ch01-Introduction About Software EngineeringBala Ganesh
 

En vedette (7)

Os8
Os8Os8
Os8
 
Give your heart a break
Give your heart a breakGive your heart a break
Give your heart a break
 
Stoop ed-subtyping subclassing
Stoop ed-subtyping subclassingStoop ed-subtyping subclassing
Stoop ed-subtyping subclassing
 
Basic html training national
Basic html training nationalBasic html training national
Basic html training national
 
Os7
Os7Os7
Os7
 
The project gutenberg e book of grimms' fairy tales, by the brothers grimm
The project gutenberg e book of grimms' fairy tales, by the brothers grimmThe project gutenberg e book of grimms' fairy tales, by the brothers grimm
The project gutenberg e book of grimms' fairy tales, by the brothers grimm
 
Ch01-Introduction About Software Engineering
Ch01-Introduction About Software EngineeringCh01-Introduction About Software Engineering
Ch01-Introduction About Software Engineering
 

Similaire à 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
 

Plus de gopal10scs185 (20)

Os5
Os5Os5
Os5
 
Os4
Os4Os4
Os4
 
Os1
Os1Os1
Os1
 
Os8
Os8Os8
Os8
 
Os6
Os6Os6
Os6
 
Os4
Os4Os4
Os4
 
Os3
Os3Os3
Os3
 
Os2
Os2Os2
Os2
 
Unit4 desiging classes
Unit4 desiging classesUnit4 desiging classes
Unit4 desiging classes
 
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
 
Design rule 31
Design rule 31Design rule 31
Design rule 31
 

Dernier

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
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
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
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
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
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
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
 
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
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 

Dernier (20)

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
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
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
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
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
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
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
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
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
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
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
 
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
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
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):