Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 28th, 2012, 01:34 PM
Friend of Wrox
Points: 550, Level: 8
Points: 550, Level: 8 Points: 550, Level: 8 Points: 550, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 113
Thanks: 31
Thanked 2 Times in 2 Posts
Default n-layered architecture

Hello:

I am a little confused about the ASP.Net web form and the presentation layer.

The .aspx file is considered part of the presentation layer because it contains all the layout and formatting. But what about the Code Behind? This can contain business logic such as validations and other rules. What layer is the Code Behind part of?

Thank you.

Tulsi
Reply With Quote
  #2 (permalink)  
Old March 28th, 2012, 02:00 PM
Imar's Avatar
Wrox Author
Points: 67,100, Level: 100
Points: 67,100, Level: 100 Points: 67,100, Level: 100 Points: 67,100, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,202
Thanks: 65
Thanked 1,405 Times in 1,385 Posts
Default

Hi Tulsi,

That's one of the problems with web forms and code behind. It could be anything depending on the code you write. If you use

myControl.BackgroundColor = Color.Blue;

it's the presentation layer. If you calculate a discount based on the number of items the customer has in his cart, it's business logic. If you set up a SqlConnection object and access the database, it's the data access layer.

In general, you should strive to write as little code in Code Behind and instead delegate to the appropriate layer. This way, the Code Behind becomes more of an orchestrator / controller as in MVC.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #3 (permalink)  
Old March 29th, 2012, 02:30 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Haven't met that problem
Reply With Quote
  #4 (permalink)  
Old March 29th, 2012, 02:17 PM
Friend of Wrox
Points: 550, Level: 8
Points: 550, Level: 8 Points: 550, Level: 8 Points: 550, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 113
Thanks: 31
Thanked 2 Times in 2 Posts
Default

Imar,

Thank you for the explanation.

Tulsi
Reply With Quote
  #5 (permalink)  
Old November 6th, 2012, 02:13 PM
Friend of Wrox
Points: 550, Level: 8
Points: 550, Level: 8 Points: 550, Level: 8 Points: 550, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 113
Thanks: 31
Thanked 2 Times in 2 Posts
Default

Imar,

I just finished reading the chapter 14 and am surprised at how powerful the ADO.Net Entity Framework is and how easy it is to create presentation pages.

I was wondering how the ADO.Net Entity Framework fits in with n-layer architecture?

Where would you put business logic specific to the photo album or picture entities. For ex, there is logic on p. 519 that creates a new file name for the uploaded picture and determines the virtual location. Would I need to create 2 separate business objects and create two classes to represent the Picture and Photo album?

Thank you.
Tulsi
Reply With Quote
  #6 (permalink)  
Old November 6th, 2012, 04:33 PM
Imar's Avatar
Wrox Author
Points: 67,100, Level: 100
Points: 67,100, Level: 100 Points: 67,100, Level: 100 Points: 67,100, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,202
Thanks: 65
Thanked 1,405 Times in 1,385 Posts
Default

It depends on how you want to implement it. You could use the EF classes Picture and PhotoAlbum as your business entities and extend them (using partial classes) with additional functionality. However, that still ties them closely to the Entity Framework and thus to the database.

A common solution for this is to use EF Code First where you define your model classes first, and let EF handle database interaction. You then create repositories to handle stuff like getting items and updating them.

Google for EF Code First to learn a lot more.

I am working on an article series on N-Layered design using EF Code First. ETA: Unknown ;-)

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #7 (permalink)  
Old December 10th, 2012, 02:50 PM
Friend of Wrox
Points: 550, Level: 8
Points: 550, Level: 8 Points: 550, Level: 8 Points: 550, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 113
Thanks: 31
Thanked 2 Times in 2 Posts
Default

Thank you. Looking forward to the next series :)

Tulsi
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Layered architecture ajinkyaraj78 Visual Studio 2008 3 February 4th, 2011 01:55 AM
Developing Layered Applications ksouthworth BOOK: Professional ASP.NET Design Patterns 5 January 6th, 2011 04:24 PM
Layered/Tiered-Architecture complexity (AGAIN)... edurazee Visual Studio 2005 3 May 13th, 2009 02:51 PM
Layered/Tiered Architecture complexity... edurazee Visual Studio 2005 6 May 3rd, 2009 11:04 AM
Layered Applications Muhammad Zeeshan General .NET 5 July 25th, 2007 04:08 AM



All times are GMT -4. The time now is 08:28 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.