开发者

How much should an application know about its database? [closed]

Closed. This question is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 11 years ago.

Improve this question

I'm building a message service for an application. Users are identified by an email address and uid. Uid is also used as the primary key for the user table. I find it faster and simpler to allow my application to see and use that UID than to work with the user's email address.

Does it matter that my application knows something about the database's design ? This is a specific example, but I mean the question as a generalization... how much knowledge is 'to开发者_运维知识库o much' when it comes to information sharing between an application and its database ?

I'm asking mostly from the perspective of what would be considered 'good design'. I'm not quite sure how to tag this, suggestions appreciated.


Your application and service layer should abstract your data into a "domain" object used throughout your application(s). Only the data layer, which handles data retrieval and storage, should know the full database design; and it does need to know this information to properly query and store data.

Follow a standard layered approach to your application development - there are many books written on layered architecture.


I think it depends on whether you plan to have this application scale beyond the use of this specific database. I think there comes a point where over-generalization makes the code more complex than it needs to be (and likely less efficient). You need to find a balance, and that will likely depend on the planned future of the application. Obviously, my answer is completely subjective.


It's all depend on how you find your Application needs.

One of good design is Seperate your codes onto layers to make your codes reusable.

Ntier : UI <-- BusinessLogiclayer <--DataAccessLayer.

MVC : Model <--- View <--- Controller.

Something like you can call your domain/DataAccesslayer anytime in your ui because it is just in one class.

Make Sure that your Database is also Normalize/De Normalize and be familiar with it so you should see what is the best approach you needed in your application.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜