Download - Classes and Objects: The Building Blocks of the Object-Oriented Paradigm Presented by Tara Struble
![Page 1: Classes and Objects: The Building Blocks of the Object-Oriented Paradigm Presented by Tara Struble](https://reader036.vdocuments.net/reader036/viewer/2022083009/5697bfbe1a28abf838ca2a16/html5/thumbnails/1.jpg)
Classes and Objects:Classes and Objects:The Building Blocks of the The Building Blocks of the Object-Oriented ParadigmObject-Oriented Paradigm
Presented by Tara StrublePresented by Tara Struble
![Page 2: Classes and Objects: The Building Blocks of the Object-Oriented Paradigm Presented by Tara Struble](https://reader036.vdocuments.net/reader036/viewer/2022083009/5697bfbe1a28abf838ca2a16/html5/thumbnails/2.jpg)
Introduction to Classes and Introduction to Classes and ObjectsObjects
All implementation details should be All implementation details should be hidden from users behind a hidden from users behind a consistent public interface.consistent public interface. Allows designer to change Allows designer to change
implementation whenever necessary.implementation whenever necessary. Greatly simplifies maintenance.Greatly simplifies maintenance.
![Page 3: Classes and Objects: The Building Blocks of the Object-Oriented Paradigm Presented by Tara Struble](https://reader036.vdocuments.net/reader036/viewer/2022083009/5697bfbe1a28abf838ca2a16/html5/thumbnails/3.jpg)
Messages and MethodsMessages and Methods
Message Message name of an object name of an object behavior.behavior.
Method Method implementation of a implementation of a message.message.
Protocol Protocol list of messages to which list of messages to which an an object can respond. object can respond.
![Page 4: Classes and Objects: The Building Blocks of the Object-Oriented Paradigm Presented by Tara Struble](https://reader036.vdocuments.net/reader036/viewer/2022083009/5697bfbe1a28abf838ca2a16/html5/thumbnails/4.jpg)
Users of a class must be dependent on Users of a class must be dependent on its public interface, but a class should its public interface, but a class should not be dependent on its users.not be dependent on its users.
Minimize the number of messages in Minimize the number of messages in the protocol of a class.the protocol of a class.
Implement a minimal public interface Implement a minimal public interface that all classes understand.that all classes understand. (operations such as copy, equality testing, (operations such as copy, equality testing,
printing, parsing from an ASCII description)printing, parsing from an ASCII description)
![Page 5: Classes and Objects: The Building Blocks of the Object-Oriented Paradigm Presented by Tara Struble](https://reader036.vdocuments.net/reader036/viewer/2022083009/5697bfbe1a28abf838ca2a16/html5/thumbnails/5.jpg)
Do not put implementation details Do not put implementation details such as common-code private such as common-code private functions into the public interface of functions into the public interface of a class.a class.
Do not clutter the public interface of Do not clutter the public interface of a class with items that users of that a class with items that users of that class are not able to use or are not class are not able to use or are not interested in using.interested in using.
![Page 6: Classes and Objects: The Building Blocks of the Object-Oriented Paradigm Presented by Tara Struble](https://reader036.vdocuments.net/reader036/viewer/2022083009/5697bfbe1a28abf838ca2a16/html5/thumbnails/6.jpg)
Class Coupling and Class Coupling and CohesionCohesion
The goal is tight cohesion within classes The goal is tight cohesion within classes and loose coupling between classes.and loose coupling between classes. Tight cohesion implies that the code Tight cohesion implies that the code
making up the function is closely related.making up the function is closely related. Loose coupling implies that when one Loose coupling implies that when one
function wishes to use another, it should function wishes to use another, it should enter and exit the function from one point.enter and exit the function from one point.
![Page 7: Classes and Objects: The Building Blocks of the Object-Oriented Paradigm Presented by Tara Struble](https://reader036.vdocuments.net/reader036/viewer/2022083009/5697bfbe1a28abf838ca2a16/html5/thumbnails/7.jpg)
Basic forms of couplingBasic forms of coupling
Nil couplingNil coupling two classes that have no two classes that have no dependency on each other.dependency on each other.
Export couplingExport coupling one class is dependent one class is dependent on the public interface of the other.on the public interface of the other.
Overt couplingOvert coupling one class uses the one class uses the implementation details of another class implementation details of another class with permission.with permission.
Covert couplingCovert coupling same as overt coupling, same as overt coupling, except that no permissions are granted.except that no permissions are granted.
![Page 8: Classes and Objects: The Building Blocks of the Object-Oriented Paradigm Presented by Tara Struble](https://reader036.vdocuments.net/reader036/viewer/2022083009/5697bfbe1a28abf838ca2a16/html5/thumbnails/8.jpg)
Classes should only exhibit nil or Classes should only exhibit nil or export coupling with other classes.export coupling with other classes.
A class should capture one and only A class should capture one and only one key abstraction.one key abstraction.
Keep related data and behavior in Keep related data and behavior in one place.one place.
Spin off non-related information into Spin off non-related information into another class.another class.
![Page 9: Classes and Objects: The Building Blocks of the Object-Oriented Paradigm Presented by Tara Struble](https://reader036.vdocuments.net/reader036/viewer/2022083009/5697bfbe1a28abf838ca2a16/html5/thumbnails/9.jpg)
Dynamic SemanticsDynamic Semantics
Collection of all possible states of a Collection of all possible states of a class’s objects, as well as the legal class’s objects, as well as the legal transitions between them.transitions between them.
Allows an object to respond Allows an object to respond differently to the same message sent differently to the same message sent at different times.at different times.
![Page 10: Classes and Objects: The Building Blocks of the Object-Oriented Paradigm Presented by Tara Struble](https://reader036.vdocuments.net/reader036/viewer/2022083009/5697bfbe1a28abf838ca2a16/html5/thumbnails/10.jpg)
Abstract ClassesAbstract Classes
Do not know how to instantiate Do not know how to instantiate objects.objects.
Used primarily for inheritance Used primarily for inheritance hierarchies.hierarchies.
![Page 11: Classes and Objects: The Building Blocks of the Object-Oriented Paradigm Presented by Tara Struble](https://reader036.vdocuments.net/reader036/viewer/2022083009/5697bfbe1a28abf838ca2a16/html5/thumbnails/11.jpg)
Roles Versus ClassesRoles Versus Classes
Be sure the abstractions that you Be sure the abstractions that you model are classes and not simply the model are classes and not simply the roles objects play.roles objects play. The distinction is based on differing The distinction is based on differing
behavior.behavior.