Jump to content

Classes


gekk0

Recommended Posts

Hi, i've been looking into using classes for my programming recently. I'd like to get some of your input here into real life examples of how you've used them? The reading that i've been doing give these abstract examples, whilst reasonabley logical i find dificult to realise why it is i should be using classes as a tool in my programming box. I have confidence that i'm simply ignorant, so yeah, how have u used them?Cheers.

Link to comment
Share on other sites

I've got a database class that encapsulates all the MySQL stuff. I use it to connect, run select, insert, update, delete queries, do error handling, etc. If I use a different database I can just make another version of the class using that database without needing to rewrite the entire application. I've got a session class that has methods for login, logout, keeping track of normal session data, switching to a specific user, etc. I've got a configuration class that's used to read and write all of the config options for the application. A couple other application-specific classes. I've got a page class that I don't use much any more that's for processing templates, you tell the class which HTML template you want to use and send it all of the dynamic data, and it goes through the template and replaces everything for outputting.

Link to comment
Share on other sites

Before creating classes, you should probably try and use some existing ones to get the idea.Depending on what you do, you may find different classes useful. Like, if you use MySQL as a database, you may find the MySQLi API useful. Use it in its OOP style (i.e. with its class, not functions), and you might like it.If you use XML, consider investigating into how DOM and XSL work.Or try somthing from the Zend Framework, like Zend_Mail for example.

Back in my Student days, I used classes to catch up on my sleep... :)
Haha. Funny :) .
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...