Click here to Skip to main content
6,822,123 members and growing! (17,985 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#.NET3.5, ASP.NET, Architect, Dev, Design
Revision:10 (See All)
Posted:13 Sep 2008
Updated:9 Jun 2009
Views:40,896
Bookmarked:113 times
Unedited contribution
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
28 votes for this article.
Popularity: 6.32 Rating: 4.37 out of 5
3 votes, 10.7%
1
1 vote, 3.6%
2

3
4 votes, 14.3%
4
20 votes, 71.4%
5

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
I New solution VI CatharsisArchitecture XI Controller layer
II Home page observation VII Entity layer XII UI Web layer
III Roles and users VIII Data layer XIII Tracking, PAX design pattern
IV Localization, translations IX Business layer XIV Catharsis Dependency Injection (DI, IoC)
V Enter into Catharsis, new Entity X Model layer XV (Code Lists - undone)

Latest stories about Catharsis

Latest stories about the Catharsis framework you can find:

http://www.codeproject.com/KB/aspnet/catharsis_tutorial_01.aspx

David O'Sullivan will guide you through   

  • the Catharsis guidance installation;   
  • the Example observation  
  • and extending the Example with new stuff (entity and its infrastructure)

You will touch all the fundaments which Catharsis architecture provides. These pieces than allow you easy and fast own development and application extending.

Enjoy these new stories. Thanks David.

Current release: 1.2  

Catharsis 1.2 - 9.6.2009: see below 

ASP.NET MVC 1.0, NHibernate 2.1. BETA 1

MVC design pattern

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 1.0

NHibernate – I do expect you are familiar with NHibernate 2.1 (BETA 1 - LinFu proxies). 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.png

Web Controls

I have to say, that MVC native solution for web controls is not well designed. HtmlHelper as the extension method for creating anchors, inputs etc. is simply bad solution. I would like to give you another point of view: Take a look at this article,

Catharsis_part12.aspx

,and you'll see how easy it is to correctly manage web controls even in the MVC world

.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 1.2

  • Serializable session - all items (entities and search objects) are Serializable (ready for web-farming)
  • Prototype desing pattern in action (every IEntityFacade<T> provides CreateNew<T>() - you are managing entity incubator on one place)
  • User friendly List view allows opening detail/edit in a new window. Row count per page adjustable for every entity on search screen.
  • Pre-created skeleton for Unit Tests (use them!)
  • Performance increase - lazy loading for Facades, Models, Daos - only when needed (Lazy Locator design pattern for Getters)
  • Native support for MultiOption list in smart binder
  • CodeLists abilities extended (using smallint and tinyint as ID)
  • Web application automated Recovery when SQL server restarts
  • AOP for logging tracks the Session size!
  • More efficient and simplified ApplicationRole provider (same for external providers via CommonRoleProvider)
  • DAO Methods for extending search criteria moved to extensions
  • powerful unit tests structure for every entity

Catharsis 1.0.1

  • New Smart WebControls providing OOP approach (no more HtmlHelper)
  • Powerful ToDisplay() (culture dependent formating for decimals, int, datatime)
  • Smart Binders (allowing to bind formated decimals, DateTimes etc.)
  • Global.asax is the only place where to set suffix ".mvc" (or not set any in IIS 7)
  • IE 8 compliant
  • More precious setting in Menu.config
  • Full support of ASP.NET WebControls meta:resourceKey localization
  • large example

Catharsis 0.9.5 was released 10.12.2008

  • Catharsis Architecture is fundamentally OOP
  • Contains TreeView - (First) 100% MVC WebControl
  • Provides direct built-in Export to Excel for every entity
  • Navigation is managed in one simple Menu.Config xml file
  • Menu.Config xml file (same as for navigation) provides Access-rights settings
  • Guidance creates: Complete Web Solution on-one-click
  • Guidance creates: Entity infrastructure at one run (Entity, Data, Business, Model, Controller, View, Test)
  • Guidance creates: Entities can be common (Persistent) or Tracked
  • Guidance creates: Entity's infrastructure without MVC at one run (Entity, Data, Business, Test)
  • Guidance creates: CodeList infrastructure at one run (Entity, Data, Business, Model, Controller, View, Test)
  • Guidance creates: MVC for not-entity handling e.g. Reports, Documentation (Model, Controller, View,)
  • New extension methods for object .Is() and .IsNull() (no more 'entity != null')
  • Messages collection introduced (replacing ErrorData) with Error, Warning and Information states
  • Translator provides sorting on translated-phrases, also searching
  • UI Layout improved (TreeView as navigation, Quick actions as Icons)
  • Master page reorganized to parts and their smart but small web controls
  • Strong support for KEY shortcuts (Almost every action can be ran as ShiftAltF = find/search)
  • Paging is essence of performance - every entity is by default displayed as a list - max rows == 20
  • Paging miracle on detail level. User's can navigate to Next or Previous entity
  • CodeLists extended with IsVisible attribute, which is applied on the GetAll() method (source for comboboxes
  • Direct built-in support for Files uploading (any Content-Type) and quick download (based on contentType browser can decide who will open)
  • Every entity Derives from base class: Add, Update, Select, Delete
  • Entity displayed in the List can be sorted by any property (e.g. Subject.Address.City)
  • Override one method ListToExcel() and you can gain direct export to excel for every entity
  • Constants placed in Str class reorganized. Every entity should use Str.Business.Entity constants
  • Base classes moved from project to the ProjectBase
  • Base Models now contains other Models (Composition) e.g. TreeViewModel, ListModel, MasterModel ...
  • Two controllers bases - Entity (for Persistent and Tracked entities) and Web (form MVC like Reports, Documentation)
  • Interfaces for Controllers and Facades extended with setters for DI
  • Object Factory rewritten to Factory provider method to allow simple addon like Spring.NET...

  • ... and many more ...

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


Member
Web developer since 2002, .NET since 2005

Competition is as important as Cooperation.

___
Occupation: Web Developer
Location: Czech Republic Czech Republic

Other popular Applications & Tools articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 36 (Total in Forum: 36) (Refresh)FirstPrevNext
GeneralOn express edition Pinmemberagussmw22:28 2 Dec '09  
GeneralRe: On express edition PinmemberRadim Köhler7:29 3 Dec '09  
GeneralExample site? PinmemberJerry Evans7:27 10 Jun '09  
GeneralRe: Example site? PinmemberRadim Köhler8:04 10 Jun '09  
GeneralRe: Example site? PinmemberJerry Evans3:05 11 Jun '09  
GeneralRe: Example site? PinmemberRadim Köhler3:59 11 Jun '09  
GeneralWell done PinmemberGovernment Agent23:44 9 Jun '09  
GeneralRe: Well done PinmemberRadim Köhler23:58 9 Jun '09  
GeneralI liked it. PinmemberRajesh Pillai6:04 9 Jun '09  
GeneralRe: I liked it. PinmemberRadim Köhler20:10 9 Jun '09  
GeneralDesign Patterns Pinmemberryan.riley8:33 8 Jun '09  
GeneralRe: Design Patterns PinmemberRadim Köhler21:25 8 Jun '09  
GeneralRe: Design Patterns Pinmemberryan.riley4:51 9 Jun '09  
GeneralRe: Design Patterns PinmemberRadim Köhler20:17 9 Jun '09  
GeneralPerformance PinmemberDOSSS16:08 28 May '09  
GeneralRe: Performance PinmemberRadim Köhler3:37 29 May '09  
GeneralDiamond database PinmemberTooShort21:24 27 Dec '08  
GeneralRe: Diamond database PinmemberRadim Köhler8:51 5 Jan '09  
GeneralC# multiple inheritances PinmemberLaurts6:41 2 Nov '08  
GeneralRe: C# multiple inheritances PinmemberRadim Köhler8:05 2 Nov '08  
GeneralRe: C# multiple inheritances [modified] PinmemberLaurts8:17 2 Nov '08  
GeneralRe: C# multiple inheritances PinmemberRadim Köhler8:41 2 Nov '08  
GeneralRe: C# multiple inheritances PinmemberLaurts6:37 5 Nov '08  
GeneralRuntime Error "Session was disposed of or closed" Pinmemberwadep14:44 7 Oct '08  
GeneralRe: Runtime Error "Session was disposed of or closed" PinmemberRadim Köhler20:40 7 Oct '08  

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads.

PermaLink | Privacy | Terms of Use
Last Updated: 9 Jun 2009
Editor: Deeksha Shenoy
Copyright 2008 by Radim Köhler
Everything else Copyright © CodeProject, 1999-2010
Web20 | Advertise on the Code Project