tags:

views:

513

answers:

12

I understand procedural programming (well, who doesnt) and want to get a good understanding of OOP and after that functional. I'm just a hobbiest so it will take me an age and a day, but its fun.

Does anyone have any ideas for what I can do to help? Project ideas? Example well documented code thats out their?

I am currently using C++ but C# looks a lot nicer to work with.

+8  A: 

There are some great OOP books from Head First covering Object-Oriented Analysis and Design and Object-Oriented Design Patterns.

cxfx
IMO best set of books to help refresh the concepts that differ between languages.
Woot4Moo
Great as books are, just reading about OOP in books won't ever really teach it to you. You really need some hands-on experience.
Benson
Some people might dislike the Head First series because they seem targeted at novices. People with even a modicum of experience seem to get offended when you insinuate that a book targeted at novices would be appropriate for them, but if you have come so far as to accept that you have more to learn, these Head First books are _awesome_. They give concrete examples and state the principles in clear and concise ways.
RibaldEddie
+4  A: 

To truly get comfortable with object oriented programming there are a couple of things you can do.

  1. Force yourself to model a real world problem with objects. Create classes to represent the objects, and methods to represent things they can do.

  2. Use a language and / or a framework that really forces OOP on you. It wasn't until I took a Java class and started using Swing heavily that I really grokked OOP. I haven't played much with C# recently, but I think either C# or Java would be a good way to go.

Benson
A: 

It depends on what languages you know. Personally I would recommend some type of OO scripting language. IE PHP or Python, I believe this will help you transition semi-smoothly.

Woot4Moo
I strongly disagree. Both PHP and Python have very strange object systems. Python's is kind of nice, but it does a very poor job at inheritance, and requires the explicit "self" parameter, which can be confusing. PHP's object system is okay, but it has quite a few oddities as a result of PHP's somewhat limited heritage. Ruby, on the other hand, has a great object system and might be a good choice.
Benson
Hmm I would have to take a look at Ruby, and yes I agree Python does have a very unique way of handling things. Most procedural programmers will continue to write their code in that fashion even if it is in OO land. Thanks for the Ruby suggestion though.
Woot4Moo
+1  A: 

I've recently converted from PHP to C# and love every minute of it! I'd say find yourself a new project with a flexible timeline and just dive in. Get a couple books too, particularly on OOP concepts and design patterns.

Colin O'Dell
+4  A: 

I recommend you read Object Thinking by David West. There is very little code in the book, but a lot of talk about how to model.

A couple things I wish someone would have told me when I was starting out are:

  1. When modeling objects, you should focus on behaviors more than the shape of the data.
  2. Although many OO tutorials model real world things such as animals and vehicles, many of the things we model in OO software are concepts and constructs (things that have no physical representation in the real world).
Daniel Auger
+5  A: 

I'd recommend working mainly with a strongly-typed language like C# or Java, as so many of the design patterns and general OOP principles are geared towards strong typing (GOF, Refactoring, Uncle Bob). Ruby is wonderful but a lot of common OOP principles like coding to interfaces won't apply.

Spend some time with Uncle Bob's SOLID principles. Go slowly, paying particular attention to Single Responsibility. If you don't get anything else from Uncle Bob, get SRP in your head and apply it early and often.

I also like Uncle Bob's idea of code katas. I'd recommend working through the bowling game kata.

Dave Sims
+2  A: 

Try learning Smalltalk - best way to improve your OO programming.

Larry Watanabe
+2  A: 

After getting a basic idea for the fundamentals, the best way is to learn by example. Download popular open source projects and dig your way through them. Some projects I've learned a lot from:

Michael Valenty
A: 

I think you can do research about Test Driven Development. This automatically orient you obeying the rules of Object Oriented Principles. This is the practical way but it works. You can also support this process with learning teorical issues, like SOLID principles and Design patterns. Reading the source code of big projects is also good idea to improve your object oriented skills

Sessiz Saat
A: 

One piece of advice I wish had been given to me a long time ago is:

Don't over-use inheritance.

This is a really easy pitfall for a beginner (imho) as it is one of the big concepts in OOP that everyone talks about.

Basically, you should be using inheritance only where it really really makes sense - think data types, some widget hierarchies, stuff where the is-a relationship is so obvious anybody would have used it. Otherwise you should be injecting objects into others and calling them in order to change functionality (composition).

Do not be tempted to just define a load of abstract methods and override multiple times to implement them differently when you could have a single class and inject (argument to constructor) an object implementing an interface that you call to do whatever variable functionality that you would otherwise have put in the abstract methods. This will lead to much simpler and more reusable code (in my experience), and more testable too.

DaveC
A: 

In order to master your Object oriented skills you need a lot of practice.

Try to think in "object terms" for about everything you do with code.

Apply it :

  • in your server-side language
  • keep your Java Script code object oriented
  • think about keeping your CSS code easily reusable and contains low duplicity.
Fedyashev Nikita
A: 

Read Bertrand Meyer's OOSC2. It's probably the best book ever on OO programming.

CesarGon