Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well the first thing you have to realize is the OOAD ("Object-oriented analysis and design") is a tool and not a means to an end. What you get out of that process is a model, not a true representation of what you're modelling. That model makes certain assumptions. The purpose of that model is to solve a problem you have.</p> <p>So how do you know how to design objects? How do you know if you've done it right? By the end result: has it solved your problem?</p> <p>So, for the Car example, in some models a car count could simply be an integer count, for example the car traffic through an intersection in a traffic model. In such a model rarely do you care about the make, model or construction of cars, just the number. You might care about the type of vehicle to the point of is it a truck or car (for example). Do you model that as a Vehicle object with a type of Car or Truck? Or just separate carCount and truckCount tallies?</p> <p>The short answer is: whichever works best.</p> <p>The normal test for something being an object or not is does it have behaviour? Remember that ultimately objects = data + behaviour.</p> <p>So you might say that cars have the following state:</p> <ul> <li><h1>of wheels;</h1></li> <li>Height of suspension;</li> <li>Left or right drive;</li> <li>Colour;</li> <li>Width;</li> <li>Weight;</li> <li>Length;</li> <li>Height;</li> <li><h1>of doors;</h1></li> <li>Whether it has a sunroof;</li> <li>Whether it has a stereo, CD player, MP3 player and/or satnav;</li> <li>Size of the petrol tank;</li> <li>Number of cylinders;</li> <li><h1>of turbo charges and/or fuel injection;</h1></li> <li>Maximum torque;</li> <li>Maximum brake-horsepower;</li> <li>and so on.</li> </ul> <p>Chances are you'll only care about a small subset of that: pick whatever is relevant. A racing game might go into more detail about the wheels, such as how hot they are, how worn, the width and tread type and so on. In such a case, a Wheel object could be said to be a collection of all that state (but little behaviour) because a Car has a number of Wheels and the Wheels are interchangeable.</p> <p>So that brings up the second point about objects: an object can exist because of a relationship such that the object represents a complete set of data. So a Wheel could have tread, width, temperature and so on. You can't divide that up and say a Car has tread but no wheel width so it makes sense for Wheel to be an object since a Wheel in it's entirety is interchangeable.</p> <p>But again, does that make sense for what're doing? That's the key question.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload