in reply to Why CGI::Application?
Let's say I have a simple application that should do the following:
- Display a paginated list of my data
- Allow me to search my data, and return the results in a paginated list
- All paginated lists of data, filtered by a search or not, should be sortable by column
- Allow me to view a single record at a time
- Allow me to edit any given record
- Allow me to delete any given record
- Allow me to add new records
How do I tie it all together?
What CGI::Application does is allow me to focus on the issue at hand: how do I retrieve my content? how do I determine what content to retrieve? Now, I can focus on one aspect at a time - one method per action, and calling related methods when necessary. I leave my display issues to templates, and simply assign the data I pull to the templates. I have session handling kept in a single superclass, along with my database connections. All I have to do is get my content; the rest is taken care of.
The CGI::App framework is setup in such a way that code reuse becomes not only easy, but the only way to effectively program. It enforces consistency, because you could be inheriting from any given module in order to extend it for further applications; because they all share the same framework, you don't have to worry about collisions in terminology when you mix and match.
On top of that, it allows you to setup an easy inheritance framework such that you can have multiple application modules inheriting from the same parent so that the same look and feel are inherited; this means that all of your site's applications can easily share the same look and feel, as well as have a common underlying structure.
And, if you want to, you can port your entire application to another site simply by changing the parameters you pass to it through the instatiation script -- new data stores, different group of templates, etc. Your reusability now extends not just to the current site, but to many sites.
Sure, you can "adjust your coding style" so that code is more reusable; what CGI::Application does is give you a ready-made, rigorously tested, framework for reusable code. Personally, I've had enough of hand-made frameworks; I want something that not only I can understand, but many other people can understand and have used.
|
---|