Composite Oriented Programming Redux

An entry about arcitechture | cop Publication date 25. August 2008 09:48

Back in February, as a follow-up to my exploration of Aspect Oriented Programming (part one, two, three), I took a look at Composite Oriented Programming. And then I kinda forgot about it… I remember speaking with Anders Norås at an NNUG Oslo event shortly after I had written my post, and he said he was planning to have a deeper look at COP himself; well, the other day he wrote a post about it over on his blog.

Dynapose

Back when I wrote my post I actually spent a fair amount of time implementing a C# COP framework based on my previous AOP work. So my initial post wasn’t just a theoretical “what if” kind of thing – it was actually compilable, executable code – I called it the Dynapose framework (a play on “Dynamic Composition” – clever, no? :p). The plan was to put it up on Codeplex, but I never made it that far and it just ended up collecting dust on the shelf instead. Well no more - if you want to play about with it then go to the end of this post for the download link.

Since Last Time…

In my original sample from back in February, I was using attributes as a way of configuring the composites. Later I also added a fluent interface style configuration API, which allowed composites to be dynamically built at runtime:

IDivision division = Composer.Compose<IDivision>()
                            .AddMixin<ICalculationDataAspect, CalculationDataAspect>()
                            .AddMixin<ICalculationLogicAspect, DivisionLogicAspect>()
                            .AddConcern<DivisionValidationConcern>()
                            .Instantiate();

You can also use a mix of attributes and dynamic configuration, to for example specify a default composite and then create variations of it. The fluent API will also let you give it a delegate to use as a factory method for mixins etc:

.AddMixin<ICalculationLogicAspect>(() => new DivisionLogicAspect())

My plan with this was to allow my framework to be integrated with IOC containers, which would have been totally awesome.

Known Bugs & Limitations

Well, its been a long while since I worked with this code so I’m not 100% sure on the state of things. What I do remember is that I was having a bit of trouble with generics, so that might not work as expected.

Try it Out!

If you want to play around with this yourself, then you can download the source code here. It includes a simple demo application, and the source code is fairly well documented and tested. I’ve no idea if I’ll pursue this thing any further, so take it for what it is: a fun little proof of concept project that you probably don’t want to get anywhere near your production code :p

If you do check it out, please let me know what you think, and what you made happen with it!

Be the first to rate this post

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

Powered by BlogEngine.NET 1.4.5.0

Welcome!

My name is Fredrik Kalseth, and this is my blog - thanks for visiting! I am fortunate enough to work with what I love for a living, and this blog is essentially the biproduct of that.

I work as a senior consultant for Capgemini, and am also an active participant in the Norwegian .NET community, as an avid attendee but also as a speaker (most recently at NNUG and MSDN Live).

As a developer, I have a wide circle of interest. My primary passion is for agile, test-driven development, with focus on best practices and clean code. That said, I also love to work on the frontend, especially with web development.

On Twitter? My handle is fkalseth. On LinkedIn? I`m there too.

NDC 2010

The conference to attend this summer happens June 16th-18th in Oslo, Norway. Are you going? Be sure to catch my talk on AOP while you're there!

 

Disclaimer

This is a personal blog; any opinions expressed here are my own and do not necessarily reflect those of my employer. All content herein is my own original creation, and as such is protected by copyright law. Unless otherwise stated, all source code posted on this blog is freely usable under the Microsoft Permissive License.

What Readers Talk About

Comment RSS