I read about objects models on Wikipedia, but it is too abstract to really make much sense to me. Can someone explain what an object model is in plain English?
1
For our purposes an Object is a thing or concept and a Model is a representation of the parts you need to refer to in your design/code.
An Interface is a description of what of what we need to know/do in our design/code.
For example: a Vehicle
object model might be an interface which requires:-
Properties to represent the state of the object (capacity, speed, direction)
Methods which affect those properties (load/unload, go faster/slower, turn)
Exceptions that represent errors which may occur (collision, breakdown, no fuel)
That interface is then implemented as a class and the code might differ for a Hovercraft
compared to a Car
but for the code which needs to operate the vehicle, it should not need to know about those things.
There are two kinds of object models:
-
for a programming language, it is the characteristics of objects in that language. Three examples of those characteristics, there are others:
-
is there a notion of multiple inheritance or not (if present, there are more questions to answer, is it limited to something like interface or more general like in C++, what happens in case of apparent ambiguity: error like in C++ or a resolution algorithm like in Common Lisp, which resolution algorithm is also important)
-
are method’s validity checked statically (how? with an inheritance mechanism or something else) or dynamically (what happens if there is no method of that name? an error? is forwarding possible?)
-
are those characteristic ad hoc or do they have a theoretical foundation? Which? (Cardelli’s Object Calculus? Something else?)
The object model is somewhat independent of the programming language. Languages targeting Microsoft’s CLR tend to have a more similar object models than others as the classes are designed with a model in mind. You may even have languages with several object models. C++/CLI has two, the C++ one and the CLR one. Objective C++ is another language with two object models: the C++ one and the Objective C one (which is nearer to the one of SmallTalk)
-
-
a (more or less standardized) set of classes representing something (documents, telescope, …). I won’t write more about that, it is just a modelization based on classes and objects.