tags:

views:

172

answers:

1

I've been using AppFuse to create my projects for a while now. And I'm already aware that there are two approaches to developing your DAO and Manager classes:

  1. GenericDao/GenericManager approach
  2. UniversalDao/UniversalManager approach

I often find that using the Universal approach to be more convenient, because I just need one class to manage all entities. Thou I always wondered if design-wise this would be a very bad choice.

Is there a reason why I should prefer the Generic variant? And generally, would It be advisable to mix both classes in my application?

A: 

I personally prefer using UniversalDao/UniversalManager, for a couple of reasons:

  • "Generic" approach generally involves a lot more configuration: you must configure a DAO and a Manager for each entity. For a medium-large model this is just unacceptable;
  • with "Generic" approach you still have to do a lot of casting. For example with Hibernate, you will end up doing a lot of downcasting , e.g, from List< Object> to List< MyDomainClass>
  • with Universal you can create a more flexible DAO that manages many (not only one) model classes, for example a OrderDAO that manages Orders, Items and Categories.

And of course, never mix the two approaches! It can be easily done, but in any project uniformity is a great virtue ;)

Megadix