Design Pattern - ASP.net - asp.net

Need to design ASP.net pages which are mostly datadriven pages (read/write to sql tables)
through a interface.
This is mostly for maintence of job queues (to job on hold / delete from queue => which in turn is updating or deleting view.
What would be best Pattern to do with such maintence pages.
Thanks

If you're looking for a quick fix, you could try Dynamic Data.

While I do agree that a good solution for administrivia style sites such a the one you are describing is easily handled by Dynamic Data as #Robert Harvey has suggested this is not quite a direct answer to your question.
I think you really can't go wrong with using the ASP.NET MVC framework with some DDD concepts tossed in. This of course may be over architecting a small problem however let me suggest why I like it so much. With ASP.NET MVC you don't have any heavy obstacles to worry about ...just nice pure HTML. Form there following a good domain driven design you can quickly get some layers running. Plug in LINQ to SQL and you are off and running. With the MVC framework you can also easily make just about everything test driven which will help to keep the site maintainable over time.
I have written a whole series on DotNetSlackers regarding architectural concerns in ASP.NET MVC from a simple app all the way back to a complex distributed SOA style application. I have one more article (covering the SOA portion) to go to complete the series but there are many other articles in this mini-series that you could get started with.
Take a look at the "Three Tiers to MVC" section on this TOC of the bigger series
If this really is an admin site that you are creating though...do take a look at the Dynamic Data option. Very powerful!

Related

Is this a good architecture for my web application?

I am trying to make a website in ASP.NET MVC, but I am not really sure how I should organize things. N-Tier applications seem to work nice, but since I am a beginner programmer it is pretty hard to understand. I just want to create a small web application where people can login and create pages. In these pages they can add others things. The database won’t be bigger than 10 tables I think. Even though it is a small application, I would like to use some best practices that N-Tier applications use.
Is this a good approach? Or is it very wrong? :
Project.Models
Models that represent the entities in my database.
Project.DAL
Interfaces and implementations for my repositories and unit of work. Also my NHibernate mappings.
Project.BLL
Interfaces and implementations for my services.
Project.UI.Web.MVC
My controllers, viewmodels and views. The controllers get data from services and pass data (viewmodels) to views so I think it’s part of the UI.
There are no hard and fast rules about how to organise your project.
That looks pretty logical to me and seems to follow a lot of hte examples that i have seen across the internet.
All that matters is that its logical to you and your team in my opinion.
Take a look at this link as well, might be a lot of useful information for you there:
Best practices for MVC architecture
That sounds like a neat layering.
Define clearly on what goes in DAL, BLL and Web.MVC. Because people can have difference in opinion in what goes into business logic and ui logic, I suggest to have a weekly review of what has went into each layers - to start with.
One suggestion is to call Project.UI.Web instead of Project.UI.Web.MVC.

Integrating MVC and ASP.Net

I am starting a new project and was going to use it learn asp.net mvc.
But time is short and I won't have time to meet the requirements, learn mvc and end up with a well designed system. So I need to start with asp.net v4 and EF.
What sort of things should I do to allow an easy transition to MVC later?
I'd say the most important thing is the separation between business logic and presentation logic.
If you have a lot of business logic embedded on the aspx or on the code behind pages the transition will be harder.
Another thing that could complicate the transition is how intensively you use asp net web controls. If you can use independent UI controls from server side language (not everywhere of course, but as much as possible), things will be easier to migrate.
If you don't have time to meet the requirements, then you didn't give yourself enough time. If you are limited by time it's presumably because you are working for someone else, and you're constrained by their timetable and/or budget, so you need to build on what you know.
You should never blindly implement on a framework you don't know. You need to build time for prototyping, learn on your own, or pull in talent that already knows. If you are using a new framework and there is uncertainty, you should have enough time that you can cut after a certain point and rebuild in a way you do know you can do it.
You should also build on the best framework for the job -- there is no one-size-fits-all solution for any problem. What framework you choose should be based on the user requirements, technical/business limitations, projected growth and life (maintenance needs), and your available resources. Choosing is based on your personal past experience, and prototyping. If you don't have the experience and don't have time to prototype in at least a couple frameworks, you are in a bad spot right from the start.
That all said, I personally think ending up with a "well designed" system in WebForms is INCREDIBLY difficult, especially compared to doing it within MVC, and that in the ASP.NET space MVC is a much better framework in almost all situations than WebForms. I am biased and will outright say I think Webforms is fundamentally flawed in its philosophy; most of the code works as small examples but falls apart and becomes unmaintable as you grow, and even the example code from MS suffers this issue. But you should not use some random person on the internet's opinion as the basis for your design choices. I am just pointing this out because I want to be clear that I am not endorsing specifically WebForms, I am endorsing "use what you know" -- whether you "know" it from previously using or take time to learn it.

ASP.NET MVC3 Design Patterns and Proper Coding techniques

I recently worked at HP doing several ASP.NET MVC3 projects as I came from a software background I was relatively new to the inner workings of MVC3 as well as the best practices.
During this time I somewhat adapted the coding style of fellow co-workers and ways of designing my pages that I still stick with to this day. With all of this in mind my main question is what would anyone recommend for learning material; books/videos/tutorials. I can learn from any of those resources and I would love to know that I am coding properly.
I have several projects under my belt and many large scale business solutions that I have coded using Razor and ASP.NET but there are times where I feel that what I am doing is either very hacky or just an inefficient way of coding things. The larger the project is the more difficult it becomes to add new features because of this.
I think this is my lack of experience in coding but at the same time I would like to overcome this and I feel that with the mass experience I do have with MVC3 I could adapt to a easier style or design pattern that would help me not only optimize my code but become a much better web developer. If anyone has any suggestions on books or training sites or anything please let me know as I would love to get better.
Thanks in advance to anyone that has been in my shoes and is willing or capable of recommending anything!
I was dealing with the same issue and found it useful to make a mind map. While it's impossible to give you a full understanding, I can try point you in the right direction with some basic ideas.
download/view (http://www.xmind.net/share/highroad/mvc3-design-pattern/)
Are you familiar with design patterns? Well they exists with MVC applications too :)
If you want to talk the talk and understand what people including myself are talking about, you would need to know the typical design patterns that come with building what they call enterprise level applications. These design patterns are the only real way to begin to understand the concepts.
These patterns structure complex business logic in ways that have become the tried and tested solutions (design patterns) to the design challenges the developer's face.
In the diagram notice there are 3 main layers:
Presentation Layer
Business Logic Layer
Data Access Layer
Some of the highly used design patterns when dealing with Model View Controller in ASP.NET include:
Business Logic Layer Design Patterns:
Active Record. Models relate exactly to the database like in lightweight frameworks e.g. Ruby on Rails). When creating new MVC3 application with ASP.NET and scaffolding views and controllers, this is how it sets it up. Is perfect for less complex applications. So why not just use Ruby on Rails? I would
Domain Logic Layer. Uses MVC with the controller containing very little code and create lots of extra models that can do complex logic, the MVC is only for presentation. Often with this style of layer, a lightweight layer called a Service Layer can be used to call all the functions in the Domain Layer from the controllers i.e. the controller calls the method in the Service Layer class which calls the domain layer. This design pattern seems to be very popular with people who enjoy object oriented programming. See link below to my (quite basic) project designed using Domain layer.
Transaction Script - Use the controller to do a lot of the logic work per action, the problem is a lot of actions need to do the same things so there will be code repetition
For the Data Access Layer:
Something like entity framework models combined with a repository which can perform any SQL queries you need.
Not going into all the patterns for this layer but they include: Data Mapper
With simple apps, there is no real data access layer, it only becomes necessary if you use the Domain Layer in the business layer (which usually is the case)
Depending on what structure your application takes, your Models will mean very different things. In general they will not be models linked to the database (the default when creating a new app makes them like this). Instead they will be ViewModels which are only responsible for holding data that each of the views will need.
I have created a ssample app which you can see here.
https://github.com/testbrian/enterpriseframeworksB
I don't know if this is an example of an enterprise solution, but I have learned a lot from the techniques found in RaccoonBlog. I like how the Layout.cshtml and other razor files use RenderAction to modularize the views.
The project is an example of MVC3 using RavenDb, but it's also one of the best real world applications I've seen since it's actually used in production.
Hope this helps.

What exactly is dynamic data?

What exactly is dynamic data? I saw the term in the ASP.NET Overview on msdn. Is it something that we use all the time thats not really mentioned when working with data?
I've built a few web applications already and never came across this term. Is it something that should be used or maybe considered?
UPDATE: I guess I'm not really sure what it's for. I've never had a problem doing LINQ to SQL or Entity Framework before. What makes using Dynamic Data worth it? Is it simply a pattern?
Dynamic Data was a new project type in VS 2008. It used scaffolding & templates to help code faster.
Two big reasons I saw for its usage:
Stand up an admin back-end really
quickly where doing much on the way
of modifying the front-end may not be
needed.
Quickly stand up CRUD apps that are
simple.
Now, it can be modified very heavily. Check out these links for some work others have done on this.
http://aspnet.codeplex.com/Wiki/View.aspx?title=Dynamic%20Data
Matt Berseth - http://mattberseth.com/blog/dynamic_data/
Stephen Naughton - http://csharpbits.notaclue.net/
http://weblogs.asp.net/craigshoemaker/archive/tags/Dynamic+Data/default.aspx
http://blogs.msdn.com/rickandy/archive/2009/01/08/dynamic-data-faq.aspx
Fast Forward to Today:
As MVC has matured they have introduced many of the ideas that were in Dynamic Data. Scaffolding, templates, etc... to help one quickly get up and running BUT also have the ability to modify more easily and is designed for many other desirable features.
Where does Dynamic Data fit today, especially with Light Switch thrown into the mix? Great question and my only answer at this point is it still fits for the two items originally mentioned but with the advent of MVC having these abilities WITH added capabilities and Light Switch it's going to see minimal usage.
The page you linked to has a link to the ASP.NET Dynamic Data Overview. Is there something on that page you would like explained?
Dynamic Data is a way to have your CRUD data logic written for you automatically using the Database Schema.
Take a look at this walkthrough to give you a quick jist.
It isn't something I use, but I can see where it has merit in a really rapid development scenario. I don't know if it will stand the test of time or prove useful or maintainable.

How should you go about learning ASP.NET after life as a ColdFusion developer?

As someone who has spent around 10 years programming web applications with Adobe's ColdFusion, I have decided to add ASP.NET as a string to my bow.
For someone who has spent so long with CF and the underlying Java, ASP.NET seems a little alien to me. How should I go about getting up to speed with ASP.NET so that I can be truly dangerous with it? Do I need to know C# at any great amount of detail?
I want to be in a position where I can build basic web apps fairly quickly so I can learn more doing the tricky stuff.
I'm only maybe six months down the same path, but here are some thoughts from my experience so far:
The C# language shouldn't give you much problem if you have very much experience with Java at all (or even CFScript). As a reference, though, when I was starting, I found csharp-station a good primer for language basics. It won't help you much as far as the ASP.NET side goes; but it is good for syntax. More you'll be familiarizing yourself with the .NET libraries. The IDE actually can be an enormous help here.
Here are the three biggest differences I found making the transition:
ASP.NET Server Controls - In ColdFusion, you really have pretty
direct control over the HTML; you
work very closely with the page.
This isn't so much the case in
ASP.NET. The server controls are
meant to relieve you of a lot of the
tedium, but at a cost of maybe some
direct control. As a CF programmer,
I'm very particular about what gets
actually output to the browser; and
at first ASP.NET frustrated me
because it spits out a lot of extra
code. Still, the controls are
really powerful, and it pays to
familiarize yourself with them.
Form and validation controls,
especially, save you from a lot of
the tedium in CF of handling post
back and validation. W3Schools
actually has a decent list of web
server controls.
The page model - ColdFusion is pretty agnostic in terms of page
flow. ASP.NET is very much geared
towards using post backs, and is
very event driven. If you're not
using a framework with CF (e.g.
Model Glue), this may be foreign to
you. .NET takes care of handling a
lot of the post back behavior for
you. Also, not to say that
ColdFusion can't be object and
function driven by good use of
CFC's, but ASP.NET really tries to
push you down the OO path compared
to CF in my experience.
Database access - Using ASP.NET really made me appreciate how
powerful cfquery really is. The
csharp-station site also has a good
tutorial on working with the native
.NET db tools. I haven't worked on
enough projects yet to start looking
around for DB access extensions; I'm
pretty sure Jeff recommended
something that they used for
building this site, so you might
check that out. Otherwise, I really
suggest you familiarize yourself
with the DataSet object. It's
somewhat similar to a query object
in CF, and lets you run query of
queries, etc... Looping over
queries in CF is very common, but it
doesn't happen nearly as much in
ASP.NET because of data binding.
Microsoft has a video called ASP.NET for ColdFusion developers you may be interested in.
Edit, here's another
ADO.NET is a core concept, and I would really recommend taking a course in it. Having a qualified instructor explain exactly what the differences are between a DataSet, DataReader (and so forth -- there are a lot of different data access object types) is invaluable. Not to mention you'll better understand the appropriate time and place to use each; and you can ask questions and get immediate answers in a classroom setting.
I took an ADO.NET class (one night a week, about 8 weeks) at my local university for around $400. Even if my company hadn't paid for it, I would have been happy to, and I can highly recommend anyone trying to learn .NET do the same.

Resources