<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Gojko Adzic &#187; frameworks</title>
	<atom:link href="http://gojko.net/tag/frameworks/feed/" rel="self" type="application/rss+xml" />
	<link>http://gojko.net</link>
	<description>Building software that matters</description>
	<lastBuildDate>Wed, 04 Aug 2010 11:38:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>What makes a good application framework</title>
		<link>http://gojko.net/2008/04/21/what-makes-a-good-application-framework/</link>
		<comments>http://gojko.net/2008/04/21/what-makes-a-good-application-framework/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 18:03:21 +0000</pubDate>
		<dc:creator>gojko</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[alt.net]]></category>
		<category><![CDATA[castle]]></category>
		<category><![CDATA[frameworks]]></category>

		<guid isPermaLink="false">http://gojko.net/?p=120</guid>
		<description><![CDATA[I have been using the Castle Project for about two years now, and it is definitely one of my favourite tools. It is truly a great example of how a good application framework should be written. Although all the concepts that it provides have been around for a while and became popular with other frameworks [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/images/967432_karlstein_castle.jpg" style="border:1px solid black; margin:5px 5px 5px 5px;" align="left" />I have been using the Castle Project for about two years now, and it is definitely one of my favourite tools. It is truly a great example of how a good application framework should be written. Although all the concepts that it provides have been around for a while and became popular with other frameworks like Spring for Java or Ruby on Rails, the Castle Project brings them together in a very effective way and makes enterprise .NET development significantly easier. <span id="more-120"></span></p>
<h2>A good framework is easy to learn</h2>
<p>Castle is, for a .NET framework, refreshingly light-weight and loosely coupled. It consists of three major components: Windsor/Microkernel dependency injection container, Monorail Web model-view-controller engine and ActiveRecord object-relational mapping library. All Castle modules are simple and focused on a single thing only: Windsor does object wiring and configuration, Monorail routes web requests and ActiveRecord maps objects to database rows. Even better, they can be used in isolation or as a combination. Being clearly focused and nicely encapsulated makes Castle components fairly easy to understand. We are not required to eat the whole elephant just to get the benefits of a simple inversion of control engine, or to use the MVC pattern.  That makes the learning curve really short. Windsor and ActiveRecord are so easy to understand that people typically start using them effectively after just a few hours of experimenting. Working with a MVC engine can require quite a mind shift if you have only used ASP.NET web forms, but if you have ever played with anything that resembles a MVC, then you should feel right at home with Monorail as well.</p>
<h2>A good framework helps but does not get in the way</h2>
<p>Castle&#8217;s dependency injection container, Windsor, allows us to benefit from inversion of control, but keep writing code the way it makes sense for us. Like Spring, it can auto-wire objects of any type. To use Castle&#8217;s services, our objects do not have to be written in any specific manner or contain Castle-specific stuff. Advanced features, like declarative transactions, can be configured externally without code modifications or applied to the classes using .NET attributes, that still allow the same code to be executed and reused outside of Castle. </p>
<h2>A good framework works in harmony with other popular tools</h2>
<p>I also like very much the practice to integrate rather than reinvent, taken from Spring. Each Castle component is clearly focused on a single thing and does it really well, and integrates with other popular opensource libraries and tools to do the rest. Instead of enforcing its own logging framework upon users, Castle components allow us to choose between Log4NET and Nlog. Monorail comes with the Brail template engine developed by the Castle team, but we do not have to use it. We can get the full benefits of Monoral with pages designed using NVelocity or ASP.NET forms templates as well. </p>
<h2>A good framework makes simple things easy to do, but allows us to do complex stuff as well</h2>
<p>ActiveRecord allows us to quickly create database backed objects by using simple code attributes and avoiding most of configuration typically required by ORM libraries. Should you require more advanced features, like using stored procedures instead of SQL commands for persistence, Castle also supports full-blown ORM frameworks like NHibernate and Ibatis. In fact, ActiveRecord uses NHibernate under the hood and provides default mapping configuration for its objects so that you do not have to worry about it. This idea of making simple stuff really easy to do is applied throughout the framework, promoting the use of convention over configuration (a concept made popular by the Ruby on Rails framework). For example, URLs are automatically mapped to actions by looking for the controller method that is named like the “file” part of the URL and using the “folder” part of the URL to determine the controller class name. All GET or POST parameters from the URL are automatically mapped to the action method parameters. Before Monorail, I developed a custom MVC framework for .NET based on Spring MVC. After migrating to Castle, I threw most of the configuration away &mdash; it was redundant anyway. Again, Monorail allows you to use more complex mappings with explicit configuration.</p>
<p>Convention over configuration principle is applied especially effectively in Microkernel. Microkernel deals with dependency injection and connecting application services (called components in Castle&#8217;s jargon). The real value of such libraries is providing external wiring and configuration for services, but very often there is only one type of a particular service used in the application. Microkernel automatically resolves dependencies based on the component interface. If there is only one IPlayerDAO service in the application, you do not have to explicitly reference it in the setup of every dependent component &mdash; Castle knows what you wanted to use. In addition to significantly reducing the amount of boilerplate XML that we have to write and maintain, this also makes the system easier to change. If we add a new argument to the constructor of the actual IPlayerRegistration implementation, we do not have to remember to change all the XML files where that service is defined &mdash; Windsor will wire the appropriate services automatically.</p>
<h2>Some links for the end</h2>
<p>If you are interested in finding more about the Castle project, visit <a href="http://www.castleproject.org" target="_blank">http://www.castleproject.org</a>. If you live in UK, drop by Skills Matter on the 15th of May for a <a href="http://www.skillsmatter.com/event/open-source-dot-net/agile-web-development-with-the-castle-framework">free workshop on Agile Web Development using the Castle project</a>.  </p>
<p>Image credits: <a href="http://www.sxc.hu/profile/opinto" target="_blank">Orlando Pinto</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gojko.net/2008/04/21/what-makes-a-good-application-framework/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
