good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: Module Organizationby blue_cowdawg (Monsignor) |
on Oct 14, 2010 at 14:21 UTC ( [id://865271]=note: print w/replies, xml ) | Need Help?? |
In my humble opinion your first question should be "what am I trying to accomplish?" Problem definition goes a long way to proper planning and proper prior planning prevents p*** poor performance. Module organization should be driven by what makes sense against the backdrop of that answer. More over if you are going to be working with a team of people then the organization of your modules should fit some agreed upon standards The first thing you have to decide after answering the "what am I trying to accomplish?" question is what you are trying to use the modules for. There are task oriented modules and there are data oriented modules, just to come up with broad categories, and the lines between those two can be very blurred. Thinking of your MUD application for a second (why does everybody seem to want to write a MUD anyway?) let's come up with a theoretical set of modules:
In my very limited example above you need to assign attributes to each of these "classes" that are in common but distinctive. (Loyalty, movement, hit points, energy points, etc. etc. etc.) and some way to act on those. In a much simpler example:
We have a parent module Animal with two children modules Dog and Cat. They are both animals, they both "speak" but they are different. I could have expanded the definition further to include attributes like fur, purring, growling, hissing, tail or no tail, etc. etc. but for simplification I didn't. So when you are designing and organizing your modules think in terms of functionality, commonality as well as disparity. Another module organization example, this one from Real Life &tm;.
What's happening here is I have two types of reports that an application is generating (actually, this is a very condensed version of the real deal) a High Level Report (for management types) and a Status Report (for the troops in the trenches) and depending on how the constructure new is being called for the module Report you get a reference back to a blessed object of either Report::HighLevel or Report::Status. In both cases they have the method generate defined so if I invoke it works the same. That's the beauty of OOP. Hope my long winded answer is of some help. Peter L. Berghold -- Unix Professional Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
In Section
Seekers of Perl Wisdom
|
|