Inversion of Control

by Kofi Sarfo 4. June 2009 16:02

Our favourite piece of code seen recently is from a while ago: Building an IoC container in 15 lines of code. We like it because the intent is really very clear. Every now and then we find some use of Spring.NET or mention of IoC. Sometimes wonder whether it's necessary or being used because Developer-X wants to indicate sophistication. So then as a refresher we often end up here: Inversion of Control Containers and the Dependency Injection pattern. Written 35 Internet Years ago.

Looking at the way applications are written circa 2008 it appears IoC is reasonably common and therefore time to incorporate. Known advantages:

  • Decoupling
  • Service Orientation (is this repetition of the first?)
  • Testability
    • Allows mocking

The fact that we've neither been tripped up by object graphs nor troubled with dependency suggests not having done anything nearly enterprise enough. That, rather than an eidetic view of object relationships. Still, there's an argument for trying to incorporate a different approach into the ordinary as a means for seeing the ordinary for being less than splendid.

Right, so which one do we go for?

The nice thing about Autofac is that it's capable of using a delegate or Lambda Expression rather than reflection for component creation. As stated elsewhere, .NET 3.0 style. We like.

Notes:

Useful to make explicit the difference between Inversion of Control and Dependency Injection. Hint: The latter is a specific form of the former. Nice one, Wikipedia!

Tags:

Why We're Sheltered Safely Behind the Curve

by Kofi Sarfo 3. June 2009 01:56

Back in 2002 we were trying to learn C# - having felt like we'd conquered VB.NET in 2001 - there was a *thrilling* chance to learn about the .NET programming model by developing creatures and introducing them into a peer-to-peer ecosystem... Terrarium! Welcome home disposable heroes.

I think we spent a week trying to get the friggin' thing to work before someone let us know that it had nothing to do with our ineptitude and everything to do with our beta version of Visual Studio. Cue decision to wait until technology beds down before adoption. Much cooler to be an Early Adopter but it required a level of patience beyond us; we watched and laughed as early versions spat out their problems. Widely anticipated, widely hyped technology seemed to disappear. Late adoption served us well. Looking down Memory Lane:

That was then. WxF looks to have good momentum - read: it's showing up on job specs - so cue once more frustration of technology adoption prior to it becoming mainstream. Pair of Snake Eyes.

Tags:

BlogEngine.NET Deployment

by Kofi Sarfo 2. June 2009 05:53

First take involved opening solution in Visual Studio 2008 and publishing to localhost and then using FTP to send files individually whereupon we discover that using O2 mobile broadband (via USB) results in files arriving "successfully" on remote web server with file size 0KB. Yuck! Many more takes to replace "successfully" transfered files. Don't blame FileZilla because it's doing only as it advertises and we've had issues with FTP ourselves quite recently from within code we'd written.

Digression: It was necessary to compare file content between local and remote files before assuming successful transfer. Not pretty. Never discovered a better solution that didn't involve MoveIt.

Finally everything copied across and directory turned into Web Application using the DiscountAsp.Net unsurprisingly named Web Application Tool. Instead of blog appearance we have this compilation error!

So it turned out there are at least two ways of resolving this without trying to understand intricacies of ASP.NET Dynamic Compilation and being frustrated by not being able to delete Temporary ASP.NET files on a remote server which denies access to said directories and probably with good reason. Wondering why WebDAV isn't an option here though... probably a good reason I'm not aware of.

If you see this then everything's turned out okay. Global warming has been corrected. If you care in even the slightest this application defaults to using an XML file datastore and so we need to weigh up whether there's any advantage to pushing this into SQL Server. Climb the mountain because it's there? Okay, it's probably not quite a mountain and we'd not do it in a tutu.

Notes:

MSDN: Understanding ASP.NET Dynamic Compilation

Post Script:

It's a love/hate relationship with Infrastructure.

  • By their being responsible for deployment I'm sometimes spared the headache of failed deployment.
    • In this first instance someone else discovers/solves the problem.
  • By their being responsible for deployment I'm sometimes victim of failed deployment.
    • In the second instance someone else *is* the source of the problem.

Poetry very incidental.

Stack Overflow: Who is using BlogEngine.Net for their blog?

by Kofi Sarfo 1. June 2009 04:38

I'm missing another superlative for Stack Overflow. Whilst trying to decide between BlogEngine.Net and SubText for this blog - using Google as is how every but every decision is made now - the following became apparent:

  • BlogEngine.NET code is likely to provide the more interesting read
  • SubText is going to be rewritten to use ASP.NET MVC
  • One is more stable than the other, supposedly

In other news I attended a London .NET user group talk at Microsoft last Thursday (ASP.NET Webforms versus ASP.NET.MVC) in which I learnt that I fall into the second category of developer: those who want to build apps so that they can charge a client. Eight weeks without a client can do that to you. The argument had the expected key themes:

  • Why must we suffer View State?
  • Web development should be about being -
    • pragmatic (Webforms)
    • elegant and of highest quality possible via Test Driven Design/Development (MVC)
  • ASP.NET MVC currently lacks the cushion (view designer, etc)
  • Does anyone like the ASP.NET Page Life Cycle?
There were some discoveries. Diary of a Dotnet Developer: What I learned last week. This was easily the best Microsoft tech talk I've been to yet. The Clash of the Titans (Microsoft Web Framework Fight)

It's been a while since I did any web development so I was going to write a web site firrst using ASP.NET old school (.Net Framework 1.2) and do the same again using ASP.NET MVC with as much of .Net Framework 3.5, Nant, NUnit, Rhino Mocks and NHibernate that I might be able to fit in sensibly. I've yet to settle on a preferred IoC implementation. Between this talk and Jon Skeet's C# in Depth (Amazon) perhaps I have enough of the pieces to put this together and more than enough time to play with jQuery besides. I'm told there's more to AJAX than UpdatePanel.

Notes:

Stack Overflow: Who is using BlogEngine.Net for their blog? Does it run well? Will it scale? :P

Mason Lyngby: Switched from SubText to BloggingEngine.NET

Kofi Sarfo modified theme by Mads Kristensen



Content by WIMIRO Technology is licensed under a Creative Commons Attribution-Share Alike 2.0 UK: England & Wales License.

Creative Commons License

Powered by BlogEngine.NET 1.5.0.7

About Me

Director, Wimiro Technology
London, United Kingdom

Writes in third person and first person plural; currently commutes to Moorgate.

Kiva Loans

  • Stalamarice Nthomo Kangi

    Stalamarice Nthomo Kangi

    Tailoring

    Requested loan: $375

    Amount raised: $0

    Machakos, Kenya

    To buy fabric

    Loan Now »

  • Jonathan Mututu Kasyoka

    Jonathan Mututu Kasyoka

    Internet Cafe

    Requested loan: $500

    Amount raised: $0

    Machakos, Kenya

    To buy more chairs, tables and printer paper

    Loan Now »

  • Jeanciana Rin

    Jeanciana Rin

    General Store

    Requested loan: $300

    Amount raised: $0

    Katutungan, Wao Lanao Del Sur, Philippines

    To purchase additional inventory and to use as working capital

    Loan Now »

 To see more entrepreneurs »

Kiva Loans