Upload
irma-wilcox
View
227
Download
3
Tags:
Embed Size (px)
Citation preview
MODULE:VIIMODULE:VII
OBJECT ANALYSIS: OBJECT ANALYSIS: CLASSIFICATIONCLASSIFICATION
04/21/2304/21/23 11Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
Recap: ObjectsRecap: Objects
Objects are taken from the real world Objects are taken from the real world They are abstract entities They are abstract entities
encapsulating data AND associated behaviour encapsulating data AND associated behaviour Data is Data is “protected”“protected” within individual chunks . within individual chunks .Data Data
Hiding.Hiding. Objects communicate Objects communicate ((interfacesinterfaces and messages and messages)) ““Design by contract” Design by contract”
objects make up the services offered by the systemobjects make up the services offered by the system eg: departments in an organisationeg: departments in an organisation
Objects are grouped into classes Objects are grouped into classes Inherit from super class.Inherit from super class.
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
22
The Use Case Driven ApproachThe Use Case Driven Approach
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
33
Classifications TheoryClassifications Theory
The process of checking to see if an object The process of checking to see if an object belongs to a category or a class, is regarded as belongs to a category or a class, is regarded as a basic attribute of human nature. a basic attribute of human nature.
Booch ExplainsBooch Explains:: Intelligence classification is part of all good Intelligence classification is part of all good
science…Classification guides us in making science…Classification guides us in making decision about modularization.decision about modularization.
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
44
Classifications Theory…Classifications Theory… We may choose to place certain classes and objects We may choose to place certain classes and objects
together in the same module or in different modules, together in the same module or in different modules, depending upon the sameness we find among these depending upon the sameness we find among these declarations;declarations;
Coupling and cohesion are measures of this Coupling and cohesion are measures of this sameness.sameness.
Coupling also plays a role in allocating processes to Coupling also plays a role in allocating processes to procedures.procedures.
We place certain processes together in the same We place certain processes together in the same processor or different processors, depending upon processor or different processors, depending upon packaging, performance, or reliability concern.packaging, performance, or reliability concern.
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
55
Classifications Theory…Classifications Theory…
Classes are important mechanism for Classes are important mechanism for classifying objects. Eg: classifying objects. Eg: new car launched.new car launched.
The chief role of a class is to define the The chief role of a class is to define the attributes, methods and applicability of attributes, methods and applicability of instances.instances.
Classification is concerned Classification is concerned more with more with identifying the classidentifying the class of an object than the of an object than the individual objects within a system.—attributes.individual objects within a system.—attributes.
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
66
Finding ClassesFinding Classes Finding classes is not easy. Finding classes is not easy.
The more practice you have, the better you get The more practice you have, the better you get at identifying classes.at identifying classes.
Finding classes is an incremental and Finding classes is an incremental and iterative process.iterative process.
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
77
There is no such thing as the “right set of classes”There is no such thing as the “right set of classes”
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
88
Finding Classes…Finding Classes…
Unless you are starting with a lot of domain Unless you are starting with a lot of domain knowledge, you are probably missing more knowledge, you are probably missing more classes than you will eliminate.classes than you will eliminate.
Naming a class is also an important activityNaming a class is also an important activity
The class should describe a single object, so it The class should describe a single object, so it should be a singular noun or an adjective and a should be a singular noun or an adjective and a nounnoun
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
99
Finding Classes: User Finding Classes: User Involvement…Involvement…
Make an adequate commitment of time. Iterative-still Make an adequate commitment of time. Iterative-still complete within time.complete within time.
Have good warning of the time commitment that will be Have good warning of the time commitment that will be required of themrequired of them
Be high-caliber workers who know their field or profession Be high-caliber workers who know their field or profession thoroughlythoroughly
Be chosen from a variety of levelsBe chosen from a variety of levels
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
1010
Finding Classes…Finding Classes…
Jacobson’s 3 typesJacobson’s 3 types EntityEntity
Concrete—land,placeConcrete—land,place Conceptual—not tangibleConceptual—not tangible Event and StateEvent and State
InterfaceInterface ControlControl
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
1111
Guidelines For Identifying ClassesGuidelines For Identifying Classes
The followings are The followings are guidelinesguidelines for for selecting selecting classesclasses in your application:in your application:
Look for nouns and noun phrases in the problem Look for nouns and noun phrases in the problem statement statement
Some classes are implicit or taken from general Some classes are implicit or taken from general knowledge knowledge
Eg:-Eg:-HR management systemHR management system
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
1212
Approaches for Identifying Approaches for Identifying Classes…Classes…
1)1) Noun Phrase ApproachNoun Phrase Approach
2)2) Common Class Pattern ApproachCommon Class Pattern Approach
3)3) CRC(Classes, Relation, Collaboration) ApproachCRC(Classes, Relation, Collaboration) Approach
4)4) Use-Case Driven Approach--Use-Case Driven Approach--The unified approach The unified approach uses the use-case driven approach for identifying classes uses the use-case driven approach for identifying classes and understanding behaviour of objects.and understanding behaviour of objects.
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
1313
Noun Phrase ApproachNoun Phrase Approach
Using Noun Phrase method, you have to read Using Noun Phrase method, you have to read through the use cases or requirements.through the use cases or requirements.
One way of gathering requirements is through One way of gathering requirements is through interviews.interviews.
Change all plurals to singular and make a list, Change all plurals to singular and make a list, which can then be divided into three categorieswhich can then be divided into three categories
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
1414
Noun Phrase ApproachNoun Phrase Approach
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
1515
Noun Phrase Approach…Noun Phrase Approach…
Irrelevant classes are simply scraped off.Irrelevant classes are simply scraped off. You must be able to You must be able to formulate a statement of formulate a statement of
purposepurpose for each candidate class; if not, simply for each candidate class; if not, simply eliminate it.eliminate it.
Flexibility is a virtue.Flexibility is a virtue.
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
1616
Noun Phrase Approach…Noun Phrase Approach…
Adjective ClassesAdjective Classes Does the object represented by the noun behave Does the object represented by the noun behave
differently when the adjective is applied to it ?differently when the adjective is applied to it ?
If use of adjective signals that behaviour of class is If use of adjective signals that behaviour of class is different then make a new class.different then make a new class.
““CurrentCurrent Account Holder” Account Holder” ““Savings Savings Account holder”Account holder”
Attribute ClassesAttribute Classes Tentative objects used only as values should be defined Tentative objects used only as values should be defined
or restated as attributes and not as a class.or restated as attributes and not as a class.
Eg:- Eg:- Client status.Client status.04/21/2304/21/23 Module VII Object Module VII Object
Analysis:ClassificationAnalysis:Classification1717
Guidelines For Refining ClassesGuidelines For Refining Classes
Redundant ClassesRedundant Classes: : Do not keep two classes that express the same Do not keep two classes that express the same
information. information. If more than one word is being used to If more than one word is being used to
describe the same idea, select the one that is describe the same idea, select the one that is the most meaningful in the context of the the most meaningful in the context of the system.system.
Remember by Remember by FRIARFRIAR04/21/2304/21/23 Module VII Object Module VII Object
Analysis:ClassificationAnalysis:Classification1818
Common Class Patterns Approach…Common Class Patterns Approach…
Based on knowledge base of common classes that have been Based on knowledge base of common classes that have been proposed by various researchers.proposed by various researchers.
Events ClassEvents Class An order, landing etc.An order, landing etc.
Organisation ClassOrganisation Class Finance Department , HR Department.Finance Department , HR Department.
People Class—those representing user of system and about People Class—those representing user of system and about whom info is kept in the system.whom info is kept in the system. Eg-HR manager of a company is user of the employee Eg-HR manager of a company is user of the employee
management system and being an employee is also a part management system and being an employee is also a part of the employee management system.of the employee management system.
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
1919
Common Class Patterns ApproachCommon Class Patterns Approach
Places-physical locations that system must keep info abt.Places-physical locations that system must keep info abt. Offices, buildingsOffices, buildings
Tangible things and devices with which application Tangible things and devices with which application interactsinteracts Cars-tangible things, pressure sensors-devices.Cars-tangible things, pressure sensors-devices.
ConceptsConcepts It is Principles or Ideas, for example It is Principles or Ideas, for example Performance Performance can can
be a concept class.be a concept class.
Remember by Remember by COPPETCOPPET04/21/2304/21/23 Module VII Object Module VII Object
Analysis:ClassificationAnalysis:Classification2020
CRC approachCRC approach
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
2121
Identify classes’ responsibilities(attributes and methods) and related classes that interact together
Continued…Continued…
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
2222
Finding StructuresFinding Structures
Subclass HierarchiesSubclass Hierarchies
AggregationsAggregations Component-AssemblyComponent-Assembly Container-ContentsContainer-Contents Collection-MemberCollection-Member
AssociationAssociation
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
2323
Superclass-Subclass RelationshSuperclass-Subclass Relationsh
Top-down approachTop-down approach
Bottom-up approachBottom-up approach
Reusability approachReusability approach (more details later at OOD)(more details later at OOD)
Multiple inheritance approachMultiple inheritance approach
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
2424
AggregationAggregation
A relationship between two classes where the A relationship between two classes where the instances of one class are in some way instances of one class are in some way components, members, or contentscomponents, members, or contents of the of the instances of the other classinstances of the other class
Appear on the class diagram along with all the Appear on the class diagram along with all the subclass hierarchies and the regular subclass hierarchies and the regular associationsassociations
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
2525
AggregationAggregation
33 relationships that sometimes occur in an relationships that sometimes occur in an object modelobject model Whole-Part or Component-AssemblyWhole-Part or Component-Assembly Container-ContentsContainer-Contents Collection-MemberCollection-Member
Improve communication and understandingImprove communication and understanding
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
2626
Component-AssemblyComponent-Assembly
Constructed from its parts and an assemblyConstructed from its parts and an assembly--ppart situation physically exists art situation physically exists A product and it’s componentsA product and it’s components French soup consists of onion, butter, flour, wine, French soup consists of onion, butter, flour, wine,
French bread, cheddar cheese, etc.French bread, cheddar cheese, etc.
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
2727
ContainerContainer
A physical whole encompassesA physical whole encompasses but is not but is not constructed from physical partsconstructed from physical parts A house can be considered a container for A house can be considered a container for
furniture and appliancesfurniture and appliances
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
2828
Collection-MemberCollection-Member
A conceptual whole encompasses parts that A conceptual whole encompasses parts that may be physical or conceptualmay be physical or conceptual Teachers are assigned to specific coursesTeachers are assigned to specific courses A football team is a collection of playersA football team is a collection of players
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
2929
Aggregation – 2 extra features Aggregation – 2 extra features
TransitivityTransitivity
If If AA is part of is part of BB and B is part of and B is part of CC, then , then AA is part of is part of CC
For example, a timing belt is part of an engine and For example, a timing belt is part of an engine and an engine is part of a car; therefore, a timing belt is an engine is part of a car; therefore, a timing belt is part of a carpart of a car
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
3030
Aggregation – 2 extra features... Aggregation – 2 extra features...
AntisymmetryAntisymmetry
If If AA is part of is part of BB, then , then BB is not part of is not part of AA
For example, an engine is part of a car, but a car is For example, an engine is part of a car, but a car is not part of an enginenot part of an engine
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
3131
A filled diamond signifies the A filled diamond signifies the strongstrong form of form of aggregation, aggregation, e.g. e.g. assembly-componentassembly-component
““WeakWeak”” forms of aggregation might be forms of aggregation might be represented using a hollow diamond , e.grepresented using a hollow diamond , e.g. . Container and Collection Container and Collection
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
3232
AssociationsAssociations
LocationLocation:: next To, part of, contained in, ingredient ofnext To, part of, contained in, ingredient of etc. etc. cheese is an cheese is an ingredient ofingredient of French soup French soup
CommunicationCommunication:: to, order toto, order to…… a customer places an order with an operatora customer places an order with an operator
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
3333
Associations...Associations...
ImplementationImplementation: : Defer implementation-specific associations to the Defer implementation-specific associations to the design phase design phase
TernaryTernary:: TernaryTernary or or n-aryn-ary associationassociation is an association among is an association among more than two classesmore than two classes
Directed actionsDirected actions (derived): (derived): can be defined in terms of other associationscan be defined in terms of other associations avoid these types of association - redundantavoid these types of association - redundant
04/21/2304/21/23 Module VII Object Module VII Object Analysis:ClassificationAnalysis:Classification
3434
ViaNet Bank ATM SystemViaNet Bank ATM System
The The bank client bank client must be able to must be able to deposit an amount deposit an amount to and to and withdrawwithdraw an amount from his/her account using the touch an amount from his/her account using the touch screen at the ViaNet Bank ATM screen at the ViaNet Bank ATM kioskkiosk. .
Each transaction must be recorded, and the Each transaction must be recorded, and the clientclient must be able must be able to to review all transactions review all transactions performed against a given account. performed against a given account.
Recorded transactions must include the date, time, transaction Recorded transactions must include the date, time, transaction type, amount, and account balance after the transaction.type, amount, and account balance after the transaction.
No receipts will be provided for any account transactions.No receipts will be provided for any account transactions.04/21/2304/21/23 MODULE-IV OO MethodologiesMODULE-IV OO Methodologies 3535
ViaNet Bank ATM System...ViaNet Bank ATM System... The bank application operates for a single banking institution The bank application operates for a single banking institution
only. only. For each checking account, one related savings account can For each checking account, one related savings account can
exist. exist. A checking account differs from other bank accounts in A checking account differs from other bank accounts in that it often allows for numerous withdrawals and unlimited that it often allows for numerous withdrawals and unlimited deposits, whereas savings accounts sometimes limit both. deposits, whereas savings accounts sometimes limit both.
Access to the ViaNet accounts is provided by a PIN code Access to the ViaNet accounts is provided by a PIN code consisting of 4 integer digits between 0 and 9. consisting of 4 integer digits between 0 and 9.
One PIN code allows access to all accounts held by a bank One PIN code allows access to all accounts held by a bank
client.client.
04/21/2304/21/23 MODULE-IV OO MethodologiesMODULE-IV OO Methodologies 3636
ViaNet Bank ATM System...ViaNet Bank ATM System...
Neither a checking nor a savings account can have a Neither a checking nor a savings account can have a negative balance. negative balance.
The system should automatically withdraw money The system should automatically withdraw money from a related savings account if the requested from a related savings account if the requested withdrawal amount on the checking account is more withdrawal amount on the checking account is more than the current balance. than the current balance.
If the balance on a savings account is less than the If the balance on a savings account is less than the withdrawal amount requested, the transaction will withdrawal amount requested, the transaction will stop and the bank client will be notified.stop and the bank client will be notified.
04/21/2304/21/23 MODULE-IV OO MethodologiesMODULE-IV OO Methodologies 3737
The Noun Phase ApproachThe Noun Phase Approach Account, Account Balance, Amount, Approval Account, Account Balance, Amount, Approval
process, ATM Card, ATM Machine, Bank, process, ATM Card, ATM Machine, Bank, Bank Client, Card, Cash, Check, Checking, Bank Client, Card, Cash, Check, Checking, Checking Account, Client, Envelope, Checking Account, Client, Envelope,Client’s Account, Currency, Dollar, Client’s Account, Currency, Dollar, (Four) Digits, Fund, (Invalid) PIN, Message, (Four) Digits, Fund, (Invalid) PIN, Message, Money, Password, PIN, PIN Code, Record, Money, Password, PIN, PIN Code, Record, Savings, Savings Account, Step, System, Savings, Savings Account, Step, System, Transaction, Transaction HistoryTransaction, Transaction History
04/21/2304/21/23 MODULE-IV OO MethodologiesMODULE-IV OO Methodologies 3838
The Noun Phase Approach…The Noun Phase Approach… Irrelevant ClassesIrrelevant Classes
Envelope, Four Digits, StepEnvelope, Four Digits, Step Redundant ClassesRedundant Classes
Client, Bank Client = BankClientClient, Bank Client = BankClient Account, Client’s Account = AccountAccount, Client’s Account = Account PIN, PIN Code = PINPIN, PIN Code = PIN Checking, Checking Account = CheckingAccountChecking, Checking Account = CheckingAccount Savings, Savings Account = SavingsAccountSavings, Savings Account = SavingsAccount Fund, Money = FundFund, Money = Fund ATM Card, Card = ATM CardATM Card, Card = ATM Card
04/21/2304/21/23 MODULE-IV OO MethodologiesMODULE-IV OO Methodologies 3939
The Noun Phase Approach…The Noun Phase Approach…
Adjective ClassesAdjective Classes Not applicableNot applicable
Attribute ClassesAttribute Classes AmountAmount Account BalanceAccount Balance Invalid PINInvalid PIN PasswordPassword Transaction HistoryTransaction History PINPIN
04/21/2304/21/23 MODULE-IV OO MethodologiesMODULE-IV OO Methodologies 4040
The Noun Phase Approach…The Noun Phase Approach… Statement of purposeStatement of purpose
ATM Machine: an interface to the ViaNet BankATM Machine: an interface to the ViaNet Bank ATM Card: a key to an accountATM Card: a key to an account BankClient: an individual with a checkings BankClient: an individual with a checkings
account and possibly a savings account.account and possibly a savings account. Bank: clients belong to the bankBank: clients belong to the bank Account: defines behaviours of account typesAccount: defines behaviours of account types CheckingAccount: withdrawal serviceCheckingAccount: withdrawal service SavingsAccount: models a client’s savingsSavingsAccount: models a client’s savings Transaction: keeps track of transaction dataTransaction: keeps track of transaction data
04/21/2304/21/23 MODULE-IV OO MethodologiesMODULE-IV OO Methodologies 4141
Common Class PatternsCommon Class Patterns
PeoplePeople Bank Client Bank Client
PlacesPlaces Nothing applicable here.(Lets consider For eg: Nothing applicable here.(Lets consider For eg:
Bank Branch) Bank Branch) Tangible things and DevicesTangible things and Devices
ATM MachineATM Machine
04/21/2304/21/23 MODULE-IV OO MethodologiesMODULE-IV OO Methodologies 4242
Common Class Patterns...Common Class Patterns...
EventsEvents Account class, CheckingAccount(models a client’s Account class, CheckingAccount(models a client’s
checking account and provides more specialized checking account and provides more specialized withdrawal service), SavingsAccount, Transactionwithdrawal service), SavingsAccount, Transaction
Organisation Classes: Bank classOrganisation Classes: Bank class
Concept Classes: N/AConcept Classes: N/A
04/21/2304/21/23 MODULE-IV OO MethodologiesMODULE-IV OO Methodologies 4343
04/21/2304/21/23 MODULE-IV OO MethodologiesMODULE-IV OO Methodologies 4444
Use Case Driven Approach: Identifying Classes Use Case Driven Approach: Identifying Classes And Behavior Through Sequence/Collaboration And Behavior Through Sequence/Collaboration
ModelingModeling Develop sequence diagram classes becomes Develop sequence diagram classes becomes
clear.clear. The process of creating sequence or The process of creating sequence or
collaboration diagrams is a systematic way to collaboration diagrams is a systematic way to think about how a use case (scenario) can take think about how a use case (scenario) can take place; and place; and
By doing so, it forces you to think about By doing so, it forces you to think about objects involved in your application.objects involved in your application.
04/21/2304/21/23 MODULE-IV OO MethodologiesMODULE-IV OO Methodologies 4545
04/21/2304/21/23 MODULE-IV OO MethodologiesMODULE-IV OO Methodologies 4646
Guidelines for Naming ClassesGuidelines for Naming Classes The class name should be The class name should be singularsingular. Eg: . Eg:
YouthMember.YouthMember. Use Use namesnames with which the users or with which the users or clients are clients are
comfortable.comfortable. Eg WithdrawCash Eg WithdrawCash Choose the class name from Choose the class name from standard standard
vocabulary vocabulary for the subject matter.for the subject matter. The name of a class should reflect its intrinsic The name of a class should reflect its intrinsic
nature.nature. Use readable names with capitalize words. Ex: Use readable names with capitalize words. Ex:
LoanWindowLoanWindow04/21/2304/21/23 MODULE-IV OO MethodologiesMODULE-IV OO Methodologies 4747
CRCCRC
CRCCRC cards: cards: CClasses, lasses, RResponsibilities And esponsibilities And CCollaboratorsollaborators
Developed by Cunningham, Wilkerson and Developed by Cunningham, Wilkerson and Beck.Beck.
CRC is a technique for CRC is a technique for identifying classesidentifying classes’ ’ responsibilities therefore their attributes and responsibilities therefore their attributes and methods.methods.
CRC helps in identifying classes.CRC helps in identifying classes.
04/21/2304/21/23 MODULE-IV OO MethodologiesMODULE-IV OO Methodologies 4848
CRC…CRC…
CRC cards are 4” x 6” index cards consisting CRC cards are 4” x 6” index cards consisting of :of : The class nameThe class name Its Super and Sub classes (if applicable)Its Super and Sub classes (if applicable) The responsibilities of the class.The responsibilities of the class. The names of other classes with which the class The names of other classes with which the class
will collaborate to fulfill its responsibilities.will collaborate to fulfill its responsibilities. AuthorAuthor
04/21/2304/21/23 MODULE-IV OO MethodologiesMODULE-IV OO Methodologies 4949
CRC LayoutCRC Layout
04/21/2304/21/23 MODULE-IV OO MethodologiesMODULE-IV OO Methodologies 5050
CRC Card Example CRC Card Example
04/21/2304/21/23 MODULE-IV OO MethodologiesMODULE-IV OO Methodologies 5151
END of Chapter-7END of Chapter-7
04/21/2304/21/23 MODULE-IV OO MethodologiesMODULE-IV OO Methodologies 5252