views:

117

answers:

7

I need to create an application whose business logic can be used in WEB/WPF apps is there any standard way to do that. I am a Newb to patterns and have been thinking around in the concept of patterns and frameworks. I donot want to reinvent the wheel.:)

Any Ideas?.

+1  A: 

You should definitely read this guide. It is a good starting point to understand the various patterns and designs that are involved.

CodeToGlory
A: 

One core concept that will apply to most of the patterns you'll see will be a "seperation of concerns" or kind of an "n-tier" architechture. If you're going to have web and WPF apps using the same data, make sure the data layer is seperate from the business logic and easily contained.

That way you can have both your web app and WPF app connect to the same data store, but not worry about the underlying issues behind it. All your app needs to know is that its getting a List of X or a DataTable or whatever, and can proceed from there.

You can easily apply this to various aspects of your application. I'd recommend starting with the "lower end" aspects such as data access and business functions. Ideally, once those get nailed down nicely, all you'll have to worry about is how the app is being presented to the user, which is where you'll have various implementations, but the core data/functionality remains the same across them all.

Dillie-O
A: 

When you need to present your application in different views, a standard Model View Controller pattern can be used:

http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller

The basic idea is that by separating out these elements you get better controll as well as the ability to reuse the model and controller in applications that use different views such as web and WPF.

You should have a look at the ASP.net MVC framework for web and the Prism framework for WPF.

There are other variations of this such as the Model View Presenter. And the model-view-viewmodel:

http://msdn.microsoft.com/en-us/magazine/dd419663.aspx

Shiraz Bhaiji
A: 

If you create a well architected 3-tier architecture (or n-tier) then it doesntr matter what your UI is. It can be a web application, a windows application, a mobile app or anything else.

UI (can be anything) | | Business Logic Layer | | DAL | | Data Source (SQL Database)

and Entity layer for transfer of data from one layer to another.

Try WCSF (which uses MVC internally)

Bhaskar
+1  A: 

You might read up on Domain Driven Design. The focus of DDD is the Business layer you are talking about. It is all object-oriented and built purely with POCOs (plain-old-clr-objects). It provides interfaces to the outside world for usage in the form of services, and it provides interfaces to the outside world for persistence in the form of repositories.

Incidentally, DDD is a near perfect match for MVC and like patterns specifically because it isolates the Domain model so well.

You could start here, but I'd start with this link or by reading Eric Evan's book "Domain Driven Design" http://dddstepbystep.com/

jlembke
A: 

search on CSLA - Component Scalable Logical Architecture. This is a .NET library of base classes for creating "business objects". This business layer can be used equally well in Winforms, Web, or WPF.

The library is free, and there are books on Amazon that describe how it works. Here is the C# version of the book. There is also a VB version

taglius
A: 

Layered Architecture: This article describes a concrete example architecture for .NET/WPF Rich Client Applications. The Domain layer and all layers below can be reused in WEB applications as well.

jbe