ALT .NET Belgium

The ALT .NET movement is getting more and more momentum in the belgian community.

Here you can find an aggregation of all the latest blog posts written by belgian ALT .NET participants.

If you have never heard of the movement before, I suggest you have a look at the 'What is ALT .NET' article from Jeremy D. Miller that appeared in MSDN Magazine in March 2008, as it clearly defines what ALT .NET is all about. The article can be found below the aggregation at the bottom of this page.

Disclaimer

All trademarks, slogans, text or logo representation used or referred to in these RSS Feeds are the property of their respective owners

Belgian Alt.Net Bloggers

The Only Way To Test Private Methods - Published At The Inquisitive Coder - Davy Brion's Blog - Thursday, November 20, 2008

I got a question from one of my readers about how to properly test private methods. She’s new to TDD and she’s not always clear yet about the best ways to test certain things. She sent me an example situation and asked me how she should properly test it. I think the only way <...>

Gotta Love Spam - Published At The Inquisitive Coder - Davy Brion's Blog - Tuesday, November 18, 2008

I get a lot of spam comments on this blog, and luckily most of them are filtered out by the Wordpress Akismet plugin. But as with any anti-spam technology, sometimes a couple of them make it through, and sometimes legitimate comments are flagged as spam. So i generally keep an eye on the <...>

Agile Development Going Downhill? - Published At The Inquisitive Coder - Davy Brion's Blog - Monday, November 17, 2008

James Shore (author of the fantastic book: The Art Of Agile Development) wrote a very interesting post on his blog: The Decline And Fall Of Agile. You should definitely read it. I’m afraid i agree with James. Over the last few years i’ve heard a lot of people saying they were doing Agile development, <...>

Compiler Enforced Disposal? - Published At The Inquisitive Coder - Davy Brion's Blog - Sunday, November 16, 2008

I stumbled upon a blog post by Kim Hamilton on When To Call Dispose. The most interesting part about the post is that this is from someone who works on the Base Class Libraries team. The following part is especially striking: A recent internal email thread unearthed extreme differences of opinion about when Dispose(void) <...>

Chain of Responsibility Using Castle Windsor and a First Experience With StructureMap - Part 2 - Published At Share the intellectual wealth - Sunday, November 16, 2008

In my previous post, I outlined an issue that I had with Castle Windsor for configuring multiple chains of responsibility. I want to have different ProcessConsumer classes that require a slightly different chain of processors: ProcessConsumer1 -> Processor1 -> Processor2 ProcessConsumer2 -> Processor3 -> Processor1 -> Processor2 Solution with Castle Windsor For achieving this scenario using Castle Windsor, without it throwing a CircularDependencyException at me, I needed to split up the IProcessor interface and the BaseProcessor class like so: public interface IProcessor
{
void Process(Request request);
}

public interface IChainableProcessor : IProcessor
{
IProcessor Successor
{ get; set; }
}

public abstract class BaseProcessor : IProcessor
{
public virtual void Process(Request request)
{
// Some base class behaviour
FurtherProcess(request);
}

protected abstract void FurtherProcess(Request request);
}

public abstract class BaseChainableProcessor : BaseProcessor,
IChainableProcessor
{
public IProcessor Successor { get; set; }

public override void Process(Request request)
{
base.Process(request);
if(null != Successor)
{
Successor.Process(request);
}
}
}

Chainable processors can now derive from the BaseChainableProcessor class and those processors that should come last in the chain can continue to derive from the BaseProcessor class.

This approach no longer results in circular dependencies. Although it works, I don't like this solution that much because now I can no longer change the order of responsibilities by simply altering the IoC container configuration. If I want to achieve that, I possibly have to change some code as well. This also means that some processors must always come last in the chain, which is not always feasible in complex scenarios.

Solution using StructureMap

One of the things I want to explore in the next couple of months is StructureMap. I was wondering whether this particular IoC container can solve this issue without having to split up the IProcessor interface and BaseProcessor class. It appears that StructureMap can indeed handle this scenario in a graceful way. I just needed to rip out Castle Windsor and replace it with the StructureMap goo. Below you can see the DependencyContainer class that I've been using for this example:



public class DependencyContainer
{
public void Configure()
{
ObjectFactory.Initialize(x =>
{
x.AddRegistry(new CORRegistry());
});
}

public T ResolveT>()
{
return ObjectFactory.GetInstanceT>();
}
}

Really straightforward stuff. I derived a class from StructureMap's Registry class and added it to the ObjectFactory. Here is the code for my derived registry class:



public class CORRegistry : Registry
{
protected override void configure()
{
ForRequestedTypeIProcessor>()
.TheDefault.Is.OfConcreteTypeProcessor1>()
.WithName("Processor1")
.SetterDependencyIProcessor>()
.Is(y => y.OfConcreteTypeProcessor2>());

ForConcreteTypeProcessorConsumer2>()
.Configure
.CtorDependencyIProcessor>()
.Is(x => x.OfConcreteTypeProcessor3>()
.SetterDependencyIProcessor>()
.Is(y => y.TheInstanceNamed("Processor1")));
}
}

That's all I had to do. Everything just works now. I really like the way StructureMap handles things (registry classes) and its configuration is quite easy. This code could probably be improved as these are my first baby steps as a noob. This first pleasant experience certainly motivates me to do some more goofing around with StructureMap.

As always, I'm open for suggestions.

Till next time,

Jan, the injected

Chain of Responsibility Using Castle Windsor and a First Experience With StructureMap - Part 1 - Published At Share the intellectual wealth - Sunday, November 16, 2008

A couple of months ago, I applied the Chain of Responsibility pattern for the very first time. I've never encountered a scenario before where applying this pattern would be a valid option. But now, after some refactoring, I somehow naturally ended up applying this rarely used design pattern. Lets dive into some code, shall we? public interface IProcessor
{
IProcessor Successor
{ get; set; }

void Process(Request request);
}

public abstract class BaseProcessor : IProcessor
{
public IProcessor Successor { get; set; }

public void Process(Request request)
{
// Some base class behaviour
FurtherProcess(request);
if(null != Successor)
{
Successor.Process(request);
}
}

protected abstract void FurtherProcess(Request request);
}

This is the base class for all processor classes (bad naming, huh?) . If there is a follow-up processor available, then its Process method is called. The processor classes can now focus on their main responsibility:



public class Processor1 : BaseProcessor
{
protected override void FurtherProcess(Request request)
{
// Do something usefull
}
}

I'm using Castle Windsor to chain together the different processors in the particular order that I want. This involves setter injection for the Successor property. Although I'm not a huge fan of setter injection, in this case it seems like a viable option. The following example uses the fluent interface of Castle Windsor for configuring the container:

_container.Register(
Component.ForProcessorConsumer1>()
.Named("ProcessorConsumer1")
.Parameters(Parameter.ForKey("processor")
.Eq("${Processor1}")),

Component.ForIProcessor>()
.Named("Processor1")
.ImplementedByProcessor1>()
.Parameters(Parameter.ForKey("Successor")
.Eq("${Processor2}")),

Component.ForIProcessor>()
.Named("Processor2")
.ImplementedByProcessor2>());

Nothing much to it. The ProcessConsumer class simply gets the first processor injected through its constructor. The above configuration results in the following chain:

ProcessConsumer1 -> Processor1 -> Processor2

Everything is fine and dandy so far. Now suppose that I want to add another ProcessConsumer that requires a slightly enhanced chain of processors like so:

ProcessConsumer1 -> Processor1 -> Processor2

ProcessConsumer2 -> Processor3 ->  Processor1 -> Processor2

This is how the configuration of Castle Windsor now looks like:

_container.Register(
Component.ForProcessorConsumer1>()
.Named("ProcessorConsumer1")
.Parameters(Parameter.ForKey("processor")
.Eq("${Processor1}")),

Component.ForProcessorConsumer2>()
.Named("ProcessorConsumer2")
.Parameters(Parameter.ForKey("processor")
.Eq("${Processor3}")),

Component.ForIProcessor>()
.Named("Processor1")
.ImplementedByProcessor1>()
.Parameters(Parameter.ForKey("Successor")
.Eq("${Processor2}")),

Component.ForIProcessor>()
.Named("Processor2")
.ImplementedByProcessor2>(),

Component.ForIProcessor>()
.Named("Processor3")
.ImplementedByProcessor3>()
.Parameters(Parameter.ForKey("Successor")
.Eq("${Processor1}")));

With this particular configuration, Castle Windsor now throws an exception with the following description:


A cycle was detected when trying to resolve a dependency.


After some investigation it seems that Castle Windsor wants to set the Successor property of Processor2 with the instance of  Processor1, which is not what I had in mind. The Successor property of Processor2 should remain empty. I believe this has something to do with the approach that Castle Windsor is taking to never inject a null reference, although I'm not completely sure.

Anyway, I got around this issue by splitting up the IProcessor interface and the BaseProcessor class as outlined in my next post.

Sigh… Why Must Microsoft Keep Disappointing Me - Published At The Inquisitive Coder - Davy Brion's Blog - Saturday, November 15, 2008

As some of you may already know, i only use a Mac at home. I have Parallels installed with a virtual Windows XP that i only use to run Visual Studio 2008 in. This week, Parallels introduced the 4.0 version of their Parallels Desktop product, so i gladly payed for the upgrade. I <...>

Using ExtJS grid in your ASP.NET MVC application - Published At Bart blogs - Tuesday, November 11, 2008

In this second code drop for the WineCellarManager on ASP.NET MVC I added an ExtJs grid. To be able to run the new version there are a couple of things you'll need to do: Update your database schema A new Migration was added  to the migration project: Migration003AddWineRelatedTables. You run this migration with the Migrator.Console which you'll find in the "libs" directory. Here is an example command that you can use to run it: "Migrator.Console.exe "SqlServer" "Server=localhost\SQLEXPRESS;initial catalog=wines;Integrated Security=SSPI" d:\OSS\WineCellarManagerASPNETMVC\WineCellar.Migrator\bin\Debug\WineCellar.Migrator.dll" You do have to change the path to the migrator assembly of course and probably also the connection string. Update Rhino.Security operations I have added a WineController which has some actions but to be able to use them you should update your Rhino.Security operations. To do that: run the application and navigate to: localhost:portnumber/Permission/Generate. When you look in the code of the "PermissionController" you'll notice that it adds those permissions for a user called "bart". That's the one that is being added by migration 2 as well. If you want another user: change migration 2 and the PermissionsController. Add some wines to your database Navigate to localhost http://localhost:portnumber/Wine/GenerateWines. The system will add some wines to the database and show a message when that is done. If you want the grid to work correctly you should use this way of adding wines because otherwise they are not added to the Lucene index. Now you should be set to go. If I missed something here, please let me know! What's new: ExtJs grid The list of wines is shown using an ExtJS grid. Out of the box this grid has some pretty cool features. For most of them there is of course some server side code needed. Following features are implemented (next to the features that are out of the box supported by the grid and don't need a server side): Paging: Rhino.Tools - FutureQueryOf is being used here Filtering and sorting on each column of the grid: A big thank you to NHibernate Criteria Quick search box: wouldn't have been possible without NHibernate.Search. You can check out the "GetWines" action method in the "WineController" to see how it's done and underneath is a screenshot of the grid. I use a HtmlHelper extensions method to generate the grid (see class: HtmlHelperExtensions). Doing so you avoid having to type a lot of JS code each time you want this grid on your page and each grid looks exactly the same because it is generated in the same way ;-) If there is anything unclear let me know! The code is here: http://code.google.com/p/winecellarmanager/

iPhone Tech Talk Amsterdam - Published At Benny Michielsen - Monday, November 10, 2008

In October I read about the iPhone Tech Talk tour and immediately registered for the event. I'm still teaching myself Cocoa so I thought this could be helpful. Only a week before the actual start time people got their registration confirmations and I was one of the lucky few. While I can't go into detail about the content of the event, since I'm bound by the NDA. Which is strange to say the least, wouldn't you want people who take the time to go to your event to talk about it with others?Anyway, the actual agenda varied from the one posted on the website. The presentations I saw were: iPhone Development Overview
iPhone User Interface Design
iPhone Development Tools Overview and Programming Concepts
Introduction to Objective-C and Cocoa Touch
Developing iPhone Applications with UIKit
Maximizing Your Application's Performance on iPhone
Submitting to the App Store using iTunes Connect
If you compare this with their original list, you see that there were a lot more sessions than originally planned and as a result the speaker had a lot of trouble fitting it all in his schedule. Which is disappointing, removing two or three topics would have been better especially since there was a lot of overlap between some of them. User Interface Design for instance explained all the different controls available and this was repeated again in the UIKit presentation. What would have been better was explaining the concepts behind it in the first session and then actually implementing a sample application using the UIKit. Model View Controller was also explained three times, why not explain it once and show code the second time. Knowing the theory behind it is good, but actually showing us why some things are in place would have been better.Did all this make it a useless event? Certainly not, if there is one in the future I hope I will be able to attend again and because this was the first time Apple organized something like this they probably still have to learn what content fits and what not.And ow yeah, catering was excellent! ;) 

Book Review : Beyond Code - Published At Share the intellectual wealth - Monday, November 10, 2008

I read Beyond Code during my flight to Austin for the Kaizenconf. It was a quite enjoyable book that focuses on how to distinguish yourself as a software developer. As you may suspect, there is no code in this book. Instead, Rajesh Setty provides 9 simple steps that makes the difference between a code monkey and a caring, disciplined software professional. If life as a whole is a game, then there are two kinds of games: the inner game and the outer game. The inner game we play with ourselves, while the outer game is played with the external world. Both games are important, so the author puts out a lot of advice to succeed in both of them. Inner Game Learn: Continuous improvement is key. This does not only mean how to dig new cool technologies, patterns and practices. This also means learning how to accomplish long-term relationships with other people, learning how to communicate with others, learning to be congruent and how to adapt quickly to ever changing situations. Laugh: When you make a mistake, laugh about it, learn and move on. Look: How to deliver beyond what is expected of us. Try to look beyond the horizon. Lasting impression: Every opportunity you get is a chance to add significant value and an impact that doesn't go unnoticed. Love: Just love your job. Outer Game Leverage: How to leverage as an individual and most importantly as a team. The most obvious leverage points are people, books, blogs, magazines, etc. Likeability: I know I fail on this sometimes, but one can accomplish far more if others like us. If we are not likeable, then things can get quite difficult sometimes. Listen: Start listening to start succeeding. Lead: Look for opportunities to lead. Try to identify voids and step into the gap. You can take advantage of these leadership moments. Doesn't this get you interested? Tom Peters ends his foreword with the sentence "Read this book as if your life depends on it. It does!". Strong words, slightly exaggerated, but somewhat truthful as well. This book contains a lot of good advice. It's only 120 pages, so what do you have to loose? Till next time

Be careful with optional parameters in C# 4.0 - Published At Share the intellectual wealth - Sunday, November 09, 2008

I've been playing with the Visual Studio 2010 CTP bits, and I tried to see what named and optional parameters in C# 4.0 can bring to the table. Although they are minor language enhancements at best, they can cause a lot of grief as well. In my former life as a C++ developer, optional parameters were quite handy in some cases to remove some ceremonial code for providing obvious overloads of a method. Since I came over to the .NET platform, I actually don't miss optional parameters. I just wanted to share a common abuse of optional parameters that you should be aware of. The following code illustrates this: public class Base
{
public virtual void Foo(Int32 x = 1)
{}
}

public class Derived
{
public override void Foo(Int32 x = 2)
{}
}

...

Base f0 = new Base();
f0.Foo(); // Invokes Foo(1)

Base f1 = new Derived();
f1.Foo(); // Also invokes Foo(1)

Derived f2 = new Derived();
f2.Foo(); // Invokes Foo(2)



This is something you have to watch out for. The object's member function silently takes different arguments depending on the static type you use. This violates the principle of least surprise and is a general PITA. Don't violate the method contract that has been provided by the base class.

Don't say I didn't warn you ;-)

Alt.net - November meeting - Published At Yves Goeleven - Friday, November 07, 2008

It's becoming a monthly habit, which is a good thing ;).

The november edition of the 'dutch alt.net' meeting will happen on the 20th, again at the cronos offices: Cronos, veldkant 33a, Kontich. Zaal Mercator.

This time we will be discussing FIT testing, Functional programming and I hope Jan or Peter can give us a small report of KaizenConf....

Kaizenconf Part 3 - Taking Action - Published At Share the intellectual wealth - Wednesday, November 05, 2008

The last day of the conference was all about taking action as a community. Which actions should be taken based on the open-space sessions of the day before? I attended the ESB Patterns session which mostly handled actions for the MassTransit open-source project. Again, the notes of the other "action" sessions are available on the wiki. I gained a lot of new insights from being at this conference and I realized that I need to learn some more. I know that its kind of early for New Year's resolutions, but I want to put out a number of actions for myself. Learn more about ESB/integration patterns. Diving into the code of MassTransit and NServiceBus will probably give me more insights. I need to get up to speed on web development really soon. I finally need to be proficient at JavaScript, CSS and jQuery. On the programming language front, I need to get back to Boo and want to add Ruby and F# to my tool belt. I've been a fervent user of Castle Windsor for my IoC needs, but I also want to take a look over the fence by leveraging StructureMap because I have the feeling that I'm missing out on some cool stuff. Determining which NHibernate contrib projects can be useful, like NHibernate Search, NHibernate Burrow, NHibernate Caching, etc. .... And last but not least, improving on my development methodologies by learning more about Lean, Kanban, the Toyota Way, etc. ... Further improving my DDD and BDD skills. I know that this is very ambitious, but hey, it's my list. I hope that I can look back at this post next year while having learned and accomplished most of the items on this list. I want to round of this post by saying kudos to Scott Bellware, Dave Laribee and all other attendees for a wonderful learning experience. Also a special thanks to Michael , Conrad and the other guys for driving and letting me and Peter tag along. I also finally got to meet fellow Elegant Coder Jarod Ferguson and others who I previously only knew by name or blog picture. I really enjoyed it. Till next time

Kaizenconf Part 2 - Open Space - Published At Share the intellectual wealth - Wednesday, November 05, 2008

After the pre-conference workshops, it was finally time to kick-off the open-space conference itself. Before Steven "Doc" List held his opening speech, Oren and Glenn couldn't wait and began sharing their thoughts: After the fish-bowl session, the self-organizing geek thing happened and resulted in a number of sessions on the board. On the next morning, a long and exhausting day was ahead of us. A wide variety of topics where chosen, so I needed to make some though decisions about which sessions I was going to attend. You can have a look at the Kaizenconf wiki for all the open-space sessions (as well as the workshop sessions) and the notes that where made during these sessions by the different people who were there. I attended the following open-space sessions: Beyond Traditional Architecture - Saying Goodbye to RDBMS and Friends Thinking Functionally (Functional Programming Languages) Rhino Tools / Producing Production Quality Software ESB Patterns & Implementation with MassTransit Advanced IOC Beyond Constructor Injection A lot of great conversations and I wished that I could split myself up so that I could be in several session rooms at once. Keep an eye on the wiki that I just mentioned, because links to the different video recordings will be posted there.

Kaizenconf Part 1 - Workshops - Published At Share the intellectual wealth - Wednesday, November 05, 2008

My colleague Peter and myself got back yesterday from Austin, Texas where we had one of the greatest learning experiences ever: the Kaizen Continuous Improvement Conference. I've really been looking forward to this event and it exceeded my already high expectations. Before the actual open-space conference, there were two days with workshops. In this post I want to highlight some things I learned from these workshops. Advanced NHibernate (Ayende Rahien) I guess that the speaker of this session needs no further introduction. As one of the major contributors of my favorite ORM, he is the right person to talk about some of its advanced usages. Here are some random notes: The NHibernate profiler looks really cool. NH is not a 100% solution. Only use NH for an OO view of the world. If you're only interested in data or transforming/reporting, then use something else. A single session can have multiple transactions. NH 2.1 adds PostSharp support for removing the need for virtual properties/methods (proxies/lazy loading). Adaptive Domain Models (e.g. Rhino Security) Multitenancy (e.g. different domain models or databases for different customers). NH profiler is freakin' cool. NHibernate Search = Lucene.NET + NHibernate. Lucene.NET: file store + full text search. FullTextSearchSession only necessary for full text search (through its extra methods). Using a regular NH Session also ensures that the Lucene.NET index gets updated. NHibernate uses 4 different caches:§ First level cache (also identity map at the session level) § Second level cache (session factory level) Entities cache Collections cache Timestamp Query cache Enable second level cache at entity level in the mapping files. This also goes for the collection and the entities that populate the collection!! Enable query cache -> SetCacheable(true) on criteria query and enable query cache in the configuration file. Cache regions -> SetCacheRegion on criteria query. Prevalence cache can best be used for smart clients (single machine). SysCache uses the ASP.NET caching (single machine). SysCache2 provides support for SQL dependencies for the ASP.NET cache (not recommended). MemCache is used for distributed applications. Velocity is also used for distributed applications. Did I already mention that the NH profiler is really cool, because it is. DDD Chalk Talk (Dave Laribee) This session was a real mind stretcher for me. I've come to realize that I need to reread the "blue book" again. I've got way too many notes from this workshop. I'll just put out some of the topics that were discussed: DSLs in relation to Rich Domain Model Publishing vs protecting a model Verbs vs Domain services Command Query Seperation Model Controller Test models (Michael Feathers) How to introduce/get started with DDD Complexity Bounded context vs Context maps I saw that a lot of people were recoding this session, so I have a suspicion that it will become available somewhere very soon. Using and Abusing ASP.NET MVC for Fun and Profit (Jeremy D. Miller and Chad Meyers) Jeremy and Chad shared their opinionated approach to using ASP.NET MVC for efficiently creating web applications. This very neat stuff is already lined out by this post from Jeremy. I heard some rumors on Twitter that Chad is working on releasing some of the code as open-source. The videos of this workshop are available here. Presentation Patterns (Jeremy D. Miller and Glenn Block) This was probably one of the highlights of the pre-conference workshops. There was this amazing back and forth between Jeremy and Glenn that I just forgot to make notes. I hope someone recorded this "masterpiece" because I want to watch it again. I thought that I already knew a lot about Passive View, Supervising Controller, Presentation Model and other companying presentation patterns. I soon realized that I am just a noob and took away lots of stuff from this session. After the workshops, the open-space conference could finally begin ...

Revolutionary Security - Published At The Inquisitive Coder - Davy Brion's Blog - Tuesday, November 04, 2008

Just restarted Visual Studio… no other changes were made to my system since the last time i started Visual Studio. And all of a sudden, i got this: Microsoft doesn’t get nearly enough credit for their revolutionary security practices… great job guys, thanks for keeping us all safe

ASP.NET MVC and Rhino Tools Sample - Published At The Inquisitive Coder - Davy Brion's Blog - Monday, November 03, 2008

Bart Reyserhove, a fellow Dutch ALT.NET member, put up a sample ASP.NET MVC application that uses some of the Rhino Tools, and he’s planning on showing off some more interesting technologies with it as he further develops the sample. I’m definitely gonna look at that sometime this week, as i’m sure this should be <...>

NHibernate.Search and NHibernate configuration - Published At Bart blogs - Monday, November 03, 2008

When you are using Rhino.Tools and NHibernate and want to use NHibernate.Search you have to set some extra configuration options. The problem is that you cannot do that in the traditional "hibernate.cfg.xml" because the XML schema will not allow you. In case you are using the UnitOfWorkApplication of Rhino.Commons the NHibernate configuration is loaded in Rhino.Commons and you cannot really touch it, unless you adapt the Rhino.Commons source code, which is something you don't want to do, because the change you are making is not for everyone and doing so you loose the possibility of future upgrades... As always there is a solution and it's called "INHibernateInitializationAware". Here you can intercept the Nhibernate configuration. Here is how you do it: 1: public class CaptureConfiguration : INHibernateInitializationAware

2: {

3: public static Configuration cfg;

4: 

5: #region INHibernateInitializationAware Members

6: 

7: public void BeforeInitialization()

8: {

9: }

10: 

11: #endregion

12: 

13: public void Configured(Configuration cfg)

14: {

15: cfg.SetProperty("hibernate.search.default.directory_provider",

16: "NHibernate.Search.Store.FSDirectoryProvider, NHibernate.Search");

17: cfg.SetProperty("hibernate.search.default.indexBase", "~/Index");

18: }

19: 

20: public void Initialized(Configuration cfg, ISessionFactory sessionFactory)

21: {

22: CaptureConfiguration.cfg = cfg;

23: }

24: }



Don't forget to register this in you Binsor configuration:



1: component INHibernateInitializationAware, CaptureConfiguration



and you're set to go...

ASP.NET MVC and Rhino Tools sample application - Published At Bart blogs - Sunday, November 02, 2008

It was on my planning already for a long time but this weekend I took a couple of hours to create an ASP.NET MVC sample application. The application itself is for the moment very, very basic, but the idea is to add features to add that demonstrate how you can use ASP.NET MVC in combination with Rhino Tools, NHibernate, Nhibernate Search, Migrator.NET, Windsor, Binsor, ExtJS grid, and probably even some others. I did not have that much inspiration, so the idea is to create an ASP.NET MVC version of the WineCellarManager, which is built with Castle Monorail. This first version contains the following: Integration with Windsor: the Controllers are created via Windsor and the configuration of Windsor is done using Binsor. Integration with Rhino.Security: I have a base "WineCellarController" that has an "AuthorizationAttribute". That means that every controller that derives from WineCellarController will pass the authorization module. This attribute was created by a colleague on my project. It uses the IAuthorizationService from Rhino.Security to verify whether the logged in user is allowed to perform the requested action. There is also a PermissionController with a Generate action that you can use to generate permissions for all actions of all controllers. On our project we have the intention to use an attribute on Controller Actions to allow you to group actions in one security operation or to not add a Controller action as an operation, but that is not entirely finished yet. Use of Migrator.NET to create the database schema: there is a project in the solution: WineCellar.Migrator that is used to add database migrations. You execute the migrations using the Migrator.Console.exe which is included in the libs. In the first migration is a comment that tells you which parameters to add to the console application. Integration with Rhino.Commons by using the UnitOfWorkApplication of Rhino.Commons. Console application for Rhino.Security setup: there is also a small console application included that I used to create the database schema for Rhino.Security. I added that afterwards to the migrations, but you can still have a look to see how it's done. Next steps: Demonstate how you can use an extension method on HtmlHelper to add security on field level. Integration of NHibernate.Search Integration of ExtJs grid using HtmlHelpers. I almost forgot to tell you where to get the source. It is here: https://winecellarmanager.googlecode.com/svn/trunk/WineCellarManagerOnASPNETMVC UPDATE: I noticed you need a password to check out the code on the link above. You should be able to get it without password in the following way: svn checkout http://winecellarmanager.googlecode.com/svn/trunk/ winecellarmanager-read-only

The Upcoming NHibernate Posts - Published At The Inquisitive Coder - Davy Brion's Blog - Sunday, November 02, 2008

Some people asked me about the NHibernate posts i’ve got planned… so here’s a list of posts that i have in mind: Exploring NHibernate Statistics, Part 2: Data Modification Exploring NHibernate Statistics, Part 3: Stats On Specific Queries Exploring NHibernate Statistics, Part 4: Caching Getting Up To Speed With NHibernate’s 2nd Level Cache User Types Event Listeners Result Transformers Transaction Management Concurrency Management Components & <...>

Austin and Kaizenconf Part 1 - workshops - Published At Peter works on the web! - Sunday, November 02, 2008

It's finally there, Jan and I departed from Belgium to Austin, Texas to attend Kaizenconf. I have been looking forward to this for quite a while. It didn't start out good when I spilled my first drink on the plane, but it only got better from then on. After a long flight with a stopover in Atlanta we arrived at the Austin airport. A lot smaller then I expected but that didn't really matter. Advanced NHibernate On the first 2 days of Kaizenconf some promising workshops where scheduled, we decided to go listen to the great ayende talking about Advanced NHibernate. The talk started off with a blast when ayende gave a demo of the NHibernate Profiler that is being developed. Although beta it looks like this will be a real hit and it will help developers to get to know and control NHibernate better. I don't see myself as an advanced NHibernate user but it was nice to follow a workshop that isn't the usual introduction on how to create a Northwind CRUD application. Below is a screenshot of the NHibernate Profiler, although it's not the best of quality you can see the query that NHibernate has generated, the different queries that were fired onto the database and much more. Very, very promising!   Another topic that was explained is the use of Lucene with NHibernate. By using a couple of attributes on your domain models to indicate which parts should be indexed, you get a very easy way to make your data searchable. Because the original is always better, here is a short video where the advantages of using Lucene with NHibernate are explained:
Advanced NHibernate: Lucene NHibernate Search from Two to Tango on Vimeo. We went on to NHibernate caching and again I discovered something that will change the way I use NHibernate on a daily basis. Seems like caching is actually very intelligent but, as with everything, you have to watch out not to shoot in your own foot. Oren showed us an example that called the database 4 times without using any caching and called the database 42, yes forty-two, times with badly configured caching. Here are some random notes I took that I'd like to keep in mind for future use of NHibernate: - When loading an object via session.Load the query gets fired when the object is being accessed, not when the Load() function is called - NHibernate solves threading issues with caching by returning different instances of the same object to different users - Queries can also be cached, call the SetCacheable(true) function on every occurrence of the given query you want to cache After this excellent session we were looking for something to eat. Luckily some of the attendees (thank you Chris and Tim) were kind enough to give us a ride to Rudy's BBQ where we learned that 'Real people eat meat'. I don't think they have a lot of veggies under their customers. Functional programming - Is it a game changer? For the second workshop a difficult choice had to be made. It was choosing between the DDD chalk talk of David Laribee or the workshop about Functional programming of Matt Podwysocki. You probably already guessed the one I chose. This was something completely different then the NHibernate talk and Matt asked several times if our brain hadn't exploded yet, and if I'm honest I had to answer yes every time he asked it. There was a lo-hot of information to take in. The first part of the presentation was about making C# more functional. By heavily using the new features in C# 3.0, a lot of for-each loops could be eliminated with the help of stuff like LINQ and lambda expressions. Matt told us that F# is very good at math stuff, the software that determines the best player in Halo 3 is written in F#. Because F# has a specific purpose, there will never be a designer to create GUI's or web pages using F#. I think I heard a little cheering in the room after those words. I still have to take a closer look to the abundance of examples Matt provided us to be able to give a deeper insight into F# so I'll leave it at that for now. Although I'd like to show a piece of code that Matt shared to point out the dangers that come with lazy evaluation of code: FuncString> GetContent;   using(StreamReader fileStream) {    GetContent = fileStream.ReadToEnd(); }   String content = GetContent(); Because the fileStream is out of scope when calling the GetContent function reference, this will give unexpected behavior which is very hard to debug if you ask me. Another good session for which I'd like to thank Matt. The conclusion of the first day of kaizenconf is very good. As I already said the sessions were of high quality. I'm already looking forward to day 2 which has an ASP.Net MVC session given by Jeremy Miller and Chad Myers. Very exciting!

Integrate Rhino Security with ASP.NET MVC - Published At Bart blogs - Friday, October 31, 2008

As promised  a follow up post on my first post on Rhino Security. This post will deal with the integration of Rhino Security in ASP.NET MVC. In our application we need to deal with different levels of security: Security on field level: some users cannot see certain fields Security on operations. Security on the data a user can see. e.g. a certain user can see vehicles but not the BMW's. That means that in each query that is sent to the database the BMW's need to be filters out. For now I will focus on 1 and 2 and I hope to find some time to come back on 3 in a next post. But before we do all that we have to some preparations: Preparations We have created our own base Controller that derives from the System.Web.Mvc.Controller. That Controller has an attribute: Authorization. This "AuthorizationAttribute" derives from the default "ActionFilterAttribute" and first checks whether the user is authenticated and after that it checks whether the user is authorized to perform the action that is requested. That brings us to security on operations: Security on operations On each public action method we add an attribute "SecuredOperation" and the "AuthorizationFilter" checks whether the logged in user is authorized to perform the requested action using the "Rhino.Security.Interfaces.IAuthorizationService". That means of course that we need to add all "SecuredOperations" to Rhino.Security. Now, that is quite easy. We just loop over all action methods with the "SecuredOperation" attribute and add them to Rhino.Security using the IAuthorizationRepository. Security on operations is not enough in our case. In some cases we also need security on field level. It turns out that ASP.NET MVC makes this really easy to do Security on field level Extensions methods are key here. You are probably already using the "HtmlHelpers" in your application. To include security you just need to extend those and use the extended ones. You create for example a "Html.SecuredTextbox" and a "Html.SecuredActionLink". In the implementation of those you check whether the user has access to the field or operation and you deal with it accordingly. In the case of the textbox you can for example show it, show it disabled or not show it. Conclusion This post shows that without a lot of effort you can integrate the powers of Rhino.Security in ASP.NET MVC and of course you can do exactly the same in Castle.Monorail. I hope to find some time in the coming weeks to write about secured queries, meaning that you restrict query results based on the user rights.

LINQ To SQL On The Way Out - Published At The Inquisitive Coder - Davy Brion's Blog - Friday, October 31, 2008

On October 20th, i wrote this in a comment: i have zero interest in LINQ To Sql because i think it will ultimately be neglected (or even dropped) by Microsoft to increase adoption of Entity Framework And there we go.

Bulk Data Operations With NHibernate’s Stateless Sessions - Published At The Inquisitive Coder - Davy Brion's Blog - Thursday, October 30, 2008

In my previous post, i showed how you can configure NHibernate to batch create/update/delete statements and what kind of performance benefits you can get from it. In this post, we’re going to take this a bit further so we can actually use NHibernate in bulk data operations, an area where ORM’s traditionally perform pretty <...>

Attending the Kaizenconf - Published At Share the intellectual wealth - Thursday, October 30, 2008

Peter and yours truly arrived at Austin yesterday for attending the Kaizenconf. I've been really looking forward to this. Hope to meet you there. If you see two goofy European guys wandering around, just say hi ;-).

Some Info About Upcoming Content - Published At The Inquisitive Coder - Davy Brion's Blog - Tuesday, October 28, 2008

Just wanted to give you guys a bit of a heads up about some of the upcoming content i’ve got planned for this blog. I’ve been posting more about NHibernate lately, and i’ve actually got 12 other NHibernate-related posts planned for the coming weeks/months. For those of you who aren’t really interested in <...>

Batching NHibernate’s DML Statements - Published At The Inquisitive Coder - Davy Brion's Blog - Monday, October 27, 2008

An oft-forgotten feature of NHibernate is that of batching DML statements. If you need to create, update or delete a bunch of objects you can get NHibernate to send those statements in batches instead of one by one. Let’s give this a closer look. I have an ‘entity’ with the following mapping:  

Exploring NHibernate Statistics, Part 1: Simple Data Fetching - Published At The Inquisitive Coder - Davy Brion's Blog - Sunday, October 26, 2008

One of the new features that NHibernate 2.0 introduced is NHibernate Statistics. This feature can be pretty useful during development (or while debugging) to keep an eye on what NHibernate is doing. Not a lot of people know about this feature, so i’ve decided to write a short series of posts about it. <...>

New Version Of CopySourceAsHtml Available - Published At The Inquisitive Coder - Davy Brion's Blog - Sunday, October 26, 2008

CopySourceAsHtml is a great Visual Studio plugin that i use to post my source code on this blog. The author has recently released a version that fully supports Visual Studio 2008. You could already use the old version with VS2008, but you had to do some things manually to get it working… this new <...>

Career Advice For Young Developers - Published At The Inquisitive Coder - Davy Brion's Blog - Saturday, October 25, 2008

Over the past few years, i’ve seen a few young developers make some not-so-smart decisions about their careers and futures. I’ve always found situations like that frustrating because i hate seeing good developers make bad choices. So i decided to write down a bit of career advice for young developers: Make sure you like <...>

What is ALT .NET? - By Jeremy D. Miller

Note: This is an excerpt from the MSDN Magazine, March 2008 edition, the original can be found here.

Last year David Laribee coined the term "ALT .NET" to describe a coalescing community of like-minded individuals within the larger world of the Microsoft® .NET Framework who felt a growing frustration that Microsoft tooling, guidance, and .NET culture at large did not reflect or support an important set of core values. In October 2007, some hundred-odd souls descended upon Austin, Texas, for the first ALT .NET Open Spaces event, turning the blogosphere buzzword into something more tangible and kicking off the formation of a real community.

So what is ALT .NET? And how does it differ from the .NET that we already know and love? What are these values that many of us think are missing? What are these alternative tools, techniques, and practices that ALT .NET'ers are espousing? Let's first examine the original tenets of being an ALT .NET developer.

  1. You're the type of developer who uses whatever works while keeping an eye out for a better way. One of the common topics at the ALT .NET event was closing gaps between requirements, testing, and code. There's still fat in the way we develop software that can be eliminated.
  2. You reach outside the mainstream to adopt the best of any community: Open Source, Agile, Java, Ruby. In no way does Microsoft or the .NET community have a monopoly on good software development. For instance, Agile processes and Design Patterns started with Smalltalk. Likewise, Inversion of Control tools and techniques originated in Java. And two fundamental Ruby on Rails principles—Don't Repeat Yourself and Convention over Configuration—are ones that we can adopt in .NET.
  3. You're not content with the status quo. Things can always be more elegant, more mutable, and of higher quality. We're all experimen