0

I have the problem statement to make an Object Model for.

Problem Statement: Every vehicle has an engine and a gearbox. A gearbox is composed of pulleys working according to predefined gear ratios. Cars have smaller engines with 4-6 gears while Sports Utility Vehicles (SUVs) have bigger engines with 4-8 gears. Heavy Duty Vehicles (HDVs) on the other hand, are designed to transport cargo thus have huge engines with 8-16 gears. The larger the numbers of gears the larger will the number of pulleys and vice versa.

Well, I have done all the Object Model, but there are three things that are confusing me:

A) The part where it says "A gearbox is composed of pulleys working according to predefined gear ratios", do we need to

  • Case 1: Take gear and pulleys as an object and make the relation of composition from object gearbox to gear and pulleys

  • Case 2: Take gear and pulleys as an attributes to the object gearbox

If it's the Case 1 or Case 2, how are we gonna show the predefined ratio of gears for every vehicle?

B) The part where it says Cars have smaller engines with 4-6 gears.....Sports Utility Vehicles (SUVs) have bigger engines with 4-8 gears.....Heavy Duty Vehicles (HDVs) have huge engines with 8-16 gears. So, how do we show the number of gears to all three types of vehicles? If according to Confusion (A) we chose the Case 1 and have made object gear, would we need to connect it to all the three objects Cars, SUVs and HDVs making Association among them OR if we chose the Case 2 from Confusion (A) then would we need to show the no of gears as an attributes in all the three objects Cars, SUVs and HDVs?

C) The part where it says The larger the numbers of gears the larger will the number of pulleys and vice versa, how should we show this relation in Object Model?

  • 1
    Write use-cases. All the details described by you may or may not even be applicable. Without the use-cases nobody knows. – Dunk Apr 24 '17 at 22:39
0

You're looking for general help with design of models for your problem statement. Since this website is not a general purpose design service, we're not going to do a design for you. But perhaps we can at least give some general advice, and provide constructive criticism for your problem statement (and current design, if you had one).


Modeling is done by identifying concepts (types) and their relationships (associations). On top of that, we can add constraints that prevent certain undesirable things from happening, constraints can range from simpler required cardinality ranges in the relationships, to broad expressions of what is and isn't allowed.

A model is, by definition, an abstraction; abstraction is the omission of irrelevant detail to the problem domain and to the ultimate usage of the model. In order to know what to model and what not to model, you have to understand how the model is going to be created and used.


Part A

My preference is to model even the simplest entities as concepts/object rather than as attributes, for starters, and later as an optimization, refactor entities into attributes when it is clear that the model doesn't need a level of detail for that type of entity (but rather just a value for those entities).

So, a perfectly good model for starters would be to model a gearbox as a collection of pulleys, and gears (and possibly gear ratios -- unless the ratios are derived from the pulleys and gears).

~~~If it's the Case 1 or Case 2, how are we gonna show the predefined ratio of gears for every vehicle?

This depends heavily on what needs to be modeled, which is not clear from the problem statement. Seek clarification for how the model will be used (so you know what needs to be captured, and so you know how to compute derived answers). In the simplest case, you just model the gear ratios directly as entities (or attributes). Otherwise, you need the problem statement to tell you how to compute or derive gear ratios from the gearbox of pulleys and gears, and you'll need to store the gears and pulleys in valid arrangements that let you compute the gear ratios.

Part B

So, how do we show the number of gears to all three types of vehicles?

Each car presumably has a gearbox. There is no need to connect components inside the gearbox to the car: simply connect each type of car to one (or more) gearboxes, the transitive relationships will suffice to connect cars to gears. Thus, to get from car to gears, we traverse thru its gearbox.

You could store, for each car, a copy of the number of gears, originally computed from the gearbox. However, this would represent caching of information, which is an design-complicating optimization that one should not undertake without clearly measured evidence that such an optimization is important for some reason.

Part C

The larger the numbers of gears the larger will the number of pulleys and vice versa

This is a statement of fact, a logical statement, a rule, if you will. It says that if we add one gear to a gearbox design, we have to have more pulleys, and if we add a pulley, we'd have to have more gears. (It doesn't tell us that it is or should be valid to add one gear or one pulley to an otherwise valid design, though.)

However, it isn't really precise: it could be that we need two gears per pulley or two pulleys per gear. You need to seek clarification from the problem domain.

If the relationships is a simple one of the the 2:1 relationships I suggest, then you should model this (a gear being related to two pulleys, or a pulley being related to two gears), and you won't otherwise have to model this rule/statement of fact because this will suffice to enforce that.

However, in the most broad sense, this might be thought of as a constraint, which you can apply in some form, though this is a difficult constraint to model in the most general case because it specifies a relationship between different gearbox designs without otherwise saying what any single valid/legal design might be. Thus, I could say I have 4 pulleys and 12 gears, and this statement of fact, this rule, would offer nothing in terms of validation (without access to other known valid designs, and, how did those known valid designs get validated??). All the rule says is that if one design is valid/legal, than another design with more gears has more pulleys. It is a hard statement to work with, and should send you back to the problem domain seeking clarification.

0

I'd like to just amplify here what @Dunk has said in the comments. What you described in your "problem statement" is not a problem statement in the object-oriented world.

The "Problem" described a data or relational model, not an object model.

An object model in the context of object-orientation is there to model behavior. Without behavior there is no object-model. Let me demonstrate with using the same description, but adding one single behavior:

  • "I'd like to list all parts in a hierarchy": In this case, I wouldn't model anything, I'd use some generic/existing "Node" objects to hold a String.
  • "I'd like to calculate the average gearbox-ratio (whatever)": I would just store the numbers, or even better, store the sum and count only.
  • "I'd like to enable ordering parts": I would only store the parts, with maybe the info for what vehicle it is for, but only if there are "search" behaviors defined in that area.
  • etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.