Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Have a Class method (not a instance method) called (say) loadFrom(), that takes a filename, and returns an array of instances. Have another Class method (say) findMatching(), that takes a reference to that array and a partially completed instance of that class, and returns one or more matching instances from the array.
If you move your data from a flatfile to a DB, you pass a DB handle (or credentials) to loadFrom() and everything else still works. As you add attributes to your class, the search code continues to know how to compare your instances, and your instantiator knows how to construct (partial) instances. The internals can change as needed, with the external inteface remaining the same, except where you need deal with new attributes. Examine what is said, not who speaks.
The end of an era!
"But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen"Think for yourself!" - Abigail "Time is a poor substitute for thought"--theorbtwo "Efficiency is intelligent laziness." -David Dunham "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon In reply to Re: Advice on OO Program structure & organization
by BrowserUk
|
|