views:

88

answers:

2

I've just taken on a new Asp.Net MVC application and after opening it up I find the following,

  1. [Project].Web
  2. [Project].Models
  3. [Project].BLL
  4. [Project].DAL

Now, something thats become clear is that there is the data has to do a hell of a lot before it makes it to the View (Database>DAL>Repo>BLL>ConvertToModel>Controller>View). The DAL is Subsonic, the repositorys in the DAL return the subsonic entities to the BLL which process them does crazy things and converts them into a Model (From the .Models) sometimes with classes that look like this

public DataModel GetDataModel(EntityObject Src)
{
    var ReturnData = new DataModel():
    ReturnData.ID = Src.ID;
    ReturnDate.Name = Src.Name;

    //etc etc
}

Now, the question is, "Is this complete overkill"? Ok the project is of a decent size and can only get bigger but is it worth carrying on with all this? I dont want to use AutoMapper as it just seems like it makes the complication worse. Can anyone shed any light on this?

+3  A: 

First, I think your reluctance to use AutoMapper is surprisingly illogical. I can see reasons not to bring in another third party library, but in this case AutoMapper really doesn't complicate things, as long as you hook it up correctly and in the right places (i.e. only one place...).

Secondly, the entire ASP.NET MVC Framework emerged from a wish to enable developers to build loosely coupled, scalable and "pluggable" applications. This does mean more work to do the same thing if you're going to choose one path and then go down that path, that's right. But as soon as you make a decision to change something - perhaps you decide to move from Subsonic to some other provider, or to use AutoMapper after all - you'll notice that you only have to re-write relevant parts of your application, instead of the entire thing.
(I'm not saying you have to rewrite a WebForms application from scratch if you for example switch database engine, but you'll have to look through almost all application code to update relevant parts of the code, if you haven't worked hard enough on decoupling. In which case you're not saving any work by choosing WebForms over MVC...)

In short: Yes, this means more work for you than just "hacking something together". And it does look more complicated than may seem necessary. But as soon as you start changing your mind about something (and you will) you'll praise your lucky star that you did it "the right way"* from the beginning.

*) There's no such thing. I know.

Tomas Lycken
+3  A: 
Joel Coehoorn