scottayy wrote:I've looked up multiple articles about MVC, tried somewhat coherantly to write a php5 database wrapper class (simple you'd think?), and have been separating coding logic from presentation using template lite.
You tried the model-view-controller pattern and database API abstraction. Neither of those things are particularly easy for someone who has never tried to do them before even if that person is experienced with objects. I wouldn't be disheartened.
Most of you on this forum who design with these practices learned it in another language. I'm learning it in PHP, has anyone else learned it in php?
I learnted what objects and classes etc. were and applied them in C++ mostly because I was just fasinated by everything about C++, it's so damn cool (geek chic if you will). It wasn't until using PHP that I actually felt I needed them and had genuine purpose to use them and looked into applying them properly i.e. refactoring, design patterns and unit testing. Many of the features of C++'s OO model are actually frowned upon now and are known to be harmful.
But, how long before it just "clicks" in my head?
Two years for the average person, I've heard. But there are levels of knowledge.
supeerdezign wrote:And screw anything you hear about inheritance... I think it's horrible for them to discuss it so early on, but it's like they all do.
If you are referring to the tendency for people to overuse it, then I agree. But inheritance is an absolutely cruical part of OO. In fact I would go so far as to say OO wouldn't exist without it.
I would say it's easier to learn OOP from languages such as Java where you are forced to do it. In PHP it's easy to skip stuff/cheat and get away with it.
Yes I agree. A PHP framework will do largely the same as long as the desire to practice OO is there.
Maugrim_The_Reaper wrote:You start adding functions, then they're needed elsewhere, then you realise they're needed everywhere. Eventually you'll either give up or figure out that what you did wrong - overloading the class with too much responsibilities
Like fighting rapids in a raft you'll feel like you are going forwards and backwards, forwards and backward. I pinch of self criticism and self belief will ensure the mean of all that bidirectional activity is the gradual meander round the twisting bends of the OO paradigm leading to green banks and tastey partsures.
Kieran wrote:it'll take a while. It's more of a mindset than a rulebook anyway, stay the course!!!
Yes, but you need the rulebook, possibly many, at first. It's like anything, you learn the rules first, and then you learn where you can break them.
<stuff hockey said here>
There is nothing like having the rules and conventions of the languge itself enforce certain behaviours on you. That's why I love PHP 5's E_STRICT errors you get when you subclass poorly. The people who write OO code in C etc. are people who are already familiar with OO and no doubt the limits of C as well.