View Single Post
08-21-2007, 05:53 PM
#5
Haris is offline Haris
Status: Request a custom title
Join date: Dec 2005
Location:
Expertise:
Software:
 
Posts: 2,741
iTrader: 9 / 100%
 

Haris is on a distinguished road

  Old

Originally Posted by Salathe View Post
My suggestion would be to initially broaden your horizons when attempting to understand OOP and what it is all about. Look back into more developed arenas such as Java. Or (and), go more theory based by looking at Object Orientation in a broader sense -- it's relation to other programming paradigms (there are lots). There is no shortage of valuable information available either digitally or in (often huge tomes) books.

If you restricted your learning specifically to PHP's OOP implementation then, in my own point of view, you wouldn't be getting the best out of your time. Nor would you get the whole picture, or anything close.

Are there any areas that you've looked into so far and had trouble understanding (please don't say, "the whole concept" )?
Ruby on Rails. I'm jumping into PHP OOP's and will try to make my first ever OOP application. I've created one application in Ruby (Only ruby) but still didn't grabbed the WHOLE correct concept. I haven't used neither Ruby or Ruby on Rails much.

I'll try to re-create what I've created in Ruby.


Make an OrangeTree class. It should have a height method which returns its height, and a oneYearPasses method, which, when called, ages the tree one year. Each year the tree grows taller (however much you think an orange tree should grow in a year), and after some number of years (again, your call) the tree should die. For the first few years, it should not produce fruit, but after a while it should, and I guess that older trees produce more each year than younger trees... whatever you think makes most sense. And, of course, you should be able to countTheOranges (which returns the number of oranges on the tree), and pickAnOrange (which reduces the @orangeCount by one and returns a string telling you how delicious the orange was, or else it just tells you that there are no more oranges to pick this year). Make sure that any oranges you don't pick one year fall off before the next year.