• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about MVC architecture having database access

 
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Generally, Request comes to controller, call the service layer and database access part and come back to view.

Do you guys call database queries right from service layer or you have one more layer for DB access? If you have DB access layer, what is the benefit? What type of decoupling does it provide?

 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Saurabh Pillai wrote:
Do you guys call database queries right from service layer or you have one more layer for DB access? If you have DB access layer, what is the benefit? What type of decoupling does it provide?



You should have another data access layer. That's what the M stands for in MVC.

There are 2 important purposes in my view

1) Decoupling : As you mentioned, its important to separate areas of concern so that maintainability is easy. In case there are newer queries to be added, current queries to be modified, there is an upgrade in the db technology itself(say from MSSQL Server to Oracle), the service layer does not need to know anything. The service layer will be content calling a few methods in the data access layer and that is it.

2) Testing : Unit testing would be much easier. You can test the methods in data access layer without dependence on service program and make sure that from the basic query level you dont have any error in the system.

Thanks,
Praveen.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic