![]() |
|
Problems? Is your data what you think it is? | |
PerlMonks |
Code reuse and method sharing with OOP / CGI::Applicationby jeyroz (Monk) |
on Jun 05, 2005 at 15:39 UTC ( #463729=perlquestion: print w/replies, xml ) | Need Help?? |
jeyroz has asked for the wisdom of the Perl Monks concerning the following question: Forgive my naiveté but have found conflicting opinions on the following topic. I am attempting to make use of CGI::Application and OOP on a project but feel as though I am hanging myself with all the freedom that Perl provides. For the (procedural) projects I have worked on in the past, a module has been set up with common methods used throughout the application via Export. My question is, when structuring an application (made up of smaller applications) what is the best procedure for sharing a basic set of methods. These methods aren't to be overridden or refined ... just used by the separate application modules. I have seen this accomplished in several ways: 1) Set up a Base C::A module / class that @ISA CGI::Application. This Base class implements sub setup{ ... } and the standard set of C::A methods and is used by all other C::A modules (providing access to the default set of C::A methods as well as any common (custom) methods through inheritance). This seems like a good way to share common run-modes maybe, but not utility style methods. 2) Set up a Base class (Super / Abstract class) to share methods through inheritance despite the fact that the relationship between the base and subclasses isn't one of inheritance ... just utility. 3) Set up a "utility" class to be 'use'd by the C::A modules (any any custom classes) providing access to the common methods. I hope I explained that clearly enough ... I know that all three are somewhat similar but I am looking for the 'cleanest' way of doing it. Also, if you think I am wasting my time trying to share a somewhat mismatched group of methods and should be breaking these methods up into respective classes (ie: a Display class that handles template output, pagination display, etc. / Authentication class that handles user auth, session management, etc. / a Debug class that provides Dumper and various diagnostics) please let me know. I am teetering back and fourth on that as well. Thank you all ahead of time ... I appreciate the help. - junior monk author => jeyroz
Back to
Seekers of Perl Wisdom
|
|