I have 2 entities: book and category when each book can have reference to its category, and the classical 3 tier architecture: presentation, business logic and DAO tier.
My question is how to implement BookDao.getAll() in terms of dependencies instantiation. Should I instantiate the category object each time for each book (sounds like a RAM wasting), of course I can create and reuse the same category objects inside the getAll(). For example I have 15 books equally divided into 3 category, so I instantiate only 3 redundant objects not 15. Nevertheless my problem is that I already have all those 3 categories in my business tier, it's a bad design decision to pass a reference on the categories collection to the method, because DAO mustn't call business. And I don't know how to avoid performance problems and Java Heap wasting on this categories if the app will scale to 250,000,000 books for example.
Aucun commentaire:
Enregistrer un commentaire