public class LoginController
{
// The view interface for manipulating the user interface.
ILoginView view;
public LoginController(ILoginView view)
{
this.view = view;
SubscriveToEvents();
}
private void SubscriveToEvents()
{
view.OnLogin += OnLogin;
}
public void OnLogin(object sender, EventArgs e)
{
if (Login(view.userName, view.password))
{
view.LoginSuccessful();
}
}
}
And in your view you will simply implement the login successful method (don't forget to add it to the interface). This means that the business rules for navigation are actully sitting in your view layer, however if you use a navigation framework they will be well encapsulated and simple to read and understand.
I have not done any investigation into which framework would be appropriate for my project, if we choose to go with MVP then this will have to be done and I'll blog that too, but in the mean time have a look at the Spring.NET libraries and PageMethods.
Showing posts with label MVP. Show all posts
Showing posts with label MVP. Show all posts
Wednesday, 17 September 2008
Navigation within MVP
I've been doing a lot of research into various frameworks so I can make an informed decision on my new application I'm developing. In evaluating MVP, ASP.NET MVC and the traditional three tiered approach I came across a question that I found it difficult to find informaton on.
How should navigation be handled in a MVP ASP.NET application and who should handle it?
Well the answer to the first question was easy, any way you like. You could use Spring.NET libraries, PageMethods, write your own, Response.Redirect, it doesn't matter and MVP doesn't prescribe any of the above. But the question that was more important is who should handle it?
I found a great article on CodeProject on Model View Presenter implementation that was very useful. The article points out that a navigation raised through the presenter should be raised in the View via an event.
So in a simple example if you have a login form your presenter might look like this:
Monday, 15 September 2008
Application Framework Choices - ASP.NET
So I was going to blog about some of the stuff that went down at TechEd, and while that'd be fun every man and his dog who was there has something to say. For me one of the mail purposes of attending tech.ed was to get some information about emerging and existing frameworks that exist around the .NET web development sphere.
For me there are a few choices that fit the requirements of our new application that we're developing here.
1. ASP.NET MVC
2. ASP.NET with the MVP pattern
3. Standard 3 Tier Architecture
What am I looking for?
I'm looking for a few things, with the large number of developers and the multiple team setup that we'll be using for this project there are a few things that would make life simpler to manage. In particulare the structure of the framework we choose is very important.
Enforced Seperation of Concerns
This is the ability for the framework we choose to force the developer to seperate the model, view and controller concerns. The benefits include more testable code, more re-usable code and more understandable code. Often the seperation of concerns is not enforced allowing the developer to code business rules into the view should they see fit, with the large team we are putting together I would consider this a disadvantage.
Simplicity
The chosen framework should ideally be simple. A complex framework will either add complexity to the code or add significant developer time to setup the framework for each process.
Readable
Too often overlooked, the application code implementing the business rules and interface should be as readable as possible. A framework that forces developers to make non-standard calls, constantly serialise or lose track of the call stack will make develop far more difficult than I would like in a large team of varying levels of expertise.
Efficient
Any processing overhead is a large negative.
Robust
A proven robust framework will ease the business' concerns when pitching the application architecture.
Supported
There's nothing worse than choosing a framework only to find that before the product is released it is no longer supported. Any choice made when considering the framework must consider the chance that the technology may become redundant.
Productive use of Namespaces
There will be an obscene amount of code requirement to complete this project. The last thing we need is to have to sift through the code to find the class we need. The framework would ideally support seperation of the code into production namespaces that will assist in identifying issues and building structure.
Proven
A technology that's proven in the industry will help alleviate concerns that the framework may not be able to fill all of our business needs.
Fast Development Time
Just like every other project, ever, our project has tight time constraints. The faster we can build code in the framework the better, but not at the risk of the attributes above.
Testable
We are using TDD as our testing framework for our project, whatever design framework we choose it should be as testable as possible so that we can cover as much of our code as possible.
ASP.NET MVC
This is a new technology currently in technical preview 5 with the beta release to come out soon. That in itself is a large risk, however a collegue of mine mentioned that the world is in perpetual beta and soon after release a technology is likely to become redundant. Scott Hanselman mentioned at his tech.ed talk that there is no such thing as a professional developer, we're all ametures. With the constant release of technology I don't believe it would be a good idea to discount a technology just because it's new.
After the session on architectural considerations for the ASP.NET framework with Tatham Oddie I had some time to speak to him breifly about considering the ASP.NET MVC framework for a large production applicaiton. His response was that the project is very mature and definately worth considering as production ready.
Benefits
- Enforced seperation of concerns
- Simplicity
- Readable
- Supported
- Efficient
- Fast Development Time
- Testable
- Robust
- Productive use of Namespaces
- Proven
- Seperation of Concerns (not enforced)
- Readable
- Efficient
- Robust
- Supported
- Productive Use of Namespaces
- Proven
- Testable
- Enforced Seperation of Concerns
- Fast Development Time
- Simplicity
- Efficient
- Simplicity
- Supported
- Productive Use of Namespaces
- Proven
- Fast Development Time
- Enforced Seperation of Concerns
- Readable
- Robust
- Testable
Subscribe to:
Posts (Atom)