views:

109

answers:

2

I am Developing a mid-size application and want to implement Application Architecture, I've read some Architecture Books and Approach and think about

AAFN (Application Arcitecture For .net) presented by Microsoft

SOA

SDLM

SDO

MVC

and vice versa ...

this is a web application that will extended with some other small application ( just think about something like a M.I.S with a (or two) core)

Whitch Projects I should have I think about

Common // to use in all projects

Framework // main framework

DAO // data access object ( entityframework or nHibernate )

UI // will available in 2 variant web and windows(wpf) interface )

BusinessEntities // all subApplication project logic will goes there

ApplicationNameProject // each application have their Own Logic (in BussinessEntities)

ApplicationUnit // each application Entity will place here

ApplicationNameProject  // each application data Entity (in Application Unit)

Services // WCF Services goes here to contribute with all applications

this is the architecture witch I think about, I do not have any force to use this, I want to know whats the best fit for me, can Change all of it or add some other projects and remove these projects

any help appriciated

+2  A: 

There is no "best small or mid-size application architecture" as a silver bullet to fit any project, so drop that idea right now or you'll be in for a world of pain down the road.

The architecture for any given project will fit the purpose of that project. In some cases, ASP.NET WebForms with a direct queries into the database will be the most appropriate architecture, in some cases MVC will be the right architecture, in some cases a windows forms application built on top of a web service that connects to a relational database through an ORM like LINQ-to-SQL or NHibernate.

You can't decide on a one-architecture-fits-all approach, it just doesn't work. Each architecture has its merits and weaknesses and thus projects for which it is well suited and projects for which it should be avoided. You should pick the approach that makes the most sense for the current project/scenario.

Given that however, I tend to take a fairly uniform approach.

If I need a quick utility project that does a very specific thing and is highly unlikely to be needed for anything else, I might use a console application with queries against my database hardcoded.

If I need a common set of queries that I'm likely to need from multiple projects, I'll write them as stored procedures to get the performance benefits and build a data access layer that will leverage these stored procedures to give me standardized business objects, in a standard DAL (data access layer)/BOL (business object layer)/BLL (business logic layer) approach. This is advantageous because it means that once I've got this set of libraries built I can float any application over the top - for instance a webforms or MVC application.

MVC is advantageous because of separation of concerns - your controller can interact with your business library simply to access the data it needs and your views are really just that - a view of the data that the user can interact with. The views do nothing more than take the current data view to the user and transport any data changes back from the user to the controller - no logic is held in the view and as such it means that it's far easier to unit test and make changes to components without affecting the rest of the application.

The drawback to a multi-tiered or multi-layered approach like this though is that it takes time to architect it properly and if you're only after a throw-away utility application like they demonstrate on stage at developer conferences then this is complete overkill and I wouldn't bother with it.

Think of it like this: Every layer, every library, every component requires justification. If there is less justification for than against, then don't do it. The key is not to do something without reason - anything you do is correct providing that you have a well thought out reason for it, and by well thought out, I mean that you've found very good reasons for and against and you've made an educated decision, you've not made a decision based on half thoughts, or worse, no thought at all.

BenAlabaster
Ben, I know whitch you said, and it is because i describe my project scenario. with all I said witch architecture you recommand, I have a mid-size application that will extend with some new projects. each project should be completly independent and have no dependancy to other projects there will be some contact point (perhaps some services) to connect projects to gether (in fact it will be our in-house architecture in company and al of upcoming project will implement with thsi architecture ).
Nasser Hadjloo
Without knowing the target audience, the type of application, the size and type of data storage, how the user will need to interact with it and a fleet of other questions I can't say. I'd need to do a whole level of business analysis with you to decide on an appropriate architecture for any given project. Does each project have a common data store? Do they use the same business objects, will they contain the same business rules? The list goes on...
BenAlabaster
A: 

Anything but the most trivial .NET application should have several projects: a UI layer, some kind of business logic layer, a persistence (storage) layer and accompanying test projects. Each project should interact loosely through interfaces.

In general you should create the minimum number of layers you need to make your code testable and easy to understand.

To figure out what the minimum is that you need it can be a good idea to let your tests drive the internal design of the system. Each layer should have tests in its own right, with (possibly) the exception of the top HTML layer and the bottom SQL layer.

With that in mind it helps to separate concerns as far as possible. For example SQL queries should almost never be in the same block of code as HTML support: split things into multiple layers that each do one and only one thing. This makes changes easier.

Be aware of the difference between systems architecture (where loosely coupled Web services using e.g. REST interact) and the internal design of the system. It's a good idea to decouple the Web service interfaces (as consumer or provider) in their own layers as this is an area that often changes.

These designs are an art that's best learned by practice. With good unit tests you should find refactoring an application design fairly swift, so it's a good idea to look at technologies like Spring.NET or other inversion of control containers to make this easy.

Jeremy McGee
This assumes the OP is using TDD. You cannot definitively make this judgement without knowing more about the scope of the project - the company it will be used for, if it's a single project for the consumer market or a web application. If it's a consumer targeted mashup, then a multi-tier approach with all the components of a line of business application will be overkill and cost more time than necessary to reach market initially. In my line of business, I would certainly take your approach but the OP hasn't provided enough info to make that judgement definitively.
BenAlabaster
Given that the OP mentions multiple applications that share common elements, I'd encourage TDD to be used. It's too easy to make mistakes with projects that have multiple dependencies if TDD is not followed.
Jeremy McGee
I have a mid-size application that will extend with some new projects. each project should be completly independent and have no dependancy to other projects there will be some contact point (perhaps some services) to connect projects to gether (in fact it will be our in-house architecture in company and al of upcoming project will implement with thsi architecture
Nasser Hadjloo
Careful: I'm using "project" to mean a Visual Studio project or .NET assembly. While reducing the number of dependencies between projects of this kind is a good thing, you don't want to remove /all/ dependencies..!
Jeremy McGee