Full Transcript

OOAD Unit-1 Object-Oriented Analysis Object–Oriented Analysis (OOA) is the procedure of identifying software engineering requirements and developing software specifications in terms of a software system’sobject...

OOAD Unit-1 Object-Oriented Analysis Object–Oriented Analysis (OOA) is the procedure of identifying software engineering requirements and developing software specifications in terms of a software system’sobject model, which comprises of interacting objects. The main difference between object-oriented analysis and other forms of analysis is that in object-oriented approach, requirements are organized around objects, which integrate both data and functions. They are modelled after real-world objects that the system interacts with. In traditional analysis methodologies, the two aspects - functions and data - are considered separately. Grady Booch has defined OOA as, “Object-oriented analysis is a method of analysis that examines requirements from the perspective of the classes and objects found in the vocabulary of the problem domain”. The primary tasks in object-oriented analysis (OOA) are: Identifying objects Organizing the objects by creating object model diagram Defining the internals of the objects, or object attributes Defining the behavior of the objects, i.e., object actions Describing how the objects interact The common models used in OOA are use cases and object models. Object-Oriented Design: Object–Oriented Design (OOD) involves implementation of the conceptual model produced during object-oriented analysis. In OOD, concepts in the analysis model, which are technology−independent, are mapped onto implementing classes, constraints are identified and interfaces are designed, resulting in a model for the solution domain, i.e., a detailed description of how the system is to be built on concrete technologies. The implementation details generally include: Restructuring the class data (if necessary), Implementation of methods, i.e., internal data structures and algorithms, Implementation of control, and Implementation of associations. Object-Oriented Programming: Object-oriented programming (OOP) is a programming paradigm based upon objects (having both data and methods) that aims to incorporate the advantages of modularity and reusability. Objects, which are usually instances of classes, are used to interact with one another to design applications and computer programs. The important features of object–oriented programming are: Bottom–up approach in program design Programs organized around objects, grouped in classes Focus on data with methods to operate upon object’s data Interaction between objects through functions Reusability of design through creation of new classes by adding features to existing classes Some examples of object-oriented programming languages are C++, Java, Smalltalk, Delphi, C#, Perl, Python, Ruby, and PHP. Objects and Classes: The concepts of objects and classes are intrinsically linked with each other and form the foundation of object–oriented paradigm. Object An object is a real-world element in an object–oriented environment that may have a physical or a conceptual existence. Each object has: Identity that distinguishes it from other objects in the system. State that determines the characteristic properties of an object as well as the values of the properties that the object holds. Behavior that represents externally visible activities performed by an object in terms of changes in its state. Objects can be modelled according to the needs of the application. An object may have a physical existence, like a customer, a car, etc.; or an intangible conceptual existence, like a project, a process, etc. Class A class represents a collection of objects having same characteristic properties that exhibit common behavior. It gives the blueprint or description of the objects that can be created from it. Creation of an object as a member of a class is called instantiation. Thus, object is an instance of a class. The constituents of a class are: A set of attributes for the objects that are to be instantiated from the class. Generally, different objects of a class have some difference in the values of the attributes. Attributes are often referred as class data. A set of operations that portray the behavior of the objects of the class. Operations are also referred as functions or methods. Example Let us consider a simple class, Circle, that represents the geometrical figure circle in a two– dimensional space. The attributes of this class can be identified as follows: x–coord, to denote x–coordinate of the center y–coord, to denote y–coordinate of the center a, to denote the radius of the circle Inheritance: Inheritance is the mechanism that permits new classes to be created out of existing classes by extending and refining its capabilities. The existing classes are called the base classes/parent classes/super-classes, and the new classes are called the derived classes/child classes/subclasses. The subclass can inherit or derive the attributes and methods of the super-class(es) provided that the super-class allows so. Besides, the subclass may add its own attributes and methods and may modify any of the super-class methods. Inheritance defines an “is – a” relationship. Example From a class Mammal, a number of classes can be derived such as Human, Cat, Dog, Cow, etc. Humans, cats, dogs, and cows all have the distinct characteristics of mammals. In addition, each has its own particular characteristics. It can be said that a cow “is – a” mammal. Types of Inheritance Single Inheritance : A subclass derives from a single super-class. Multiple Inheritance : A subclass derives from more than one super-classes. Multilevel Inheritance : A subclass derives from a super-class which in turn is derived from another class and so on. Hierarchical Inheritance : A class has a number of subclasses each of which may have subsequent subclasses, continuing for a number of levels, so as to form a tree structure. Hybrid Inheritance : A combination of multiple and multilevel inheritance so as to form a lattice structure. Generalization and Specialization: Generalization and specialization represent a hierarchy of relationships between classes, where subclasses inherit from super-classes. Generalization In the generalization process, the common characteristics of classes are combined to form a class in a higher level of hierarchy, i.e., subclasses are combined to form generalized super- class. It represents an “is – a – kind – of” relationship. For example, “car is a kind of land vehicle”, or “ship is a kind of water vehicle”. Specialization Specialization is the reverse process of generalization. Here, the distinguishing features of groups of objects are used to form specialized classes from existing classes. It can be said that the subclasses are the specialized versions of the super-class. The following figure shows an example of generalization and specialization. Links and Association: Link A link represents a connection through which an object collaborates with other objects. Rumbaugh has defined it as “a physical or conceptual connection between objects”. Through a link, one object may invoke the methods or navigate through another object. A link depicts the relationship between two or more objects. Association Association is a group of links having common structure and common behavior. Association depicts the relationship between objects of one or more classes. A link can be defined as an instance of an association. Degree of an Association Degree of an association denotes the number of classes involved in a connection. Degree may be unary, binary, or ternary. A unary relationship connects objects of the same class. A binary relationship connects objects of two classes. A ternary relationship connects objects of three or more classes. Aggregation or Composition: Aggregation or composition is a relationship among classes by which a class can be made up of any combination of objects of other classes. It allows objects to be placed directly within the body of other classes. Aggregation is referred as a “part–of” or “has– a” relationship, with the ability to navigate from the whole to its parts. An aggregate object is an object that is composed of one or more other objects. Example In the relationship, “a car has–a motor”, car is the whole object or the aggregate, and the motor is a “part–of” the car. Aggregation may denote: Physical containment : Example, a computer is composed of monitor, CPU, mouse, keyboard, and so on. Conceptual containment : Example, shareholder has–a share. Abstraction Abstraction means to focus on the essential features of an element or object in OOP, ignoring its extraneous or accidental properties. The essential features are relative to the context in which the object is being used. Grady Booch has defined abstraction as follows − “An abstraction denotes the essential characteristics of an object that distinguish it from all other kinds of objects and thus provide crisply defined conceptual boundaries, relative to the perspective of the viewer.” Example − When a class Student is designed, the attributes enrolment_number, name, course, and address are included while characteristics like pulse_rate and size_of_shoe are eliminated, since they are irrelevant in the perspective of the educational institution. The three models: There are three types of models in object oriented languages. 1. Object model 2. Dynamic model 3. Functional model Object model The object model identifies the classes in the system and their relationship, as well as their attributes and operations. It represents the static structure of the system. The object model is represented graphically by a class diagram. Step for object modeling Following steps are performed in constructing an object model. 1. Read carefully, the problem statement. 2. Locate the object classes by underlining nouns. 3. Remove unnecessary and incorrect classes. 4. Prepare a data dictionary. 5. Locate associations between object classes. 6. Remove unnecessary and incorrect attributes. 7. Use inheritance to share common structure. 8. Traverse access paths to identify deficiency. 9. Remove unnecessary and incorrect associations. 10. Locate attributes of the object classes. Dynamic model The dynamic model indicates the dynamics of the objects and their changes in state. The dynamic model captures the functional behavior of the system by exploring the behavior of the objects over time and the flow of control and events among the objects. Steps for dynamic modeling Following steps are performed in constructing dynamic model. 1. Locate use cases and prepare scenarios of typical interaction sequence. 2. Locate events between objects and prepare an event trace diagram for each scenario. 3. Develop an event flow diagram for the system. 4. Develop state diagrams for classes with important dynamic behavior. 5. Check for consistency and completeness of events shared among the state diagrams. Functional model The functional model is a data flow diagram of the system and describes what the system does, not how it is done. A DFD is a network representation of the system to show the functional relationships of the values that are computed by a system. Data flow diagrams consist of processes , data flows , actors and data stores. 1. A process transforms input data values in to output data values. A process is presented as an ellipse, with the name of the process inside the ellipse. 2. A data flow shows the flow of data through a network of processes. 3. An actor, drawn as a rectangle, is an object. 4. A data store is a respository for the temporary storing of data. A data store is represented as a pair of parallel lines containing the name of a data store. Data stores may also be objects. Steps for functional model Following steps are performed in constructing a functional model. 1. Identify input and output values. 2. Use data flow diagrams as needed to show functional dependencies. 3. Describe what each function does. 4. Identify constraints. 5. Specify optimization criteria. Relationship among models The three models – object model , dynamic model and functional model are closely related to one another. To implement a system, all the three models are required to be modeled. After integration of these models , a complete view of the system can be achieved. The working of all three models explains how they are interrelated which is as follows: 1. Each model describes an aspect of the system but contains references to the other models. 2. The object model describes the data structure on which the dynamic and functional models operate on. 3. The operations in the object model correspond to events in the dynamic model and functions in the functional model. 4. The dynamic model describes the controlling structure of objects. It shows decisions which depend on object values and which cause actions that change object values and invoke functions. 5. The functional model describes functions invoked by operations in the object model and actions in the dynamic model. 6. Functions operate on data values specified by the object model. The functional model also shows constraints on object values. Class Model: The class model shows all the classes present in the system. The class model shows the attributes and the behavior associated with the objects. The class diagram is used to show the class model.The class diagram shows the class name followed by the attributes followed by the functions or the methods that are associated with the object of the class.Goal in constructing class model is to capture those concepts from the real world that are important to an application.

Use Quizgecko on...
Browser
Browser