Saturday, January 29, 2011

Moving to IIS and C#&ASP.NET

I decided to get some new experience working in c# and learning web patterns and common practice to create expendable, well formed and efficient web content.

So I browse a little and found Martin's Fowler site. It gives me some understanding how to build well formed content. Actually it is the same patterns that I have used in c/c++/java in application development, but now I can see it from web development prospective.

There are some useful and specific to web dev patterns:

Transform View - just a base concept. If you have data then all you are doing is transform this data in convenient for browser/user way.
Application Controller - usually this pattern implemented inside some web framework. but it is very useful. using it you can control common site behavior. Security, url parsing, external connections, styles (header,footer), etc. (security, extendability)
Page Controller - this a controller that handles particular user command on the page. (if page represent table from database than page controller should contains handlers to insert/view/delete/update commands
Template View - split html and data layer in such way that instead of real data we put getters unique strings that represent our data. layer when we build html page we replace getters with a real data. this process is more unified and thats why we can apply it to different pages without changes. This means that we can use template parser again and again without any changes. (portability, extendability)
Data Transfer Object -  I don't like to pass many parameters during function call. If you have it too much (more than three) that means you are doing something wrong (I investigate tons of frameworks and a other open source code. They are all using objects (structures) to pass params back and forth. It also solve problems when you need to add/remove some extra params. You don't need to change interface of function/class. just add new params and change implementation.(portability)

Query Object - remove language inside language (this pattern applies in lot of areas). Basically it is a wrapper in native language to represent other language. Like in sql case we need to create a sql wrapper and in common code use sql commands over wrapper. It makes code less dependent on database schema or sql syntax. (portability)

As a general concept of web dev you can use app controller to control security and localization
Template view and Data layer to build html page. Then use Javascript/flash to make your page interactive

No comments: