0

say I have an EntityManager that can read(PK) a dataset from the DB and return it.

I have an application that will process multiple records, iterate over them and for each, use the EntityManager to read each record.

Therefore it would be nice to inform that EntityManager about the coming workload so it is able to preload the necessary data more efficiently.

How would you integrate such optional hints into a clean, SoC OO-Design?

Thanks alot

2

1 Answer 1

1

I think it's not responsibility of EntityManager (ActiveRecord object I guess) to care about workload.
Add another object, which will preload entities to the cache storage in case of coming workload, then add class EntityManagerCached which will override method read() to check cache storage first and then read from DB.

Words like "manager" in the class name is a warning sign.

1
  • Thank you, especially for the manager-warning. However, an ActiveRecord should be the record itself with CRUD-methods etc, isn't it?
    – hotzen
    Mar 20, 2013 at 9:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.