http://www.perlmonks.org?node_id=909305


in reply to How to implement a Design Pattern/ Strategy??

I have two comments for you

I will be considering a subroutine to bypass the repetitive writing of similar code and provide a centralized chunk of code that can be invoked from anywhere within your program, this carries the advantage of making it easier to debug and trace errors, modify & enhance code later and facilitate adding more capabilities centrally that are going to be dynamically extended to the areas in the program invoking the subroutine without having to write too much code or deal with nasty inadvertent typos for instance.

You can have many subroutines organized by the theme of the activities they will be performing and if necessary they can communicate among themselves, consider this pseudocode:
#define functions in themes sub dependency_checks{ #receive arguments and perform the checks #common to the so many if statements } #write your program with the rest of the unique section.

Secondly, how do you intend to use @matches, does ordering matter to you in this case or could you avail of the flexibility that a hash based structure has where you can directly retrieve and have access to values without so much hassle, the link you provided implied that hash-based structures are more flexible.

From the overview of the concepts presented to you in http://www.perl.com/pub/2003/08/07/design2.html, familiarize yourself with the concepts and consult links such as those in Tutorials->The Uniqueness of hashes.,intro to references but I emphasize that you should go ahead learning Perl in an orderly way without jumping ahead of yourself because new knowledge needs time to solidify and if you have any doubts or questions, seasoned monks will undoubtedly spring to help, best of luck !


David R. Gergen said "We know that second terms have historically been marred by hubris and by scandal." and I am a two y.o. monk today :D, June,12th, 2011...