5,695,118 members and growing! (15,684 online)
Email Password   helpLost your password?
Web Development » Applications & Tools » Tools with source code     Intermediate License: The Code Project Open License (CPOL)

Web-Application Framework - Catharsis - Part I - New Solution

By Radim Köhler

Catharsis web-app framework
C#.NET 3.5, .NET, ASP.NET, Architect, Dev, Design

Posted: 13 Sep 2008
Updated: 5 Nov 2008
Views: 15,122
Bookmarked: 63 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
19 votes for this Article.
Popularity: 5.35 Rating: 4.19 out of 5
3 votes, 15.8%
1
1 vote, 5.3%
2
0 votes, 0.0%
3
2 votes, 10.5%
4
13 votes, 68.4%
5
Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report This Article

Introduction

Catharsis is a complete framework for developing web applications. The question is, has she (Catharsis) something essentially better than others, what could promote her to an everyday usage? Answer must come from you.    

All source code can be found here.

 Catharsis-title.png

No. Chapter No. Chapter No. Chapter
New solution  VI  CatharsisArchitecture XI  (Controller layer - undone)  
II  Home page observation VII  Entity layer  XII  (UI Web layer - undone) 
III  Roles and users VIII  Data layer XIII  Tracking, PAX design pattern
IV  Localization, translations IX  Business layer XIV  Catharsis Dependency Injection (DI, IoC) 
Enter into Catharsis, new Entity (Model layer - undone)   XV  (Code Lists - undone)    

Current release: 0.9 .1

06.11.2008 - Upgraded to ASP.NET MVC (Beta) :  see below

After two month after first release I've realized, that there are still some gaps in the MVC design pattern understanding. If you would like to get another view on MVC, to see some comparison with MVP and that all in the world of ASP.NET MVC and mainly how it works in Catharsis framework Architecture - try to follow this link http://www.codeproject.com/KB/aspnet/AspNetMvcMvp.aspx. This description is intended as a support for Catharsis, not as an academic and only valid explanation...

Background      

ASP.NET Web form pages are dead, or at least out of the date. Do you really know all of the 23 (or how many) page life-time events? And do You need all of them?

Even in Microsoft they realized, that ASP.NET need a big change and purification (in Greek 'purification' == 'Catharsis') The result is ASP.NET MVC, the lightweight of web-forms with everything you need and lot of new features, which can change your way of thinking about request and response (and url-routing is really a very small piece of that wonderful puzzle called MVC).  

Among other problems in Microsoft world of web-forms, there is depression of the OOP programming, caused mainly with DataSets, DataTables, DataAdapters ...

How could you think in object, if DataTable generated by designer has thousands of rows of code, which you cannot change, but above all: you cannot derive from DataTable! is this an OBJECT? And did you ever tried to create lte’s say object called User with property CurrentRole and property collection Roles using DataTables? (DataSet with related tables? Magically connected by relations? No ability to use auto identity for inserting ...) Get out of here. Now.  

NHiberante 2.0 (even 1.2) can correct your sad ideas, because of narrowing the OOP world. And maybe it also can improve your designing habits when working with relational-database. Inheritance, polymorphism ... and fancy lazy mode (it’s not OOP but how effective)

Well, we have ASP.NET MVC (today Preview 5) and NHibernate 2.0 (final) and lot of good practices known. The missing part is the pot, which will allow us mix it and prepare delicious meal for our users.      

Catharsis features   

I do believe, that this article will have many descendants. So, do not waste time and place and just briefly about Catharsis: She is the 'Web-Application Framework' gathering best-practices... based on ASP.NET MVC, NHibernate 2.0.

Catharsis has real multi-tier architecture, with a separating of concern as the framework essence.

  • Entity contains only plain objects
  • Data is handling Storage (DB)
  • Business is responsible for rules
  • MVC process user requests and communicate with business facades

Catharsis is strongly OOP! Using 1) inheritance as a key feature for code reuse and 2) polymorphisms as the only way to communicate among layers (objects are working with interfaces! without knowing who is implementing them)

Powerful features are:

  • Roles with CurrentRole property (user has roles but access is evaluated only against currently selected role).
  • Users and Roles are objects managed in runtime (Roles should be fixed but users can be added, modified or deleted)
  • Localization in the runtime (no .resx) with ability to add new languages on the run!
    AOP filters (authorization, work-flow navigation...).

For all of that Catharsis has a Guidance. Every needed piece of code you'll find on a  http://www.codeplex.com/Catharsis.

Catharsis.Guidance

Guidance provides two type of tasks:

  1. Creates new solution with all needed libraries, assemblies and implemented infrastructure 
  2. Generates new classes in a design mode - separately for every layer, or all of them (30 classes?) at once. 

Guidance itself should be the target of an article (to create them took me lot of days of my life ... ). But their final stage is 'wunderbar' ...

Needed Prerequisites

Needed knowledge   

Visual Studio (2008) - You need to have SP1! installed and VB.NET Support. Both these requirements are MUST. VB.NET has unique support for Linq to XML. When you'll see it, you will never use anything else to generate Word or Excel files directly from your web application!

MVC - I do expect that you are well oriented in ASP.NET MVC. Wonderful place to start is www.asp.net/mvc and you should have seen all videos from Scott Hanselman – not they are really cool, but first of all they are very clear and nice to understand.
Current version used in Catharsis is ASP.NET MVC (Beta)

NHibernate – I do expect you are familiar with NHibernate 2.0 (some big differences from 1.2, like missing namespace Expressions). The nice place to start is www.nhibernate.org (or examining Catharsis code)  

Needed SW packages 

Before you can start using Cathrasis.Guidance you have to install:  

  • AspNetMVCBeta-setup.msi (without that, you cannot load Web project to VS)
  • GuidanceAutomationExtensions.exe (the 'CIL' for any Guidance) 
  • -/+ GuidanceAutomationToolkitForVS2008.msi (if you want to change them) 

And finally you can choose to install

  • Catharsis.Guidance as MSI (probably preferred way)
  • Catharsis.Guidance solution, Open it, click on a project Guidance, select register.

 

Register.png

From the version 0.9.1 there is The 'ProjectBase' namespace instead of 'Catharsis'. The aim is clear - to quickly start to use Catharsis framework in your company ...

Finally I suggest you install provided SQL scripts (create tables and insert few objects) or restore backup. It will allow us run solution very quickly. Scripts are needed for new solution (they create infrastructural tables). If you are running example, then you should use backup

(Source codes and MSI are available here.)

Creating our first Solution 

If you have installed all needed stuff, let's start with a new solution.

Open Visual Studio 2008 and select Create new project. In the menu you can see now item: Guidance, which contains one solution - Catharsis. 

New_solution.png

Name new solution like 'YourCompany.Product' for example and create it. On the wizard screen you can change some settings, important is connection string.

Sln_settings.png

When you click finish, Catharsis.Guidance will create new solution with all needed layers, referenced libraries and needed classes to handle roles, users, localization ...

If you've created Database as mentioned above, and provided correct connection string in a setup of a new solution, you should be very near to a first run of your new Web application.

Select 'Firm.Product.Web' project as startup and Default.aspx is as startup page and press F5...

Catharsis is running

If everything went right, you should see the HomePage screen:

Catharsis_running2.png

.NET

I’d like to point out one fundamental thing on Catharsis, which (when I went through all my articles) was not said. Firstly I do not accept everything what’s coming on the market (even open source one) until I do play with it and feel friendly. (The example of bad experience for me was ‘Linq to Entities’ which I was looking forward as a child).

The pillar of Catharsis, I must mention, is Microsoft .NET C# 3.5! From my point of view and experience the C# is at the moment leading OOP programming language. Anything you need is there and lot of features extends the ability of day to day coding. 

The last missing thing in C# is multiple inheritances (but as I heard rumors it will be changed). Despite of that fact the Extensions methods at current version can do lot of useful job. And also LINQ itself as the part of .NET 3.5 brings tremendous simplification. I think that it must be written: MS C# .NET 3.5 is precious diamond! I am looking forward .NET 4.0 as a child …

In a next part we will examine the Homepage, and the built-in stuff.

Enjoy Catharsis.

Source code

History    

Catharsis 0.9.1  

Upgrade 06.11.2008  

Two fundamentals upgrades were made in Catharsis 0.9.1:

1) Catharsis was upgraded to ASP.NET MVC Beta.
2) Catharsis namespaces are changed to ProjectBase. Catharsis is Philosophy of well designed Architecture. The name usage will now join all these features together. The name change to 'ProjectBase' comes from your experience (and requirement). Framework as whole can be now directly used in your company and keep it not so obvious, that it is OpenSource. It means, that when you create new solution, only the name of your Company.Producet + core libraries ProjectBase.* will be displayed. I hope it helps in rigid environments ... :)
Enjoy Catharsis

 

Updated 26.10.2008 

WPF - Windows client support

Catharsis is based on multi-tier architecture and is strongly OOP. As the proof of concept, Catharsis was extended to allow development not only for web-applications but also for Windows-clients based on WPF (do not confuse with smart clients). 

Catharsis Guidance now allows you to create two types of solutions:

  1. Web
  2. WPF

Web is based on ASP.NET MVC. Windows-client uses WPF as a presentation tier and Catharsis inner MVC pattern implementation to handle it.

The result is almost the same approach! Development steps, guidance usage, classes creators, etc - that all is the same for both types of applications (Web or Windows)! It means that you can use the best practices you know in both worlds without any changes. 

Excel export 

Another feature is based on Visual Basic .NET. Therefore you have to install VB.NET support to your VS.

VB.NET has tremendous built-in ability to handle XML (download code and observe). To simply cerate Excel extracts there is new project in every solution (named LinqToXml). The Unit tests will uncover how easy is to create Excel sheet. 

Enjoy Catharsis.   

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Radim Köhler


Web developer since 2002, .NET since 2005

Give me feedback. Append a message. Vote.
Competition is as important as Cooperation.

___
Occupation: Web Developer
Location: Czech Republic Czech Republic

Other popular Applications & Tools articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 16 of 16 (Total in Forum: 16) (Refresh)FirstPrevNext
GeneralC# multiple inheritancesmemberLaurts6:41 2 Nov '08  
GeneralRe: C# multiple inheritancesmemberRadim Köhler8:05 2 Nov '08  
GeneralRe: C# multiple inheritances [modified]memberLaurts8:17 2 Nov '08  
GeneralRe: C# multiple inheritancesmemberRadim Köhler8:41 2 Nov '08  
GeneralRe: C# multiple inheritancesmemberLaurts6:37 5 Nov '08  
GeneralRuntime Error "Session was disposed of or closed"memberwadep14:44 7 Oct '08  
GeneralRe: Runtime Error "Session was disposed of or closed"memberRadim Köhler20:40 7 Oct '08  
GeneralRe: Runtime Error "Session was disposed of or closed"memberwadep0:21 8 Oct '08  
GeneralRe: Runtime Error "Session was disposed of or closed"memberRadim Köhler0:32 8 Oct '08  
GeneralRe: Runtime Error "Session was disposed of or closed"memberwadep0:54 8 Oct '08  
GeneralCodeProject should make this mandatory...memberRaghu Karupakala5:21 26 Sep '08  
GeneralRe: CodeProject should make this mandatory...memberRadim Köhler6:14 26 Sep '08  
GeneralRe: CodeProject should make this mandatory...memberShivprasad koirala4:50 29 Sep '08  
GeneralRe: CodeProject should make this mandatory...memberRadim Köhler22:06 29 Sep '08  
GeneralRe: CodeProject should make this mandatory...membertorial19:11 27 Oct '08  
GeneralRe: CodeProject should make this mandatory...memberCIDev12:01 1 Oct '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 5 Nov 2008
Editor: Deeksha Shenoy
Copyright 2008 by Radim Köhler
Everything else Copyright © CodeProject, 1999-2008
Web11 | Advertise on the Code Project