Click here to Skip to main content
Click here to Skip to main content

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

, 4 Feb 2012
Rate this:
Please Sign up or sign in to vote.
The Catharsis framework, web-application in .NET with Guidance.
Catharsis-title.png

Introduction

Catharsis (current version 4.1.0 - 04.02.2012) is a complete framework for developing .NET web applications. It is an Open Source distributed as the binaries (Guidance) or the source code, for free...

The latest Guidance binaries, source code, some documents and stories can be found at http://catarsa.com.

Current release: 4.1.0

Catharsis 4.1.0 - 04.02.2012:

I would like to let you (all) know, that there is a new Catharsis release. It is a really very very long time since this article was last time updated. The Catharsis web application framework meanwhile reached the adulthood.

While many features has been improved, fixed and rewritten, the main Architecutre remains still the same.

There is a POCO project containing Entities, as a Data Transfer Objects (DTO). Every entity in the system is represented by its POCO object (e.g. User, Contract, Client) and a searching object (UserSearch, ContractSearch) gathering all filter values.

Data layer (so far NHibernate 3.2, XML, ADO.NET, LDAP) publishes API via IDao interfaces. Basic CRUD operations and powerful one GetBySearch method

Business rules are nested in the application layer published via IFacades. This place is where all rules are applied, and new objects are borned (FactoryMethod, Binding from any IValueProviders).

And Finally ASP.NET MVC as a UI. No Html Helper in Catharsis framework. Fully typed objects representing basic HTML 5 are there instead (Div, Anchor...). And their combination encapsulating some common features (Display format based on DataType, localized Label, read or write representation)

Through all layers bubbles the Messages collection, allowing naturally management of a workflow and provide upper layers with meaningful (and localized) information.

Out of the box, Catharsis brings, authorization, localization, exception handling, loggin or publishing, AOP, IoC (StructureMap)... and Guidance to quickly create new Solution and use recipes to extend it with new Entities and their infrastructure.

After 4 years of development even the UI was finally made a bit more fancy ... HTML5, support for any browser except IE 6.0-.

Try the latest Guidance here

The Catharsis Framework 4.1.0

you will need:

  • VS 2010 SP1
  • ASP.NET MVC 3.0
  • Code Contracts (it is a must)
  • GAX 2010 (to run Guidance)

Enjoy the latest Catharsis

.

.

.

.

.

Older stuff:

The latest stories

About the Catharsis framework (2.5):

Release: 2.5

Catharsis 2.5 - 1.4.2010:

  • Validator Design Pattern, Business rules declarative syntax
  • Expressions instead of strings - DAO Criteria assembling
  • Expressions instead of strings - Controller list view (columns)
  • Wiki .NET Parsers - C# code generated with the ANTLR tool
  • DAO support for nHibernate, XML, ADO.NET
  • Entity can have different ID types (int, decimal, GUID)
  • CSS: Standards, one definition for all browsers, easy to change, e.g., colors.

Uses: ASP.NET MVC 1.0, nHibernate 2.1.

MVC Design Pattern

Two months after the 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 everything in the world of ASP.NET MVC and mainly how it works in the 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 date. Do you really know all of the 23 (or many) page life-time events? And do you need all of them?

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

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

How could you think of an object like a DataTable generated by a designer that has thousands of rows of code, which you cannot change, but above all: you cannot derive from the DataTable! Can that be called an object? And have you ever tried to create let's say an object called User with a property CurrentRole and a property collection Roles using DataTables? (A 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 ideas by narrowing the OOP world. And maybe it can also improve your designing habits when working with a relational-database. Inheritance, polymorphism ... and fancy lazy mode (it's not OOP, but very effective).

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

Catharsis features

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

Catharsis has real multi-tier architecture, with separation of concerns as the framework essence.

  • Entity contains only plain objects
  • Data handled storage (database)
  • Business is responsible for rules
  • MVC processes user requests and communicates with business facades

Catharsis is strongly OOP! Using:

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

Powerful features are:

  • Roles with the CurrentRole property (user has roles but access is evaluated only against the currently selected role).
  • Users and Roles are objects managed in runtime (Roles should be fixed but users can be added, modified, or deleted).
  • Localization at runtime (no .resx) with the 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 can be found at http://www.codeplex.com/Catharsis.

Catharsis.Guidance

Guidance provides two type of tasks:

  1. Creates a new solution with all the needed libraries, assemblies, and implemented infrastructure
  2. Generates new classes in 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. Once you use 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. A wonderful place to start is www.asp.net/mvc and you should have seen all the videos from Scott Hanselman - they are really cool, but first of all, they are very clear and easy to understand. The current version used in Catharsis is ASP.NET MVC 1.0.

nHibernate - I do expect you are familiar with nHibernate 2.1 (LinFu proxies). A nice place to start is www.nhibernate.org (for examining Catharsis code).

Needed software packages

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

  • AspNetMVCBeta-setup.msi (without that, you cannot load a 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 an MSI (probably the preferred way)
  • Catharsis.Guidance solution. Open it, click on project Guidance, select Register.

Register.png

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

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

(Source codes and MSI are available here.)

Creating our first Solution

If you have installed all the needed stuff, start with a new solution. Open Visual Studio 2008 and select Create new project. In the menu, you can see the item Guidance, which contains one solution - Catharsis.

New_solution.png

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

Sln_settings.png

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

If you've created the database as mentioned above and provided the correct connection string in the setup of the new solution, you are close to the first run of your new Web application.

Select the 'Firm.Product.Web' project as Startup and Default.aspx as the Startup page, and press F5...

Catharsis is running

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

catharsis.png

Web Controls

I have to say that the MVC native solution for web controls is not well designed. HtmlHelper as the extension method for creating anchors, inputs, etc., is simply a 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 talked about before. Firstly, I do not accept everything that's coming on the market (even Open Source ones) until I play with it and feel friendly. (An example of a bad experience for me was 'LINQ to Entities' which I was looking forward to like a child).

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

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

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

Enjoy Catharsis.

Binaries, source code

History

Catharsis 1.2

  • Serializable session - all items (entities and search objects) are serializable (ready for web-farming).
  • Prototype Design Pattern in action (every IEntityFacade<T> provides CreateNew<T>() - you are managing the entity incubator in one place).
  • User friendly list view allows opening detail/edit in a new window. Row count per page adjustable for every entity on the 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.
  • CodeList 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 Test structure for every entity.

Catharsis 1.0.1

  • New Smart WebControls providing OOP approach (no more HtmlHelper).
  • Powerful ToDisplay() (culture dependent formatting for decimals, int, datatime).
  • Smart Binders (allowing to bind formatted decimals, DateTimes etc.).
  • Global.asax is the only place where to set suffix ".mvc" (not set 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 in 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 the 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 what app will open the file).
  • Every entity derives from a 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 the Str.Business.Entity constants.
  • Base classes moved from project to ProjectBase.
  • Base models now contain 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 add-ons 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)

Share

About the Author

Radim Köhler
Web Developer
Czech Republic Czech Republic
Web developer since 2002, .NET since 2005
 
Competition is as important as Cooperation.

___

Comments and Discussions

 
GeneralDesign Patterns Pinmemberryan.riley8-Jun-09 7:33 
GeneralRe: Design Patterns PinmemberRadim Köhler8-Jun-09 20:25 
GeneralRe: Design Patterns Pinmemberryan.riley9-Jun-09 3:51 
GeneralRe: Design Patterns PinmemberRadim Köhler9-Jun-09 19:17 
GeneralPerformance PinmemberDOSSS28-May-09 15:08 
GeneralRe: Performance PinmemberRadim Köhler29-May-09 2:37 
GeneralDiamond database PinmemberTooShort27-Dec-08 20:24 
GeneralRe: Diamond database PinmemberRadim Köhler5-Jan-09 7:51 
GeneralC# multiple inheritances PinmemberLaurts2-Nov-08 5:41 
GeneralRe: C# multiple inheritances PinmemberRadim Köhler2-Nov-08 7:05 
GeneralRe: C# multiple inheritances [modified] PinmemberLaurts2-Nov-08 7:17 
GeneralRe: C# multiple inheritances PinmemberRadim Köhler2-Nov-08 7:41 
GeneralRe: C# multiple inheritances PinmemberLaurts5-Nov-08 5:37 
GeneralRuntime Error "Session was disposed of or closed" Pinmemberwadep7-Oct-08 13:44 
GeneralRe: Runtime Error "Session was disposed of or closed" PinmemberRadim Köhler7-Oct-08 19:40 
GeneralRe: Runtime Error "Session was disposed of or closed" Pinmemberwadep7-Oct-08 23:21 
GeneralRe: Runtime Error "Session was disposed of or closed" PinmemberRadim Köhler7-Oct-08 23:32 
GeneralRe: Runtime Error "Session was disposed of or closed" Pinmemberwadep7-Oct-08 23:54 
GeneralRe: Runtime Error "Session was disposed of or closed" Pinmemberdeanyap25-Apr-09 9:08 
GeneralRe: Runtime Error "Session was disposed of or closed" PinmemberRadim Köhler25-Apr-09 20:02 
GeneralCodeProject should make this mandatory... PinmemberRaghu Karupakala26-Sep-08 4:21 
GeneralRe: CodeProject should make this mandatory... PinmemberRadim Köhler26-Sep-08 5:14 
GeneralRe: CodeProject should make this mandatory... PinmemberShivprasad koirala29-Sep-08 3:50 
GeneralRe: CodeProject should make this mandatory... PinmemberRadim Köhler29-Sep-08 21:06 
GeneralRe: CodeProject should make this mandatory... Pinmembertorial27-Oct-08 18:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

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

| Advertise | Privacy | Mobile
Web04 | 2.8.140814.1 | Last Updated 4 Feb 2012
Article Copyright 2008 by Radim Köhler
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid