Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been studying n-tier architectures as of late, particularly in VB.NET with Entity Framework and/or LINQ to SQL. I understand the basic concepts, but have been wondering about best practices in regard to triggering CRUD-type operations from user input/action. So, the arcitecture looks something like the following:

[presentation layer] -> [business layer] -> [data layer] -> (database)

Getting information from the database into the presentation layer is simple and abstracted. It's just a matter of instantiating a new object from the business layer, which in turn uses the data layer to get at the correct information. However, saving (updating and inserting), and deleting seem to require particular APIs on the relevant business objects. I have to assume this is standard practice, unless a business object will save itself on various operations (which seems inefficient), or on disposal (which seems like it just wouldn't work, or may be unwieldy and unreliable).

Should my "savable" business objects all implement a particular "ISavable" or "IDatabaseObject" interface? Is this a recognized (anti-)pattern? Are there other, better patterns I should be using that I'm just unaware of?

The TLDR question, I suppose, is How does the presentation layer trigger database changes?

share|improve this question
up vote 5 down vote accepted

How does the presentation layer trigger database changes?

Well, presentation layer should not directly trigger changes in database layer. It should initiate call to the service layer, where your business logic should verify the request. Upon successful verification it should perform DB operation on entities/tables that it needs.

You may also look at this very useful pattern - Repository Pattern that may associate a behavior with the related data.

share|improve this answer
Right. So, all my business-layer classes should implement some sort of save method? – Ryan Kinal Sep 28 '12 at 19:19
You may say like that, actually all your entities should have CRUD operations on them. You may use Repository pattern to easy your operations as well. Link is provided. – Yusubov Sep 28 '12 at 19:21
That makes a lot of sense. I like it. – Ryan Kinal Sep 28 '12 at 19:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.