If we use the example from perltoot which some of you may be familiar with, or at least have available, a class is developed for managing 'Person' objects. What I'm developing is similar enough to the Person example.
In my code, I have some objects for storing data, but I'd also like a search function. My objects are identified by an integer id - because they are going into an SQL DB at this stage.
However I'd like to be able to do searches. The natural inclination is for a search method which returns a list of integers, each of I could pass to my 'fetch' method on a new object on to get the data in.
However this doesn't quite 'feel' right. For example, I need to do a $thing->new to initialize the object so I can use the $thing->search method. So I've allocated storage, created an object that didn't need to be made.
Of course this is all semantic - but it's not obvious to me in what way I've got it 'wrong', nor how to implement it 'right'.
Can provide more detail if needed, but it's basically very similar to the 'Person' class from the manpage, with some added store and fetch methods to do SQL stuff.
Would appreciate some insights from more experienced OOP programmers.
In reply to Beginner OOP style question by Tardis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |