Is Creating Classes For Divs and Spabs Taking oop too far?
I'm getting into the practice of using oop for all my development now but am just wondering if I'm going too far with it.
Basically I have a class called Html which is used as an abstract class and acts as a base for classes used to create basic html elements i.e. I then have a "form" class which extends the html class and is used to build forms etc.
However I have also created a "div" and a "span" class which both extend html. Is creating classes for these going a bit too over the top?
I'm thinking based on the fact that I use an autoload function to load in these classes there will be a lot of calls to the file system when these need to be included
First time I've heard of PHP dom. Will take a look into it. Thanks. I see what you guys mean about not using classes for basic html.
I'm trying to get used to oop a bit more and practice makes perfect I think so I was just trying to apply classes to things that I use over and over again to make them easier but seeing as it takes about as much effort to write html with a method as it does to actually write html it does seem redundant ha.
Can you recommend any other things in a php/mysql based website where classes would be best applied? At the moment the most useful implementations seem to be for:-
1. Validating forms
2. Generating Forms
3. Image upload
4. SQL Queries
Not a direct answer, but I recommend spending some time with PHP Objects, Patterns, and Practice. You might also consider downloading and playing around with one of the object-oriented PHP frameworks. (I found CodeIgniter to be one of the easiest to learn.)
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Thanks NogDog. Book purchased. I've previously used codeigniter in my last job briefly and you're right it does seem the easiest especially compared to what I am tasked with learning in my new job, Zend, which seems albeit more advanced yet far more (unnecessarily) complicated than others frameworks. Although I am seeing the benefits in form validation.
I prefer to create my own classes though when working on personal projects hence my interest in oop best practices