skip to main |
skip to sidebar
In continuing with definitions, here are a few more that add to the core fundamentals of Object Oriented Design.Class describes the abstract characteristics of a "thing" (or Object as we define below), such as the "thing's" characteristics (its attributes, fields, or properties), and the "thing's" behaviors (the things it can do, or methods, operations, or features. It is typically the blueprint for which Objects are to be built on.For example, a class Dog could consist of traits shared by all dogs, such as eye and fur color (characteristics - aka properties), and the ability to bark and sit (behaviors - aka methods).A Method, or function as they also reffered to as, is an Object's ability. A German Sheppard, being a dog, has the ability to bark. So "bark()" is one of German Sheppard's methods. The German Sheppard might have other methods as well, such as "sit()", "eat()", or "walk()".The properties and methods defined by a class are called members. An Object is a pattern (exemplar) of a class. When a class of a German Sheppard is created, it can inherit from the Dog Class, and therefore has the same properties and methods as its parent Class.
An Instance is the actual Object created at runtime. The set of values of the attributes of a particular object is called its State. The Object consists of state and the behavior that's defined in the object's class.
- Class is designed --> Object inherits from Class during design --> Instance of Object is created at runtime.
The root to understanding Objected Oriented Design is grasping the fundamentals of three concepts: Inheritance, Encapsulation, and Polymorphism. Typically I hate reading definitions and go straight to analyzing code, but I have found that when it comes to understanding Object Oriented Design, that it makes it much easier to really understand the definitions behind the concepts before writing any code. Regardless what language you are coding in, the concept of Object Oriented Design is the same.And believe it or not, finding clear and understandable definitions for some of these was a real pain, as it seemed like every author has their own way of defining them, and some were better at it than others, and ironing out their definitions is what really set the wheels in motion for starting this blog.Inheritance, simply put, enables one "thing" to inherit from another "thing". In programming, we are specifically refering to classes, which I will define in another post. For now, understand that inheritance involves using something as a blueprint that can be used by something else (such as a builder using a blueprint for a house to build a house).Encapsulation is more tricky to explain. A good text book explaination would be that Encapsulation involves a single object that contains both its data and behaviors and can hide what it wants from other objects. Well what does that mean? Think of driving a car: When we push down on the accelerator, the car goes faster. When we hit the break, it stops. We aren't concerned with the actual mechanisms that make the car go faster, nor break, but we know how to get the car to do both. In programming terms, we can hide those mechanisms from other objects, and just give them the option to move faster or stop, without them being able to see how either are being done.There are various was to do this, and some good words to associate with this concept for now would be public, private, get, and set, all which you may have seen by now. We'll come back to those later.Polymorphism is probably the hardest Object Oriented Design concept I ever tried to dig up a clear and consise defintion for, and I am not talking about the Greek definition of it. In reading a dozen C# books, I've only come by one that explained it as well as this: Polymorphism enables an object to perform an operation the way that it wants to. For example, all vehicles have a method for starting their engine, but a car starts differently than a rocket. Both are vehicles, but perform the start action in a different way. A key term associated with Polymorphism is Overloading, which we'll get to later.And those three are the big ones. Get a basic understanding of them, then expand your knowledge of them, and you'll have a great start understanding Object Oriented Design.