Hiya, I'm still hesitant on starting my project, as I am unsure whether or not to code everything using classes or not. Whilst searching the net for inspiration, I came across this script on Code Canyon. Does this script have to be coded in a class, or can the same results be achieved by simply using functions. What would be the main advantage(s) for coding such a script using classes? This is still something I have difficulty getting my head around. I would appreciate any body's thoughts on this topic. Thanks, FishSword
A pagination script doesnt have to be written using a class, the author of this particular one chose to take that approach. Writing as a class helps organize code , grouping functions that serve a common purpose together.
Its easy to maintain, flexible, you can write less code once a class is written by extending the core class... At first it takes a bit of work to grasp the concept, but once you understand you see the benefit.
Thanks once again! Do classes have any disadvantages? - e.g. Do they put a lot more strain on the server?
Any code can be written poorly and cause server problems. If you are going to write a larger application, using classes may be a good way to go. For writing something as simple as a pagination script, it could be overkill. (not in the sense of server strain, but just may not need to implement a class to accomplish the function). With coding, there are always many ways to accomplish an end result. Budgets, deadlines, long term goals of project... all have a deciding factor on the approach to take.
To summarize, classes are not a requirement to write even large projects, but they might help maintainability, organization and also save some coding work. Most quick projects I do I complete using ordinary functions, and it works fine for me.