|
classes are best when you need "re-usable" code, and if know how, why or when to use OOP methods and properties you know how to use classes.
All that a class does, is encapsulate methods (sub routines and functions) and properties (constants or variables) into a "wrapper" with a name.
One use is if you are writing an application that can use different database servers, you could encapsulate all the MySQL code in one class, Access in another, MSSQL in a third class etc.
Then your app could check a configuration parameter and include the appropriate class/module.
All the property and method names are the same across all three classes, but the code will have the appropriate syntax for the DB server.
__________________
Chris. ->> Please login or register to view this content. Registration is FREE <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
|