473,511 Members | 16,983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Model-View-Controller implementation question in .NET

Two questions really, the first one "conceptual" and the other more involved
with design:

1 - There are two schools of thought where I work on the role of the
"controller" task.

The first is that the business object will provide the business rules and
that the controller will implement the rules and then pass the result set to
the view (i.e. do most of the grunt work).

So for example, the business object may have two methods. The first one
provides a list of menu items and the second provides a list of who can see
what. The controller then prunes the list of menu items down to those that
can be accessed by the particular user and passes the result to the view.

The second is that the business object has one method that gives the menu
items that the end user can see and the controller simply passes this to the
view. (i.e. the BO does most of the grunt work and the controller just has
the logic of knowing where to get this data and where to send it - i.e.,to
the view).

Personally, I subscribe to the second one. The reason is that if I have one
BO that happens to be consumed by n controllers, then I don't want to
replicate the implementation of the business rules n times, just the once.

However, what is the general consensus of opinion?

2 - I've just read in an article "MVC infrastructure that doesn't harm
ASP.NET mechanism" that implementing the MVC pattern isn't truly compatible
with the ASP.NET 2.0 framework: http://www.codeproject.com/aspnet/NWAF.asp

Do people concur with this?

If so, what advice can people give me? I've got to re-write a CLASSIC ASP
eCommerce application that is not that complicated a site in terms of the
number of pages etc, but it does have a heavy load (it's a B2B system with ~
3/4 million users)

Thanks in advance

Griff
Jan 26 '06 #1
4 1914
The idea behind MVC is that the Data (Model) is hidden from the outside
world. That way if it changes, or how you implement it changes, the outside
world does not care/know. The Controller (API) is what the outside world
uses to gain access to the data but in a non-data-implementation-specific
format (ie. you dont want to return a Collection because later on you may
change to use a fixed array of objects instead.)

Example:
A class that keeps track of people. The person calling the controller has no
idea that the Model uses collections to keep track of data, or that there
are 2 different collections in use (one for age and one for name). If I
decide to change how I store the data later on (maybe I will store the data
in a database instead of in memory) the outside world would not have to
change how they access the Controller because the API they are using does
not change.

public class Controller
{
private Model m_model;

public int Count
{
{ get m_model.m_names.Count; }
}

public string GetName(int index)
{
return (string)m_model.m_names[index];
}

public int GetAge(int index)
{
return (int)m_model.m_ages[index];
}

public itn AddPerson(string name, int age)
{
m_model.m_names.Add(name);
m_model.m_names.Add(age);
}
}

public class Model
{
public ArrayList m_names;
public ArrayList m_ages;
}

Hope this helps!

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Charles Cox
VC/VB/C# Developer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"Griff" <Ho*****@The.Moon> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Two questions really, the first one "conceptual" and the other more
involved with design:

1 - There are two schools of thought where I work on the role of the
"controller" task.

The first is that the business object will provide the business rules and
that the controller will implement the rules and then pass the result set
to the view (i.e. do most of the grunt work).

So for example, the business object may have two methods. The first one
provides a list of menu items and the second provides a list of who can
see what. The controller then prunes the list of menu items down to those
that can be accessed by the particular user and passes the result to the
view.

The second is that the business object has one method that gives the menu
items that the end user can see and the controller simply passes this to
the view. (i.e. the BO does most of the grunt work and the controller
just has the logic of knowing where to get this data and where to send
it - i.e.,to the view).

Personally, I subscribe to the second one. The reason is that if I have
one BO that happens to be consumed by n controllers, then I don't want to
replicate the implementation of the business rules n times, just the once.

However, what is the general consensus of opinion?

2 - I've just read in an article "MVC infrastructure that doesn't harm
ASP.NET mechanism" that implementing the MVC pattern isn't truly
compatible with the ASP.NET 2.0 framework:
http://www.codeproject.com/aspnet/NWAF.asp

Do people concur with this?

If so, what advice can people give me? I've got to re-write a CLASSIC ASP
eCommerce application that is not that complicated a site in terms of the
number of pages etc, but it does have a heavy load (it's a B2B system with
~ 3/4 million users)

Thanks in advance

Griff

Jan 26 '06 #2
Hi Charles

Great simple example - thanks.

Just extending it a little....if you wanted to add a business rule to say
that a particular end user can NOT add users, then should you add this
business logic to the controller or should you incorporate it in the model
class?

I'm guessing that the Model is not just data but business rules too? Am I
wrong?

If I'm right then you'd have to call a method on the model class that adds
the new user to a PRIVATE array and this method has an additional argument
to say who is trying to add the new user and use a business rule to decide
whether or not the new user should be added.

Thanks

Griff
Jan 26 '06 #3
I guess it depends on the situation and implementation of the particular
system. Take the following scenario as an example of what I mean.

You have a backend system (database) that has 2 different front ends (web
and desktop application). Now, the Web side you only want to allow Queries
to be done but the desktop app. can add/delete/etc. Both of the front ends
could use the same Model but use different Controllers to access it. The
business logic in this setup would probably be in the Controller since it
would be different between the two front ends. You would use two different
controllers as a security measure so that no matter what the Web front end
does not even have the "code" (Controller) to perform add/delete/etc.

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Charles Cox
VC/VB/C# Developer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"Griff" <Ho*****@The.Moon> wrote in message
news:uA**************@TK2MSFTNGP12.phx.gbl...
Hi Charles

Great simple example - thanks.

Just extending it a little....if you wanted to add a business rule to say
that a particular end user can NOT add users, then should you add this
business logic to the controller or should you incorporate it in the model
class?

I'm guessing that the Model is not just data but business rules too? Am I
wrong?

If I'm right then you'd have to call a method on the model class that adds
the new user to a PRIVATE array and this method has an additional argument
to say who is trying to add the new user and use a business rule to decide
whether or not the new user should be added.

Thanks

Griff

Jan 26 '06 #4
CC - thanks!

Griff
Jan 26 '06 #5

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

Similar topics

0
2133
by: Flare | last post by:
Hi I tring to implement a model 2 architecture in a new test JSP site for my own training. I read this article...
1
3327
by: Abhijit | last post by:
I am working in a data warehousing environment which gets sourced from Oracle ERP (AR/GL/AP). The dimensional entities associated with incoming data are GL Code (e.g. 110), Department (e.g. 1050),...
10
7117
by: Michael Strorm | last post by:
Hi! I've been having problems with a DTD. Having had the Sun XML validator reject a document, I put it through 'xmllint' for more information. 'Xmllint' noted a problem with the DTD itself;...
4
7049
by: Davíð Þórisson | last post by:
Hi, when I was programmin ASP/JScript I had a very nice utilitiy which I got from MSDN (Script56.CHM). It's simply a help file but containing object orientiated documentation of all scripting...
5
2236
by: clintonG | last post by:
I'm looking for documentation and would not turn my nose up to any code from anybody who thinks they are good at the design of an algorythm that can be used to generated a hierarchical relational...
5
2117
by: Kevin C | last post by:
I was curious to know what some developers out in the industry are doing when it comes to exposing Data access logic, specifically persistence. This is assuming that your not using an O/R framework...
1
3328
by: Earl Teigrob | last post by:
Background: When I create a ASP.NET control (User or custom), it often requires security to be set for certain functionality with the control. For example, a news release user control that is...
122
7210
by: Edward Diener No Spam | last post by:
The definition of a component model I use below is a class which allows properties, methods, and events in a structured way which can be recognized, usually through some form of introspection...
23
3114
by: tonytech08 | last post by:
What I like about the C++ object model: that the data portion of the class IS the object (dereferencing an object gets you the data of a POD object). What I don't like about the C++ object...
3
2443
by: Andy B | last post by:
I have about 12 services that will be used on the website I am working on. A few of them are News, Events, Venues (that work directly with Events), Mailing lists and some others. Each one of these...
0
7356
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,...
0
7427
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...
1
7085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5671
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,...
1
5069
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...
0
4741
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...
0
3227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1577
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
449
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.