473,779 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Separating presentation from data layer

Hi all... I could use a little TLC here for understanding and not for
solving a specific problem... sorry if I've got the wrong group, but I'm
using VB so I figured this was the most appropriate one.

I'm an advanced beginner, but in all of the books and class material I have,
I haven't found something that gets to the point about this... lot's of high
level theoretical talk, but nothing that says things in simple terms.

I'm building an app and want to separate the presentation and data "stuff".
Here's some background on the approach I want to take as I understand it:

In my VS project (an ASP.NET project), I've got 3 important things:

1) Submit.aspx -- this is the presentation "thing". It contains mostly
just web controls. Textboxes, a DateTime control (from a vendor), labels,
and a submit button. For example purposes, let's say the fields are:
FullName, PhoneNumber, DOB.

2) DataLayer.vb -- this is my "data" stuff. It contains a class called
"User" that is a model of the data in my form. So, there are read/write
properties for FullName, PhoneNumber and DOB. Also, there's a method called
"SaveToDB" that does exactly that--- opens a database connection and Inserts
the data into a table.

3) Submit.aspx.vb -- The code-behind for Submit.aspx... there's an event
handler here for the Submit button that:

- instantiates an object based on the User class
- sets the properties of this object using values from the web controls
- calls the SaveToDB method on that object to write the values to the
Database.

My questions are:

1) I might also like to write a couple of other classes, possibly to handle
validity... is it appropriate for me to write them in the DataLayer.Vb? My
confusion is because in Visual Studio, when I add a new item, it refers to
it as a "Class"... is this only supposed to contain ONE class?

2) Is this approach reasonable--- I know this is a small app... just an
example, but if it were a lot bigger (i.e. more controls on the form, more
fields, etc), would this be the right approach? If not, what am I doing
wrong?

3) In an app like this, where you are submitting information in a form, is
it better to postback and hide the form to display success, or is it
considered better practice to submit to a second page and have that page
call my data layer?

Thank you in advance for your time...

Michelle
Nov 23 '05 #1
13 2538
Michelle,

As this is a general approach question, here some general answers.

A dotNet webapplication with data is basicly direct starting a 3 tier
application.

Tier 3
The page (aspx), that is from the middle tier generated HTML page which is
processed by the webbrowser of the client and which communitace with your
database.

Tier 2
The DLL, that is created for handling the request and answers and is for all
users at the same time active

Tier 1
Your database.

You are in fact all the time in dotNet webdevelopment busy with Tier 2. The
client tier is generated from that while the database exist.

If you are building the application (the DLL), than you should in my opinion
be stupid not to do what you say.

Create all database access in a seperated components (classes) for this (and
add than the item component to your IDE for this.

However be aware that all data in that class if you set it shared, will be
shared by all users.

Therefore I would make in your situation at least two (data) classes.

One to share all non updatable date (addressbooks, article lists, etc) by
all clients, without consequently updating.

One (or more) to use as a helper class, to use for all your database
handling. That one you have to create every time as new object from this
class in the UI's that it uses. This because the data of a handled web page
will go completly out of scoop if the generated page is (again) sent to the
client. (A webform is not persistent)

I hope this gives some idea.

Cor

Nov 23 '05 #2
Cor:

Thanks for taking the time...

Can you explain your last 2 paragraphs?--- it's unclear to me what you're
suggesting. Do you mean one class file (eg: readData.vb) that does just
read operations from the database, and one class file (eg: updateData.vb)
that handles only Insert, Delete and Update operations?

Thanks,
Michelle

"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:uB******** ******@tk2msftn gp13.phx.gbl...
Michelle,

As this is a general approach question, here some general answers.

A dotNet webapplication with data is basicly direct starting a 3 tier
application.

Tier 3
The page (aspx), that is from the middle tier generated HTML page which is
processed by the webbrowser of the client and which communitace with your
database.

Tier 2
The DLL, that is created for handling the request and answers and is for
all users at the same time active

Tier 1
Your database.

You are in fact all the time in dotNet webdevelopment busy with Tier 2.
The client tier is generated from that while the database exist.

If you are building the application (the DLL), than you should in my
opinion be stupid not to do what you say.

Create all database access in a seperated components (classes) for this
(and add than the item component to your IDE for this.

However be aware that all data in that class if you set it shared, will be
shared by all users.

Therefore I would make in your situation at least two (data) classes.

One to share all non updatable date (addressbooks, article lists, etc) by
all clients, without consequently updating.

One (or more) to use as a helper class, to use for all your database
handling. That one you have to create every time as new object from this
class in the UI's that it uses. This because the data of a handled web
page will go completly out of scoop if the generated page is (again) sent
to the client. (A webform is not persistent)

I hope this gives some idea.

Cor

Nov 23 '05 #3
Michelle,

No one of the actions is to create a shared class for all your consistent
data you use in your pages. Than you can do that one time.

Just ask in the creation of that ( if a datasource is nothing)

Than your pages have only to load that data in memory once

You cannot use that in data that has to be updated (or it should be in a
very difficult way).

The objects from that will you have to be created everytime new at pageload.

I suggest you to use seperated classes for those.

I hope that this gives an idea

Cor
Nov 23 '05 #4
Previous was at least for me unreadable

No one of the actions is to create a shared class for all your consistent
data you use in your pages. Than you can do that one time.

Just ask in the creation of that ( if a datasource is nothing)

No, one of the classes is for the handling of all your consistent data,
that you use in your pages. Than you can do that one time. To prevent all
the time reading. Because that if all sessions are stopped, than it closes,
you can just ask in the creation of that if a datasource is nothing and
than do all handling to get the data again. (Be aware that if it is real
active you have to time by time to close by hand, a simple aspx page can do
this job)

The other one is than for regular client data handling, or you create more,
however don't splits the reading and updating, I will earlier do that for
the different datasets that be used

I hope this gives an idea

Cor

Nov 23 '05 #5
Cor... thanks... I think I'm understanding. Let me answer my questions
based on what I understand from your words:
1) I might also like to write a couple of other classes, possibly to
handle validity... is it appropriate for me to write them in the
DataLayer.V b? My confusion is because in Visual Studio, when I add a new
item, it refers to it as a "Class"... is this only supposed to contain ONE
class?
Not only is it acceptable to have more than one class in a Class file,
it is a sensible approach.
2) Is this approach reasonable--- I know this is a small app... just an
example, but if it were a lot bigger (i.e. more controls on the form, more
fields, etc), would this be the right approach? If not, what am I doing
wrong?
Creating separate classes to handle data operations is a reasonable
approach, and considering the example, it may be beneficial to have more
than one class to handle data: One that performs read operations and
possibly even caches information in the session object, and a three others
that handle Insert, Update, and Delete operations -- these classes should
handle the connection to the database as well (separating that operation
from the PageLoad event).
3) In an app like this, where you are submitting information in a form,
is it better to postback and hide the form to display success, or is it
considered better practice to submit to a second page and have that page
call my data layer?

No answer provided yet.
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:%2******** *******@TK2MSFT NGP15.phx.gbl.. . Previous was at least for me unreadable

No one of the actions is to create a shared class for all your consistent
data you use in your pages. Than you can do that one time.

Just ask in the creation of that ( if a datasource is nothing)

No, one of the classes is for the handling of all your consistent data,
that you use in your pages. Than you can do that one time. To prevent all
the time reading. Because that if all sessions are stopped, than it
closes, you can just ask in the creation of that if a datasource is
nothing and than do all handling to get the data again. (Be aware that if
it is real active you have to time by time to close by hand, a simple aspx
page can do this job)

The other one is than for regular client data handling, or you create
more, however don't splits the reading and updating, I will earlier do
that for the different datasets that be used

I hope this gives an idea

Cor


Nov 23 '05 #6

"Michelle" <Nope> wrote in message
news:e$******** ******@TK2MSFTN GP10.phx.gbl...
1) I might also like to write a couple of other classes, possibly to
handle validity... is it appropriate for me to write them in the
DataLayer.Vb ? My confusion is because in Visual Studio, when I add a new
item, it refers to it as a "Class"... is this only supposed to contain
ONE class?


Not only is it acceptable to have more than one class in a Class file,
it is a sensible approach.


Jumping into the middle of this, sorry.

You can have more then one class inside a *.vb file. But most (by most I
mean me) don't do this. It adds a layer of confusion.

IMO
Greg
Nov 23 '05 #7
Michelle,

The only thing I will add is use a component (which you can add from your
solution explorer as item) for your dataclasses. That component has all
build in for disposing etc. It seperate directly your data from your pages
(I will not call it here UI, because it is not the UI, it is a kind of
middle tier) Although the DLL is one so it is in fact all the time in one
application.

I hope this is enough for today? :-)

Although be free to ask again as you have all thought over, this newsgroup
is not closing you know

:-)

But I hope as well that it helps

Cor
Nov 23 '05 #8
Reading Gregs post.

For every class another component, otherwise it has no sense at all (while I
completely agree what Greg wrote)

Cor

"Cor Ligthert [MVP]" <no************ @planet.nl> schreef in bericht
news:uR******** ******@TK2MSFTN GP15.phx.gbl...
Michelle,

The only thing I will add is use a component (which you can add from your
solution explorer as item) for your dataclasses. That component has all
build in for disposing etc. It seperate directly your data from your pages
(I will not call it here UI, because it is not the UI, it is a kind of
middle tier) Although the DLL is one so it is in fact all the time in one
application.

I hope this is enough for today? :-)

Although be free to ask again as you have all thought over, this newsgroup
is not closing you know

:-)

But I hope as well that it helps

Cor

Nov 23 '05 #9
Any thoughts on the third question: -- In an app like this, where you are
submitting information in a form, is
it better to postback to the same form "on submit" and hide the form
elements (eg: in a panel perhaps) to display success, or is it considered
better practice to submit to a second page and have that page
call the data layer?

Thanks,

M

"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:O5******** ******@TK2MSFTN GP09.phx.gbl...
Reading Gregs post.

For every class another component, otherwise it has no sense at all (while
I completely agree what Greg wrote)

Cor

"Cor Ligthert [MVP]" <no************ @planet.nl> schreef in bericht
news:uR******** ******@TK2MSFTN GP15.phx.gbl...
Michelle,

The only thing I will add is use a component (which you can add from your
solution explorer as item) for your dataclasses. That component has all
build in for disposing etc. It seperate directly your data from your
pages (I will not call it here UI, because it is not the UI, it is a kind
of middle tier) Although the DLL is one so it is in fact all the time in
one application.

I hope this is enough for today? :-)

Although be free to ask again as you have all thought over, this
newsgroup is not closing you know

:-)

But I hope as well that it helps

Cor


Nov 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
9113
by: Michael Rodriguez | last post by:
I have a windows form that makes a call to my BLL to get some data. The windows form has a progress bar component that I would like updated as the data retrieval takes place. However, strictly speaking, the BLL is not supposed to know anything about the presentation layer. Also, since the presentation layer has a reference to the BLL, it won't let me add a reference to the presentation layer from the BLL, it complains about a "circular...
5
1689
by: Learner | last post by:
Hi there, I am just trying to set up 3 tier architecture. When i add my Datalayer project to the Business layer project the methods are exposed to in my business class. But in the similar way when i add the Businesss layer project to my presentation i don't see the methods of BL exposing in my presentation layer. But i see the namspace and also the class of my business class but i don't see the methods! is there any thing i am missing...
8
1810
by: Jeff S | last post by:
Please note that this question is NOT about any particular pattern - but about the general objective of separating out presentation logic from everything else. I'm trying to "get a grip" on some of the patterns (e.g., Model View Presenter) or strategies for separating UI logic from the underlying business rules and data. As I understand it, the general intent of doing this is to reduce dependencies amongst our classes in order to make...
5
1562
by: Ronald S. Cook | last post by:
We have a Windows app which contains UI code and all classes that perform business logic and make calls to database stored procs (located on a database server - i.e. not local to the app). My boss wants to bring all those classes to a business server and out of each instance of the Windows application (i.e. separate into a business tier). I understand that by having the business tier separate from the user tier, we can make changes...
1
1616
by: rbg | last post by:
Hi, I am trying to understand the layering concept with the ASP.NET 2.0 apps. I have a ASP.NET 2.0 Web app which has 3 layers Presentation layer which contains UI elements and Input validation logic
2
1932
by: Ily | last post by:
Hi all I am using Visual studio 2005. Im my project I have a presentation layer, a business layer and a data access layer. From my business layer i have a reference to my data layer. I also have a refeence to my business layer from my presentation layer. Now the weird thing is, I can create a form, and I can add a using
6
14154
by: Dhananjay | last post by:
hello everyone i have got a problem i want to design business layer, data access layer , presentation layer for asp.net using C#.net , can anyone help me to solve this problem. i want some resources to complete this. i am trying very hard. Do you have any idea about website or any links where i can find some examples based on this concept.can you plz provide me , its urgent i want this solution with an example, if u have plz provide me. ...
1
1444
by: | last post by:
I'm querying Index Server to return search results, both regular properties and some custom properties I've created. Index Server has this preference for thinking about information as strings rather than datatypes.If you really work at it, you can configure Index Server to treat the data as, say, sortable DateTime datatypes, or integer datatypes. But I'm finding this a huge pain in the butt, and it bothers me that I'm attaching a bunch of...
1
1545
by: Clark Simpson | last post by:
Hi, Apologies if this is such a simple query but if I have an ASP/.NET Application which I normally access via www.foo.com/myapp on Machine A can I access this application layer machine via a Presentation Layer Machine B via www.mypresentationlayer.com/myapp? In a nutshell I want users to access Machine B on the front end (web) but behind the scenes the actual requests are routed to Machine A. Anyone?
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10306
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10139
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9931
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8961
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6727
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5504
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.