| Java Quick Reference |
|
Sidebar - Skyscraper and Firefox
|
SCJD Study Notes - Application Design - OOD
A class is a programming construct; a template used to create objects. Try to think in terms of the object vs the class when you start a design. The design process involves building a model of an object using abstraction.
An interface describes the services the client wants accomplished ie the object's capabilities or functionality. A public interface describes the objects contract with users. The implementation is how the object goes about providing the services In Procedural programming design is based on the implementation; it is task oriented. Object-Oriented programming design is based on the interface; it is service oriented. You need to be concerned, initially, with what an object can do, not how it does it. Encapsulation hides the non-essentials ie it hides the implementation details. This is not about setting every field to private and writing public gettors and settors. You need to make sure your public interface does not rely on how the objects behaviour is implemented. Think what would happen if every time you upgraded your PC you had to learn a new keyboard layout! Sales would plummet and programmers would become extinct. When you begin to design an object, you need to act like an investigative reporter and discover the:
of an object's existance.
As a first step, describe, in a single paragraph, exactly what the object you're building should do (requirements). This paragraph is informal and written from a user's perspective ie "I want an object that can display the current date and the time in an analog or digital format." not "This object uses the Java Date class and JPanel to display the date and time. The analog display blah, blah, blah ...." State and BehaviourStateAn objects attributes define its state (condition). The attributes can be defined as:
BehaviourDesign TrapsIt might be easier to describe well-designed code in terms of what it is not vs what it is. The following is a summary of such information gleaned from various sources: Source: Object-Oriented Design in Java by Stephen Gilbert and Bill McCartyData Warehouse TrapAn object is not a repository for data that the rest of your program will use! An object should manipulate it's own data; not pass it to other parts of the program which then manipulate it. Spectral Object TrapAn object is not a collection of methods you pass data to. Objects with no data are ghosts. Multiple Personality TrapAn object should model only one object. Every data element and every method should contribute to that object. |
|
|
OOD | OOP | Resources |