June 2006
M T W T F S S
« May   Jul »
 1234
567891011
12131415161718
19202122232425
2627282930  
Chris Donnan

Create Your Badge

Chris Donnan : Programming – Brooklyn Style

software, trading, family, fun

Spring Framework Developer Session .Net Code Examples

Thanks to the ~40 folks that came out last night for our 1st developer session. The night wound up being fairly SpringFramework.net centric. I gave a quickie demo of some code I have been working on for the forthcoming SpringFramework.net Desktop Application Framework.

I also had some requests to post the .net code project I used as an example.
Spring Framework.net demo code

There are a few areas that can be looked at for example purposes.

  • Start by looking in the Program.cs in the SpringPresentation project. This will show you at least the entrance into spring and the top of the object graph with the Main form.
  • Look at the App.config file in the SpringPresentation project. Trace the object graph from the Main Form – to it’s presenter, to it’s commands. Notice how the commands are just added to a generic dictionary – as you add commands – you could just add them to this strongly typed (thanks to generics) dictionary.
  • From there – the commands reference other prototype objects that are what I used as the center of the demo. In essence – our ‘business obejcts’ could be used in a few different ways. We vary the behavior of the business object by injecting different dependencies (strategy like classes in this case).
  • The ComplexBusinessObject.cs file in the library project has a few things in it (this was for convenience in the demo). There are the basic interfaces used to do this business object thing
    • interface IComplexBusinessObject
    • interface IBusinessData
    • interface ICalculator
  • Essentially – ComplexBusinessObject implements it’s interface – IComplexBusiness object by containing strategies that do the real work. These strategies can be passed in – thus allowing you to have different configurations of the same ‘ComplexBusinessObject’. In the spring configuration – you can see that there are ‘Strict’ and ‘Easy’ (arbitrary fake names like all of this demo). These different configurations hand different implementors of the ICalculator interface to make the object do it’s work differently in different circumstances. This type of thing is a prime example of how IoC in general is valuable.
  • The core idea again is that spring assembles these objects for you as needed. It can manage making all of this configurable, flexible etc.

Feel free to comment here with questions etc or email me directly.

Thanks;

Chris


You can leave a response, or trackback from your own site.