Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The whole idea behind layering an application is that each layer does not depend on implementation details of the layer(s) below. For example, in your code you have a T-SQL statement inside your presentation layer. This means you have a direct dependency of your presentation layer on your database (the bottom layer). If you make a change in your database, you must also make a change in your presentation layer. Ideally this is not what you want. The presentation layer should only be concerned about presenting data, not about how to retrieve it. Suppose you move your whole database into CSV files (I know, crazy idea), then your presentation layer should not be aware of this at all.</p> <p>So ideally, you have a business layer method that returns just the data you want to show to the user. You should take a look at <a href="http://msdn.microsoft.com/en-us/library/9a4kyhcx.aspx" rel="nofollow noreferrer"><code>ObjectDataSource</code></a> instead of <code>SqlDataSource</code>. <code>SqlDataSource</code> is nice for small prototyping projects, but you should not use it for any more serious projects.</p> <p>Between business layer and data layer you should have a similar separation. The data layer is responsible for getting the data you want from some storage location (database, CSV file, web service, ...). Again, ideally, the business layer should not depend on the implementation details of the data layer. If you're talking to SQL Server for example, you should not return a <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.aspx" rel="nofollow noreferrer"><code>SqlDataReader</code></a> instance to your business layer. By doing this you create a dependency of your business layer on an implementation detail of your data layer: the actual database it is retrieving it's data from.</p> <p>In practice you see that the business layer does depend on implementation details of the data layer in some way or another and usually that's not a bad thing. When was the last time you decided to switch databases? But eliminating dependencies and isolating implementation details as much as possible almost always results in an application that's easier to maintain and understand.</p> <p>You can find a similar explanation <a href="https://stackoverflow.com/questions/661530/layering-a-wcf-service-the-right-way/662527#662527">here</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload