I am trying to get my head around object oriented programming as it pertains to web development (more specifically PHP).
I understand inheritance and abstraction etc, and know all the "buzz-words" like encapsulation and single purpose and why I should be doing all this.
But my knowledge is falling short with actually creating objects that relate to the data I have in my database, creating a single object that a representative of a single entity makes sense, but what are the best practises when creating 100, 1,000 or 10,000 objects of the same type.
for instance, when trying to display a list of the items, ideally I would like to be consistent with the objects I use, but where exactly should I run the query/get the data to populate the object(s) as running 10,000 queries seems wasteful.
As an example, say I have a database of cats, and I want a list of all black cats, do I need to set up a
FactoryObject which grabs the data needed for each cat from my database, then passes that data into each individual
CatObject and returns the results in a array/object - or should I pass each
CatObject it's identifier and let it populate itself in a separate query.