1 / 38

Object-Oriented Software Development

Object-Oriented Software Development. Software Development Process Analyze Relationships Among Objects Class Development Class Design Guidelines. Software Development Process. The waterfall model. Software Development Process.

kmeek
Download Presentation

Object-Oriented Software Development

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Object-Oriented Software Development • Software Development Process • Analyze Relationships Among Objects • Class Development • Class Design Guidelines

  2. Software Development Process The waterfall model

  3. Software Development Process 1. Requirements Specification: Understand the problem and document in details what it needs to do. This phase involves close interaction between users and designers. 2. System Analysis: Analyze the business process in terms of data flow, and to identify the system’s input and output. Part of the analysis entails modeling the system behavior. The model is intended to capture the essential elements of the system and to define services to the system.

  4. Software Development Process 3. System Design: Design the system components. This phase involves the use of many levels of abstraction to decompose the problem into manageable components, identify classes and interfaces, and establish relationships among the classes and interfaces.

  5. Software Development Process 4. Implementation: Translate the system design into programs. Separate programs are written for each component, and they are put to work together. This phase requires the use of an OOP language like Java. The implementation involves coding, testing and debugging.

  6. Software Development Process 4. Implementation: Translate the system design into programs. Separate programs are written for each component, and they are put to work together. This phase requires the use of an OOP language like Java. The implementation involves coding, testing and debugging.

  7. Software Development Process 5. Testing: Ensure that the code meets the requirements specification and weeds out bugs. An independent team of software engineers not involved in design and implementation of the project usually conducts such testing. 6. Deployment: Make the project available for use. 7. Maintenance: Change and improve the product. Periodically upgrade the product to fix newly discovered bugs and incorporate changes.

  8. Relationships among Classes • OOP is centered on objects. • The first step: Identify the objects and establish relationships among them. • The relationships can be classified into three types: 1. Association: has-a relationship 2. Aggregation 3. Inheritance: is-a relationship

  9. Association • Association represents a general binary relationship that describes an activity between two classes. • A student taking a course is an association between the Student class and the Course class. • A faculty member teaching a course is an association between the Faculty class and the Course class.

  10. Association: UML • An association is is illustrated using a solid line between the two classes with an optional label that describes the relationship (see labels Take and Teach). • Each relationship may have an optional small black triangle that indicates the direction of the relationship. • Each class involved in the relationship may have a role name played by the class in the relationship.

  11. Association: UML • Each class involved in the association may specify a multiplicity. A multiplicity could be a number or an interval that specifies how many objects of the class are involved in the relationship. • The caharacter * means unlimited number of objects, and an interval 1..u means the number of objects should be between 1 and u.

  12. Association • Association may exist between objects of the same class. • For example, a person may have supervisor. 1 Person 1 Supervise

  13. Association, cont. An association is usually represented as a data field in the class. public class Course { private Faculty faculty;   /**Constructors*/   /**Methods*/ } public class Person { private Person supervisor;   /**Constructors*/   /**Methods*/ }

  14. Has-a relation • has-a, part-of, or owns. • Has-a relationship holds when one object has another object as component: object has a (stores) reference to another object. It may use another object to store its state or do its work.

  15. Aggregation • Aggregation is a special form of association, which represents an ownership relationship between two classes. • Aggregation models the relationship like has-a, part-of, owns, and employed-by. • An object may be owned by several other aggregated objects. An example of aggregation

  16. Composition • Composition is a stronger form of aggregation. • In a composite object the components exists only as part of the composite. • Rules of thumb: 1) The whole and parts have coincident lifetimes. 2) Both classes represent physical items. • Examples: An engine is a part a car; a package is a part of a shipment; employee is a part of a team. Composition Aggregation

  17. Composition: UML Notation

  18. 3. Inheritance • Inheritance models the is-a relationship between two classes. • A strongis-a relation describes a direct inheritance relationship between two classes. Class Student inherits from the Person class. • A weekis-a relation describes that a class has certain properties. A week is-a relationship can be represented using interfaces.

  19. 2. Inheritance public class Student extend Person { /**Constructors*/   /**Methods*/ } public class Faculty extend Person { /**Constructors*/ /**Methods*/ }

  20. Is-a relation • Is-a relationship holds when class is a subtype of another class It may use another object to store its state or do its work. • All the properties: data and member functions unless overriden, are inherited from a base class. • Constructor for subclass will call the constructor for base class prior to any other actions. • Examples: Class Dog is inherited from a class Animal. Class Circle is inherited from abstract class Shape.

  21. Major Inheritance Types 1. Inheritance for Extension 2. Inheritance for Specialization 3. Inheritance for Specification 4. Inheritance for Limitations 5. Inheritance for Construction 6. Inheritance for Combination

  22. 1. Inheritance for Extension • The subclass adds new functionality to the base class. • It does not change any inherited behavior • The first most common form of inheritance Example:Animal  (Dog, Cat)

  23. 2. Inheritance for Specialization • The subclass is a special case of the super class. • Specialized class redefines some of the methods of the superclass by overriden them. • Specialization is useful a class … with a more special behavior than superclass … that is a variation of the superclass …with more efficient implementation Example:MyApplet  Applet

  24. 3. Inheritance for Specification • The second most use of inheritance • The superclass defines behavior that is implemented in the subclass • All classes maintain a certain specification, which is a common interface (classes basically implements the same methods) Example:Delivery Company  (Air-Delivery Company, Ground-Delivery Company, Courier Company) Method deliver

  25. 4. Inheritance for Limitation The child class restricts the use of some of the behavior inherited from a parent class. Should be avoided Example:

  26. 5. Inheritance for Construction • A class can often inherit almost all of its functionality from a parent class, perhaps changing only the names of the methods used to interface to the class, or modifying the arguments. Example: The class Stack is constructed using inheritance from the class Vector. pop(), push()

  27. 6. Inheritance for Combination • It is common to form a new abstraction by combining features of two or more abstractions. • A new class extends an existing class and implements an interface. Example: A teaching assistant may have characteristics of both teacher and a student.

  28. Class Development 1. Identify classes for the system. 2. Describe attributes and methods in each class. 3. Establish relationships among classes. 4. Create classes.

  29. Example 9.1 Borrowing Mortgages Name Mortgage Person Borrower Address

  30. Example 9.1 Borrowing Mortgages (W/o getters and setters!)

  31. Example: Account

  32. UML: Classes

  33. UML: The Rational Class

  34. UML: Package

  35. Class Design Guidelines • Hide private data and private methods. • A property that is shared by all the instances of the class should be declared as a class property. • Provide a public default constructor and override the equals() method and the toString() method defined in the Object class whenever possible.

  36. Class Design Guidelines, cont. • Choose informative names and followconsistent styles. • A class should describe a single entity or a set of similar operations. • Group common data fields and operations shared by other classes.

  37. Example 9.4Designing Generic Classes • Objective: This example gives a generic class for matrix arithmetic. This class implements matrix addition and multiplication common for all types of matrices.

  38. UML: Package

More Related