I have been studying my PHP Advanced Class here on City University for past 3 months and I had a last lesson behind me. The time has come and we need to use all the knowledge we manage to get during those 3 months. The course work says something on these lines. Produce web application where people can sign up, sign in, change their profiles, set their location, specify RSS feeds they like. Its basically location based RSS reader. The PHP application should use Google Maps to display the location of all users on the map and once you are signed in it should display the location of RSS articles on the Google Map as well and list of latest unread articles.
We have gone through most of this stuff so it should not be that difficult in terms of building functionality. My questions come where I start to think what is the right way to do thinks. I love object oriented programing because it makes my code clean and easy to read. I have read that the execution is slightly slower comparing to procedural programing technique. I also like the fact that I can just build those classes and use them across lots of different projects. For example, I have created form class which generates the sign up form and also the sign in form. There is a method inside that class which validates the form before submitting data into database. I have also created user class which is responsible for managing user data. It usually uses database class which is responsible for insert, select and update queries and so on.. I really like coding in OOP and I think it must be specially useful when you are building functionality on top of your existing code and also debugging seems to be more easy.
There is always but
So my question comes. Do you use classes for everything or you use procedural programming in some parts of your code. For example page header. It consist of structured data such are css links, js links, meta data etc. I have created header class where I set and get my css and js paths, keywords, description and those are displayed in the header.php which is included into every single page. Bu now I am thinking I could even go further and set all the header data (doctype, metadata etc.) in the header class but I do not need to change these data for any page. It seams to be cleaner way to set all the header data using header class but on the other hand it looks a bit like overkill. What do you guys think? How do you do it? What techniques do you use? Do you prefer OOP or procedural programing?
Comments
good luck in finding the best way…
@automanijak – Thanks! Will try my best.