[eluser]TheFuzzy0ne[/eluser]
[quote author="jedd" date="1236709857"]You mean more publicly visible functions ..?[/quote]
Indeed. I just want to avoid repeated code as much as possible. For getting a rows by ID or by Email, or by username for example, the code in each function would be virtually identical, apart from the WHERE condition.
[quote author="jedd" date="1236709857"]I'm looking at something similar at the moment, and I really like the abstraction approach (as you've done above), but I also like the approach of making my code self-documenting, and I think this approach doesn't satisfy quite like a series of
get_by_id() , get_by_username() , etc. (As you were intimating.)[/quote]
I agree. So where do we draw the line? Can we combine the two, or should we stick to one or the other?
[quote author="jedd" date="1236709857"]At the moment I'm implementing a bunch of them - and I may have maybe a dozen or so for this one particular model. Within each of them, well for some of them, I then call to one of several private functions that do the actual lookups, as there's certain groupings of complexity, if you will, for some of these lookups. Others are very simple WHERE additions to a table lookup. And a couple require some messy JOINs. So I'm not sure how comparable my situation is to yours.[/quote]
That's exactly what I was thinking of doing, but is this acceptable, and are we going to run into problem later down the line if we need to edit on of said private functions?
[quote author="jedd" date="1236709857"](ponder pulp) I think if we had real OO in PHP, it'd be nice to be able to overload the same function name with different input types and get 'redirected' in that fashion, but at the moment the extra code you (might) require to handle the different contents of your arrays that you're receiving .. well, I see the same
amount of code being required, just it gets spread around into different places. Ie. no great saving over the multiple method calls approach.[/quote]
Personally, I think that would complicate things as you may not know for sure if you're accessing the right "version" of a particular function.
Thanks for your input.