Where to find in-depth information about OOP?

I've found a lot of information on object oriented programming, but none of it seems to go into much detail. They always give you the shape example where cirlce, square, and retangle implement the interface. That's easy. I'm looking for something more real life and deeper into the process.

Does anybody have any good resources that are pretty in-depth? Or even code samples would be helpful.

Answers


That's a very broad question... Here's just a few links for you:

http://en.wikibooks.org/wiki/Object_Oriented_Programming

http://www.amazon.com/Object-Oriented-Programming-Peter-Coad/dp/013032616X

@Frankie - I've edited this for you having seen your comment. You're question is still very broad, but I'll try to provide a quick (very loosely thought) example of modeling some objects. The language I'll use is C#, though you can do it any OOP language you like.


We use Interfaces and Base Classes to represent very basic models. One of the defining differences between and Interface and a Base Class is that an Interface cannot be instantiated (think of it as a blueprint that cannot physically exist, just a design on paper)... a Base Class however can be instantiated (it can exist, and might be considered a prototype). Let's go from there...

Say we want to model vehicles... airplanes, cars, motorcycles, bicycles, etc. In our modeling brain we recognize that a Vehicle is the root of everything. Let's start then by defining a blueprint that works for all types of vehicles. For that we'll use an Interface

interface IVehicle
{
    string Make;
    string Model;
    int Year;
}

Our interface now says, any object we build that implements this interface must have a Make, Model, and Year property. Now cars, bikes, motorcycles, etc. pop into our head, and we want to make classes for them... but we realize, lots of these vehicles have things in common. Let's make a prototype for all LandVehicles, and for that we'll use a Base Class that implements our blueprint interface IVehicle

public class LandVehicle : IVehicle
{
    // We must physically implement the required members of the interface.
    public string Make { get; set; }
    public string Model { get; set; }
    public int Year { get; set; }
    // Then we can add things specific to land vehicles.
    public int NumberOfWheels { get; set; }
    public int TopSpeed { get; set; }
}

Now we have a prototype to build from. Let's design a Car and a Cycle

public class Car : LandVehicle
{
    // because LandVehicle is a real object, we do not have to re-implement its memebers,
    // we can just add to them:
    public int MaxPassengers { get; set; }
    public bool IsLuxury { get; set; }
    public string FuelType { get; set; }
}

public class Bicycle : LandVehicle
{
    public string Type { get; set; } // mountain, race, cruiser, etc.
    public int NumberOfGears { get; set; }
}

With that, we can instantiate Cars and Bicycle objects... but by using Base Classes, we could create many other types of LandVehicles without having to add our basic properties to each one. This is one of the things than makes OOP so extensible.

Furthermore with our Interface, we left it open enough to make other base classes, perhaps WaterVehicles, AirVehicles, etc... and thus classes that derive from them.

This is just the very tip of the iceberg, and a rather off-the-top-of-my-head example, but it should get you started. If you have more specific questions or a specific scenario you'd like to use as context, let me know and I'll help out more.


Need Your Help

SQL syntax error at or near 'union'

sql postgresql sql-order-by union

I have a small query, and a union to put another small query next to it. However, the union has a syntax error in it.

image stitching for more than 2 images

matlab image-stitching

I am trying to implement an image stitching algorithm and came across this wonderful code posted on

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.