1 / 20

Object –Orientated Design II

Object –Orientated Design II. Revision. Usually the most natural way to describe a task is to list the entities involved in the task. These entities are referred to as objects . What are the two most important properties of an object ? Answer: State Behaviour. Revision.

derica
Download Presentation

Object –Orientated Design II

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 –Orientated Design II

  2. Revision Usually the most natural way to describe a task is to list the entities involved in the task. These entities are referred to as objects. What are the two most important properties of an object ? Answer: • State • Behaviour

  3. Revision What determines the state of an object ? Answer: The attributes ( the individual components of information of the object ). Attributes can be primitive values or other objects. What is object behaviour ? Answer: Behaviour is the actions that an object can perform ( and which change the state of an object ).

  4. Revision What is a class ? Answer: A class describes the state (attributes) and behaviour of an object. What is an instance of an object ? Answer: An instance is an individual occurrence of a class with specific attribute values and behaviour. An object is defined as an instance of a class.

  5. Revision What is a super-class ? Answer: A super-class is a class that contains common attributes of other classes. What is a sub-class ? Answer: A sub-class is a class that inherits the attributes and behaviour of one or more super-classes.

  6. Revision What is behaviour overriding ? Answer: If a specific behaviour is defined in a sub-class as well as its super-class then the behaviour of the sub-class has priority. What is a class hierarchy ? Answer: This is a diagrammatic view of the classes in a system e.g.

  7. Revision Machine Applicance Vehicle Computer Van Car Truck Mini Delivery Limo Sports Dump Pickup

  8. Creating OO Designs Object-Orientated Designs An object-orientated design provides a more natural and systematic framework for specifying and designing a programming solution. Program designs are almost always based on the program specification i.e. a document describing the exact requirements a program is expected to achieve.

  9. Creating OO Designs There are generally four phases to the object-oriented design process: • The identification of objects from the program specification. • The identification of the attributes and behaviours of these objects. • The identification of any super-classes. • The specification of the behaviours of the identified classes.

  10. Creating OO Designs It is imperative that the four phases of the OOD process are followed systematically to avoid overlooking important aspects that may affect the final design. Phase 1 – Identifying Objects The most important and crucial phase of the OOD process is the identification of objects within the program specification. A systematic way to identify possible objects is to list all the nouns in the program specification.

  11. Creating OO Designs Nouns represent entities or concepts ( usually a person or a thing ) Proper Nouns are best described as names e.g. persons, cities countries e.g. Jamaica, Mary etc. Common Nouns generally refer to things or concepts e.g. lecturer, car, sky. Once a list of nouns has been determined using the program specification a set of elimination operations can be used to streamline the noun/class list.

  12. Creating OO Designs Elimination Operations • Redundant Classes Remove classes that are identical to another class but with different names e.g. pupil would be a redundant class for student. • Irrelevant Classes Some classes may have no relevance to the application under design though they may appear in the program specification e.g. user, keyboard. Sections of the program specification that are deemed outside the scope of the program would also be irrelevant.

  13. Creating OO Designs Elimination Operations • Attributes and Behaviours Nouns that are the attributes or behaviours of other objects can be removed. This are easily identifiable in possessive phrases e.g. the student’s book, the name of the dog etc. • Implementation Constructs Nouns that refer to the program under implementation should be avoided e.g. the system, the program, the application etc.

  14. Creating OO Designs A final list of candidate classes is identified after the elimination phase of the object identification. Phase 2 – Identifying Attributes and Behaviours The next phase in the OOD process is to identify the attributes and behaviours of the classes remaining after the object identification phase If there is any doubt whether a noun should be eliminated the best course of action is to let it remain. It is easier to eliminate classes later in the design phases than introduce new classes.

  15. Creating OO Designs Identifying the attributes of an object requires some general knowledge as well as knowledge of the problem domain under consideration. Note: • Not all attributes may be described in the program specification. Some common sense is required. Be careful not to include to many attributes outside the scope of the program specification unless they are absolutely necessary. This can lead to cumbersome and unmanageable designs.

  16. Creating OO Designs An easy way of identifying the attributes and behaviour of an object is by highlighting possessive phrases associated with the object. e.g. the A of B the size of the boy the name of the book C’s D the girl’s name the car’s color

  17. Creating OO Designs After a set of attributes have been identified an automatic set of behaviours can be listed i.e. constructor, mutator and accessor behaviours on the attributes. Other behaviours can be identified by analysing the program specification. Specifications may require tasks to be performed which are better re-phrased as behaviours on an object.

  18. Creating OO Designs Phase 3 – Identifying Super-Classes This phase requires the creation of super-classes if it is determined that classes identified in Phase 1 contain common attributes and behaviours. These common attributes and behaviours are placed in a super-class.

  19. Creating OO Designs Phase 4 – Specifying the Behaviours In the final phase of the OOD process the behaviour of objects are specified. To specify the behaviour of an object we require the input, output and process of the behaviour ( Note that this is similar to design process in procedural program design ) The process of the behaviour specification outlines in pseudo-code the task that the behaviour is to perform.

  20. Creating OO Designs The output specifies the result of the behaviour. The inputs to the behaviour specification are values outside the scope of the object. Objects have their own attributes which are automatic inputs to their behaviour. Only values outside the attributes of the object need be input explicitly e.g. the behaviour to modify an attribute will require an external input i.e. the new value for the attribute.

More Related