NHibernate in Dec MSDN

Published 12/7/2009 by Dave in alt.net | Database

Ayende never ceases to amaze me, I just wonder where he finds the free time (must be cloning). Anyway, he has written a simple TODO list article which uses

  • Object Relational Mapper
  • Presenter View View-Model
  • Number of Design Patterns

By the looks of this, Ayende has tried to use a minimal number of 3rd party tools, to try and show principals.

Well worth a look!

(Thank you Ayende)

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

a number of articles by a development team whom implemented a web site using Sharp Architecture

Bill's link

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

I fnd it fun to look at Architecture, as when it comes to building web applications you do not want to re invent the wheel every time. before recently there where not many designs for using .Net in a n-tier approach which did not contain DataSets. If you are like me and come from a OO back ground you may see DataSets to be DataCentric and not easy to apply domain rules to the data (neatly).

With the Alt.Net movement promoting a clean OO approch there has been a nice shift from the DataSet designs to Domain Driven technques. The first publised example framework was Patterns in Action. This is quite nice in the sence it promotes the Gang of Four patterns along with some of Martin Fowlers Pattern of Enterprise Application Architecture (PEAA, one of my faviourte books). I have the .Net 2.0 copy (there is a .Net 3.5 one now), which i would reconmned just so you can see how things fit together.

However, there has been another Architecture I have been following, its S#arp Architecture. This is where all my friends woudl know go, "he mentioning it again", at the same time they will think "but he is right this is worth a look". the SA has just released its version 1 RTM release, of which im partictually found of the WCF addition. If you have not been keeping an eye on this I would reconmend downloading the RC2 (just for the word document) and the RTM (for the updated code). I found this Architcture to be extremely impressive. Its easy to understand and its easer to extend. The best thing is the price tag (its FREE). 

Before you consider looking at an architecture in .Net I would highly reconmend reading the Foundations of Programming, then looking at S#arp Architecture. you will note between these 2 you will have knowlegde of some extremely good tools and patterns.

thats it for my rant,,, go look at the new S#arp Arhicture now!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Active Record

Published 4/23/2009 by Dave in alt.net | Database

if you are writing any data layer code in .Net, please have a look at this presentation by Ayende

Oredev 2008 - ALT.NET - Using Active Record to write less code

its an hour long, but it can save you lots of time

Active Record is built ontop of NHibernate, and its free... wahey for open source

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Some Links for AOP

Published 3/11/2009 by Dave in alt.net | dotNet

AOP is a great way to clean code, well if used correctly. lots of examples will only show the logging example, when an exception is thrown (I should know here is one I wrote: hello world of AOP). Well thats ok, you can see it in action and step through it, however that for me was not enough. So here are a few more really helpful links

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

DI frameworks

Published 10/20/2008 by Dave in alt.net | dotNet

One thing I have been looking into in my free time is Dependancy Injection (DI). As I'm a little new to this area I wanted to read up on it and see what is the best framework (for me) to start doing this in.

What is it?

Designing For Change is a great presentation by Nate Kohari the author of Ninject. look through those slides an you will begin to get a good idea of how to code loosely.

So you are thinking in abstracts and interfaces, Plain Old Software Engineering (if you may) and want to know what is a great framework to code in.

There Seems to be a lot of Frameworks?

As you may have noticed there are quite a few frameworks out there. These are the ones that stood out to me (and by the looks of it everyone else)

So the next port of call is to find a great comparison

The DI Framework Comparison - Val la, this is a very well thought of comparison, an would help you all on which DI framework you would choose.

One Last thing.

OK, now we have an understanding of DI and the features in some of the frameworks, there is just one more thing. which one is Lightning fast?

How Expensive is it? Part 1, Part 2, - Great test on how long it takes to create an object.

Well I think i have made my mind up.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Here are some links for developer Joe, whom wants to get started in NHibernate.

Sites

Official site: Contains great reference material, read the Quick guide too.

Community: Wiki, Blogs and downloads. become a member today, and start adding to the KB.

Video Training, (Big thanks to Unhandled Exception) Excellent, 14 videos to get you started.

Fluent Nhibernate - write code instead of XML for your mapping files.

Tools

http://www.nconstruct.com/ - NConstruct Lite is free, so give it a go, Generate you classes and mapping files from your DB.

NH Prof - a Profiler, yep see what is going on, well worth your time!

Articles, publications:

Best Practices (has a basic example and then a Enterprise example), aimed at version 1.2, however extremely good. I like this as you have the sample project layout.

The foundations of programming ebook mentioned previously in this post. As it covers NHibernate and other patterns you will most likely use with it. Fantastic read.

 

If any one knows of any good material please add a comment linking to it. 

 

Currently rated 5.0 by 3 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

The Hello World of AOP

Published 9/23/2008 by Dave in alt.net | dotNet
Tags:

Being armed with some new toys I wanted to carry on into my look of Alt.Net ways. This latest post is just a very quick demo of Aspect Oriented Programming (AOP), hopefully it will prove helpful to understand AOP for others as it did for me.

If you do not know what AOP is, please google or Wikipedia it

First things first. for this demo I'm using Spring.Net version 1.1.2 (almost the latest version)

Project Download: Test_Spring.zip (3.55 mb) (VS2008)

Project Overview

1. The Service Layer. (simple service)

This test app has a Service called "Hello" which implements the IHello. The main point of this is that the Hello.World function throws an exception, and the application is going to use AOP to jump in and show the params passed to the method.
 

Note if you did not use an interface or make the method virtual, the spring.Net framework does not apply the aspect.

namespace ServiceLayer
{
    public class Hello : IHello
    {
        //The method which will throw the exception
        public string World(string Name)
        {
            throw new Exception("did not work");
        }
    }
    
    //The IHello contract
    public interface IHello
    {
        string World(string Name);
    }
}

2 Aspects

there are many types of aspects you can use, in this case I have used the IThrowAdvice, which will intercept an exception thrown. For more information see the Spring.Net Manual its really well written.

namespace Logging
{
    public class Log : IThrowsAdvice
    {
        //catch any exception
        public void AfterThrowing(MethodInfo method, object[] args, object target, Exception ex)
        {
            Console.WriteLine("");

            Console.WriteLine("Test Logging, Params");
            //print out all the params where were passed into the method
            //which threw the exception.
            foreach (object arg in args)
            {
                Console.WriteLine(arg.ToString());
            }

            //this will write the thrown exception msg
            Console.WriteLine("Error Msg: " + ex.Message);

            Console.WriteLine("End of logging");
        }
    }
}

3. The Command line app

Finally the command line app sets up the AOP container and calls the method. note there are a 2 ways (which i have seen) to set up AOP,

1 Is programmatic, shown below.
2 Is using the IoC container and XML, commented out, but i have included the XML in the attached project

namespace Test_Spring
{
    class Program
    {
        static void Main(string[] args)
        {
            //// Create AOP proxy using Spring.NET IoC container.
            //IApplicationContext ctx = ContextRegistry.GetContext();
            //IHello hello = (IHello)ctx["HelloService"];

            //Creating the AOp Factory in Code.
            ProxyFactory factory = new ProxyFactory(new Hello());
            factory.AddAdvice(new Log());
            IHello hello = (IHello)factory.GetProxy();

 

            try
            {
                hello.World("Dave");
            }
            catch
            {
                //no logging here
            }
            Console.WriteLine("press Enter to Exit.");
            Console.ReadLine();
        }

    }
}

Running this app you will see there is more written to the console than "press Enter to Exit", how cool is this? from what i can see if creates a virtual proxy class which inherites off the Hello class. Then when you call any function it is able to re-act accordingly!

 

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

I mentioned this quickly before, but did not really go into it.

Foundations of Programming is a blog series written by Karl Seguin, which recently have been converted into a very nice single PDF book (I mean proper book). If you have not read this yet, and you think you know about .Net programming, I strongly suggest you download it now (its free).

The Book covers multiple Alt.Net tools which are used to create a Domain Driven Program. The great thing about this book, it just assumes that you know C# and ADO. It will introduce a programmer to techniques which will help them build loosly coupled and robust applications.

I have found this to be a great read and have been recommending this for a while to other developers. (almost 20,000 downloads in just over 1 month.. I am not the only one whom thinks this)

Some of the Tools described:

  • Object Relational Mapper, Nhiberbnate
  • Inversion of Control and Depenancy Injection, structureMap
  • Active Record, Castle Winsor
  • Mock Objects, Rhino Mocks

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Alt.Net events are in the UK

Published 8/2/2008 by Dave in alt.net
Tags:

Good News, Alt.Net programmer events are being arranged in the UK!

Before I go any futher, you may ask, "What is Alt.Net?". here is an MSDN magazine article on this or read this document (Foundations of programming), but in a nut shell its an alternative way to programming in .NET.

Back onto where to find some of these NEW events:

Alt Net UK - events being orgainised by some of the industry leaders (Red Gate and Conchango), with well known speakers.

Skills Matter - Open Source .Net, Events (Free and pay for), Pod casts and general resources

I recently attended one in London, and it was a great into into some of these exellent tools:
Nhibernate - an Object Persistance framework
Castle Winsor -  just the Inverson of control and Dependancy Injection parts of this framework.
Rhino Mocks - unit testing
PowerShell
Subverion - source control

Hope to see some of you in these up comming events.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5