Introduction, Modeling concepts, Class Modeling
 What is an Object?
An object is an entity (a thing or a concept) that can be manipulated by programming language, such as value, variable, function.  What is Object orientation? The software is organized into collection of discrete objects that incorporate (add up) both as a structure and behavior.  Explain the Characteristics of OO approach each with examples: OO approach includes 4 aspects: 1. Identity 2. Classification 3. Inheritance and 4. Polymorphism Identity: Data is quantized into, discrete, distinguishable entities called objects. Object has its own identity; two objects are different even if their attribute values (size, name) are same. Classification: The objects with the same data structure (attributes) and behavior (operation) are grouped into a class. Example: paragraph, Monitor A class is an abstraction that describes the properties important to the application and ignores the rest. Each object is an instance of the class. An object has its own value for each attribute but it shares the attribute names and operations with other instances of the class. Inheritance: The sharing of attributes and operations among classes based on a hierarchical relationship. A superclass has general information that the subclasses refine and elaborate. Example: Scrolling Window and Fixed Window are subclasses of window. One main advantage of OO technology. The ability to factor out common features of several classes into super classes can reduce repetition within designs and programs. Polymorphism: The same operation may behave differently for different classes. Example: Move operation. Operation: Is a procedure or transformation that an object performs or is subject to. Example: Right justify, display, and move.

Analysis: The analyst scrutinizes (study) and rigorously (strictly) restates the requirements from system conception by constructing models. Application model: A description of the parts of the application system itself that are visible to the user. The analysis model has two parts: 1. Since OO operator is polymorphic. Domain model 2. Information added in one stage of development need not be lost or translated for the next stage. 1.  It can serve as a medium for specification. rather than final representation in a programming language.  Explain OO Development Development refers to software life cycle:  Analysis  Design  Implementation OO development is the identification and organization of application concepts. developers. and make tentative resource allocations. Explain OO Methodology The process consists of building a model of an application and then adding details to it during design. The Methodology has the following stages. and customers express abstract concepts clearly communicate them to each other. Benefits  Used for helping specifiers. documentation and interfacing as well as programming. because problem statements are rarely complete to correct. The notation is used from analysis to design to implementation. Application model Domain model: A description of the real-world objects reflected within the system. OO concepts and notation used to express a design also to provide useful documentation. each for a different class or the object. System conception: software development begins with business analysts or users conceiving an application and formulating tentative requirements. The analyst must work with the requestor to understand the problem. not how it will be done. 3. The system designer must decide what performance characteristics to optimize choose a strategy of attacking the problem. The analysis model is concise. The analysis should not contain implementation decisions. analysis. . 2. precise abstraction of what the desired system must do. System design: The development team must plan a high level strategy-the system architecture-for solving the application problem.Method: An implementation of an operation by a specific class. it may have more than one method implementing it.

Explain the Three models Three kinds of models are used to describe a system from different viewpoints  Class model for the objects in the system and their relationships. Activity diagrams elaborate important processing steps. o It Contains class diagrams. Interaction model: o It describes how the objects in a system cooperate to achieve broader results. Sequence diagrams shows the objects that interact and the time sequence of their interactions. Class design: The class designer adds details to the analysis model in accordance with the system design strategy. or hardware. o Class diagrams are a graph whose nodes are the classes and whose arcs are relationships among classes. Use Case diagrams focuses on functionality of a system-that is what the system does for the users. During implementation. State model: o It describes the aspects of an object that change over time. The class designer should elaborate both domain and application objects using the OO concepts and notation. o It starts with use cases that are then elaborated with sequence and activity diagram.  State model for the life history of objects  Interaction model for the interactions among objects Class model: o It describes the static structure of the objects in a system and their relationships. it is important to follow good software engineering practice so that traceability to the design is apparent and so that the system remains flexible and extensible. o It specifies and implements control with state diagrams o State diagrams are a graph whose nodes are the states and whose arcs are transactions between states caused by events among classes. Implementation: Implementers translate the classes and relationships developed during class design into a particular programming language. although they exist on different conceptual planes. 5. . database. o It defines the context for software development.4.

metamodels. polymorphism. graphics. CAD systems. Each of these concepts can be used in isolation. databases. Emphasis on the essence of an Object Oo development places a greater emphasis on data structure and a lesser emphasis on procedure structure than functional decomposition methodologies. an Oo language. 1. they are particularly well supported. but together they complement each other synergistically.Explain OO Themes Themes are not unique to OO systems.Sharing OO techniques promote sharing at different levels. It is not unique to OO languages The ability to combine data structures and behavior in a single entity makes encapsulation cleaner and more powerful than prior languages 3. classification. The Emphasis on the essential properties of an object forces the developer to think more carefully and deeply about what an object is and does. Modern languages provide data abstraction. and inheritance characterize Oo languages. Oo models are used to document programs that are ill-structured and difficult to understand. Abstraction It focuses on essential aspects of an application while ignoring details. Oo development is similar to information modeling techniques used in database design. but also offers the prospect of reusing designs code on future projects. but inheritance and polymorphism add power. The sharing via inheritance is one of the main advantages of OO languages. 6. Synergy Identity. OO development not only lets you share information within the application. 2. Oo development adds the concept of class-dependent behavior. from the internal implementation details that are hidden from other objects. Use--> Preserves (Keeps) the freedom to make decisions as long as possible by avoiding premature commitments to details. user interfaces. Ability to abstract is the important skill required for OOdevelopment. control systems. and other applications. It separates the external aspects of an object that are accessible to other objects. . Encapsulation It is also known as information hiding. before deciding how to implement it. simulations. usefulness of OO development OO techniques are used for developing compilers. Combining Data and Behavior Maintenance is easier 4. Focusing: on what an object is and does. 5.

Models reduce complexity by separating out a small number of important things to deal with at a time. State model represents the temporal. behavioral.  Class model It describes the structure of objects in a system.their identity.Modeling as a design technique  What is an model? Model: It is an abstraction of something for the purpose of understanding it before building it. Modeling Designers build models for various purposes before constructing. incorporates the previous reasons. while state and interaction model elaborate the operations. etc.  For example: the class model attaches operations to classes..  Explain Abstraction Abstraction is a selective examination of certain aspects of a problem. . is to deal with systems that are too complex to understand directly. airplane scale models for wind tunnel tests. because a model omits non-essential details.  The different models are not completely independent.  Each model contains the references to entities in other models. their relationships to other objects. their attributes. and is not important. the ‘Interaction” aspects of a system.  The different models have limited and explicit interconnections. because the purpose determines what is.  Visualization  Reduction of complexity: The main reason for modeling. The three kinds of models separate a system into distinct views. Abstraction should always be for some purpose. It provides context for the state and interaction models. Example: Architectural models to show customers. “control” aspects of a system. required for a complete description. and their operations. structural. Interaction model represents the collaboration of individual objects. “data” aspects of a system. The goal of abstraction is to isolate those aspects that are important for some purpose and suppress those aspects which are unimportant. each capturing important aspects of the system.  Abstractions are incomplete and inaccurate. It is easier to manipulate than the original entity. The Three Models To model a system it is useful from three related but different viewpoints.. Class model represents the static. Models serve Several Purposes:  Testing a physical entity before building it  Communication with customers: Architects and product designers build models to show their customers.

Use cases diagrams. Class models provide an intuitive graphical representation system and are valuable for communicating with customers. Generalization lets classes share structure and behavior and associations relate the classes. Sequence diagrams: shows the objects that interact and the time sequence of their interactions. We should build a system around objects rather than functionality Because an Oo system is more closely corresponds to the real world and is more resilient with respect to change. Classes define attribute values carried by each object and the operations that each object performs or undergoes. Activity diagrams: show the flow of control among the processing steps of a computation.  Objects and class concepts  Define Objects . References between the state diagrams become interactions in the interaction model. State diagram refers to other models. without regard for what the operations do. or how they are implemented. The relationship between the objects and the attributes and operations for each class of objects.how individual objects collaborate to achieve the behavior of the system as a whole. Class diagrams express the class model.  State model It describes those aspects of objects concerned with time and the sequencing of operations It captures control. what they operate on. Use cases diagrams: documents themes for interaction between the system and outside actors. the aspect of a system that describes the sequences of operations that occur. Actions and events in a state diagram become operations on objects in the class model. activity diagrams document the interaction model. sequence diagrams. State diagrams express the state model. Each state diagram shows the state and the event sequences permitted in a system for one class of objects.  Interaction Model It describes interactions between objects.  Relationship Among the models  Class modeling It captures the static structure of a system by characterizing the objects in a system. Class model is important of three models.Goal of constructing a class model  Is to capture those concepts from the real world that are important to an application.

Simplex Company. Example: Two apples with the same color. and top windows are objects. Processno 7648. An object is a concept. Objects in a class have the same attributes and forms of a behavior. All objects have identity and are distinguishable. Objects appear as proper nouns or specific references in problem descriptions and discussions with users.  Explain Class Diagrams and Object diagrams Two kinds of models of structure are  Class diagrams  Object diagrams . Class describes a group of object with the same properties (attributes).The purpose class modeling is to describe objects Example: Joe Smith. OO programming languages can determine an object class at run time. Identity: means that objects are distinguished by their inherent existence and not by descriptive properties that they may have. a person can eat one at a time. Company.  Define Classes An object is an instance or occurrence of a class. Process and Windows are all classes. The choice of objects depends on judgment and the nature of the problem. Some objects have real world counter parts while others are conceptual entities are introduced for implementation and have no correspondence to physical reality. Objects in a class share a common purpose above and beyond the requirements of common attribute and behavior. or thing with identity that has meaning for an application. shape and texture are still appear individual apples. Classes often appear as common nouns and nounpharses in problem descriptions. abstraction. Class name and attribute name are stored one per class rather than one per instance. behavior (operation) kinds of relationships and semantics. Example: Person.

thereby describing possible objects. birth date and weight are attribute of person objects.  It is helpful for documenting test cases and discussing examples.  Attribute elaborate classes Person name: string birthdate: date Figure: Class with attributes JoeSmith:Person name= “joe smith” birthdate=21 October 1983 MarySharp:Person name= “Mary Sharp” birthdate=16 march 1950 Figure: Objects with values .  A class diagram corresponds to an infinite set of object diagrams.  Singular nouns are used for the names of classes.  They are concise.  Object is to class value is to attribute.  Each attribute has a value for each object.  Example country is an object whose name attribute has the value “Canada” (the string).  It is useful for abstract modeling and for designing actual programs.  Example: Name.  Different objects have the same or different value for a given attribute. JoeSmith:Person MarySharp:Person :Person Figure Object diagram  Explain Values and Attributes  A value is a piece of data. Person Figure class diagram Object diagrams:  It shows individual objects and their relationships.  An Attribute is a named property of a class that describes a value held by each object of the class.  Example birth date attribute has value “21 October 1983” for object Joe smith.  Attribute name is unique within a class.Class diagrams:  It provides a graphic notation for modeling classes and their relationship. easy to understand and work well in practice. The values are found by examining problem documentation.  Attribute should describe values not objects.  Attributes are less important and serve to elaborate classes and relationships.  Values lack identity.

 Is purely an implementation convenience and have no application meaning.  Example: Hire.  We need not and should not list them explicitly.  Behavior of the operation depends on the class of its target.  Example: class file has the operation print  An operation may have arguments in addition to its target object.  Oo languages automatically generate identifiers with which to reference objects. Fire and Pay dividend are operations on class company.  When an operation has method on several classes. Person name birthdate changeJob changeAddress File fileName sizeInBytes lastUpdate print GeometricObject color position move (delta : Vector) select (p : Point): Boolean rotate (in angle : float = 0.  Same operations may be apply to many different classes  Such operations are polymorphic.0) Figure: operations . Person personID: ID name: string birthdate: date homeTelephoneNumber: string Person name: string birthdate: date homeTelephoneNumber:string Wrong Correct  Explain Operations and Methods  An operation is a function or procedure that may be applied to or by objects in a class.  Each operation has a target object as an implicit argument.  All objects in a class shares same operation. it is important that the methods all have the same signature.  Method is an implementation of an operation for a class. Explain Identifiers  Are implicit in a class model.  Internal identifiers.

A link is an instance of association. but some links relate three or more objects. Most links relate two objects. Links and associations appear as verbs in problem statements Class diagram Person name John:Person name=“John” Mary:Person name=“Mary” GE:Company name=“GE” IBM:Company name=“IBM” OwnsStock * * Company name Object diagram Sue:Person name=“Sue” Alice:Person name=“Alice” Jeff:Person name=“Jeff” Figure: Many-to-Many association: An association describes a set of potential links in the same way that a class describes a set of potential objects. An association describes a set of potential links in the same way that a class describes a set of potential objects. A Link is a physical or conceptual connection among objects. An association is a description of a group of links with common structure and common semantics. Example: Joe smith works for simplex company. The Links of an association connect objects from the same classes. Notation for classes Class Name attributeName1:dataType1=defaultValue1 attributeName2:dataType2=defaultValue2 …… OperationName1(argumentList1):resultType1 OperationName2(argumentList2):resultType2 ……  Notation for an argument of an operation direction argument Name: type=default Value  Explain Link and Association concepts           Links and associations are the means for establishing relationships among objects and classes. . Example: A person works for a company.

Cardinality: is the count of elements that are actually in a collection. Parent 2 * Child Person child parent 0.1 console Window Association Vs Link A anAssociation * * B anA:A aLink aB:B Class diagram Multiple association to model multiple links Object diagram anA:A aLink anotherLink aB:B A anAssociation * * B * anotherAssociation* Class diagram  Object diagram Explain Association end names  It can give names to the association link  The use of associations end name : to name links b/w object of some class Person employee * employer Company 0.. Windows opened on screen follow on explicit order only top most window is visible on any part of screen Ordered collection of elements with duplicates not allowed . Explain Multiplicity and cardinality Multiplicity is a constraint on the size of collection. Bags and sequence Ordering: Association which follows some priority Eg.1 WorksFor employee employer Joe Doe Simplex Mary BrownSimplex Jean Smith United Widgets Association end names are necceaaary for associations between objects of the same class. Multiplicity is a constraint on the cardinality 0 or 1 multiplicity Workstation 1 0... Therefore.2 * Wrong model Correct model  Explain Ordering.

Screen {ordered} 1 VisibleOn * WIndow Bags and sequences Bag: collection of elements with duplicates allowed Sequence: ordered collection of elements with duplicate allowed eg.login  read read-write read-write John Doe Mary Brown John Doe Attributes may occur for 1-m and 1-1 associations Person boss birthDate 0. {ordered} and {sequence} is same only difference is sequence allows duplicates. An itinerary is a sequence of airports and the same airport can be visited more than once Sequence is ordered bag both allow duplicates.1 Company name address name Manages * worker performanceRating Proper use of association class ..1 address * WorksFor salary jobTitle 0.. Itinerary {sequence} * * Airport  Explain Association Class It is an association that is also a class Link of association can have attributes File * AccessibleBy accessPermission * User /etc/termcap /etc/termcap /usr/doe/.

Person * WorksFor salary jobTitle 0.1 Company name address Preferred form name birthDate address Person * WorksFor 0.. Ordinary class Association class Person name * OwnsStock quantity * Company name Person Ordinary class name 1 * Purchase quantity date cost * Company 1 name  Explained Qualified Associations An association in which an attribute called the qualifier disambiguates the objects for a many association end. Can only work for m-m and 1-m Bank accountNumber 1 0.1 Company name address Discouraged form name birthDate address salary jobTitle An association class participating in an association User * Authorization priority privileges startSession * Workstation homeDirectory Directory 1 * Association class Vs.1 Account Bank 1 * Account accountNumber Qualified Not qualified ... Job of qualifier to reduce the many association to one.

reuse of code. Explain Generalization and inheritance Generalization is the relationship between a class (the super class) and one or more variations of the class (sub class). operations and associations. Super class holds the common attributes.1 atm diameter = 8 m height = 9 m P101:DiaphragmPump name = “P101” manufacturer = “Simplex” weight = 100 kg cost = $5000 suctionPres = 1. Each subclass inherits features of super class Equipment name manufacturer weight cost {Note: The listing of equipment.  To enable. . Subclass adds specific attributes.} Pump suctionPressure dischargePressure flowRate HeatExchanger surfaceArea tubeDiameter tubeLength tubePressure shellPressure Tank volume pressure CentrifugalPump impellerDiameter numberOfBlades axisOfRotation DiaphragmPump diaphragmMaterial PlungerPump plungerLength plungerDiameter numberOfCylinders SphericalTank diameter PressurizedTank diameter height E302:HeatExchanger name = “E302” manufacturer = “Brown” weight = 5000 kg cost = $20000 surfaceArea = 300 m tubeDiameter = 2 cm tubeLength = 6 m tubePressure = 15 atm shellPressure = 1.  To structure the description of objects.1 atm dischargePres = 3.7 atm FloatingRoofTank diameter height T111:FloatingRoofTank name = “T111” manufacturer = “Simplex” weight = 10000 kg cost = $50000 volume = 400000 liter pressure = 1.3 atm flowRate = 300 l/hr diaphragmMatl = Teflon 2 Use of generalization  Support for polymorphism increases the flexibility of software. and tanks is incomplete. pumps.

.Figure 1 Diagram name * color centerPosition penThickness penType move select rotate display dimensionality ZeroDimensional OneDimensional orientation scale TwoDimensional orientation fillType scale fill Point Line endPoints Arc radius startAngle arcAngle display Spline controlPts display Polygon numOfSides vertices display Circle diameter display rotate display display  Explain Class Model of windowing system Window x1 y1 x2 y2 display undisplay raise lower ScrollingWindow xOffset yOffset scroll cx1 cy1 cx2 cy2 Canvas Panel itemName 1 addElement deleteElement 1 window 0..1 elements notifyEvent 1 Event action 1 Shape color lineWidth * * keyboardEvent PanelItem x y label Text Window string insert delete Scrolling Canvas Line x1 y1 x2 y2 draw Closed Shape fillColor fillPattern Button string depressed Choice Item 0.1 {subset} 1 TextItem maxLength currentString * currentChoice 1 Point x y vertices * {ordered} 1 Polygon draw Ellipse x y a b draw ChoiceEntry string value * choices .

maximumcredit Operations syntax by -> Simple association acustomer. (Traversal of the two associations results in a set. Amount -> sum( ) . CreditCardAccount .1 0.1 Transaction transactionDate explanation amount CashAdvance Interest Purchase Fee feeType Adjustment * 1 Merchant name Object constraint language : It is Used to answer question pertaining to a class model Attribute syntax acreditcardaccount. resulting in a set of transactions. rather then a bag.. because both associations are one-to-many. Statement. Transaction-> select (aStartDate <= transactionDate and transactionDate <= anEndDate).1 1 Institution accountNumber name address phoneNumber * * name accountHolder Customer Statement paymentDueDate financeCharge minimumPayment transactionNumber 1 0.mailingaddres  How many credit card account customer has  What transaction occurred in a time interval for a customer  What transactions occurred for a credit card account within a time interval ? aCreditCardAccount. Explain Navigation of class model Class model for managing credit card account MailingAddress address phoneNumber 1 * CreditCardAccount maximumCredit currentBalance statementDate 1 0.Transaction  select(aStartDate <= transactionDate and transactiondate <= anEndDate The expression traverses from a CreditCardAccount object to Statement and then to Transaction.Statement..mailingaddres Acreditcardaccount..) Then we use the OCL select operator (a collection operator) to find the transactions within the time interval bounded by aStartDate and anEndDate  What volume of transaction were handled by an institution in last year ? anInstitution.

(We choose to make the time interval more general than last year. we then traverse to Statement.  What customers patronized a merchant in the last year by any kind of credit card ? aMerchant . (Traversal across a generalization. Customer->asSet() The expression traverses from a Merchant object to Purchase.) The OCL select operator finds the transactions within the time interval bounded by aStartDate and anEndDate. from Purchase to transaction. and then to transaction. then to CreditCardAccount. resulting in our answer. CreditCardAccount-> size() Given a Customer object. we find the value of maximumCredit and compute the total with the OCLsum operator. given the set of MailingAddress objects. and not a bag.  How many credit card accounts does a customer currently have ? aCustomer . which returns the cardinality of the set. we find a set of CreditCardAccount object. CreditCardAccount . (This traversal yields a set. maximumCredit->sum () The expression traverses from a Customer object to MailingAddress.Mailingaddress. yielding a set of CreditCardAccount object. The association from MailingAddress to customer is many-to-many. (Traversal results in a set.) for the set of CreditCardAccount objects we apply the OCL size operator. is implicit in the OCL. for all accounts ? aCustomer. Then. Purchase-> Select (aStartDate <= transactionDate and TransactionDate <= anEndDate). then to MailingAddress.) for these transactions. Mailingaddress. because each creditCardAccount pertains to a single MailingAddress. because all three associations are one-to-many. For each CreditCardAccount. and finally to Customer. so traversal to Customer yields a bag. We find a set of MailingAddress object. Statement. and then to CreditCardAccount.  What is the total maximum credit for as customer. rather then a bag. The OCL select operator finds the transactions within the time interval bounded by aStartDate and anEndDate. Traversal of multiple association may yield a bag . The OCL asSet operator converts a bag of customers to a set of customers. CreditCardAccount.The expression traverses from an institution object to CreditCardAccount.) Then we find the amount for each transaction and compute the total with the OCL sum operator (a collection operator). then to Statement. MailingAddress.

Class diagram MailingAddress address :Address address=123 Main :Address * * Person name OwnsStock * * name Company John:Person name=“John” Mary:Person name=“Mary” Sue:Person name=“Sue” GE:Company name=“GE” Object diagram address=456 State :Address address=789 First :Address address=234 Olive .

Sign up to vote on this title
UsefulNot useful