Aaron Powell's blog

var blogs = umb.Posts.Where(p => p.Intelligent);

AUSPAC Webinar recording

Sunday, 7 February 2010 by Aaron Powell

In the AUSPAC webinar I ran 2 weeks back I said I recorded (most of the) session (the slide deck can be found here).

Well after 2 weeks of reinstalling my laptop (that took longer than it should have!), my flatmate moving out (and a level of disorganization caused by that) and good ol' procrastination I've managed to get a few spare hours which I could use to encode the video.

It's missing the last ~20 minutes, basically everything after I finished with OS X, but otherwise the session has everything included.
I'm yet to have the additional time to record the missing session, but I figured that getting what I've got so far available was more important.

So if you missed the session, or just loved it that much, grab a copy now! (It's about 45 minutes long and 170mb)

The answer to why this code works

Saturday, 23 January 2010 by Aaron Powell

So at the start of this week I put up a blog asking Why this code works, and to be honest I've grown quite a bit of an ego since then as no-one has been able to answer the question correctly.

One person did get close, but close doesn't quite cut it ;).

Well the answer is actually very simple, and it's a really handy feature of the C# language, explicit operators.
Explicit operators allow you to define explicit casting between types. So the code that was missing from my original post was this:

public static explicit operator UmbracoPage(XElement x) {
    return new UmbracoPage(x);
}

What I've done here is defined how the compiler is to treat a casting of an XElement to an instance of UmbracoPage, and since UmbracoPage inherits IUmbracoPage there is already a defined casting to it.

Inside the body of my explicit operator I can do anything I desire, here I'm just returning a new instance, passing the XElement to the constructor.

I find it really quite elegant, and that it reduces code smell quite nicely.

But explicit operators also have a buddy, in the form of implicit operators (which was the close-but-no-cigar answer). These work by the type being defined by the assignment target, eg:

UmbracoPage page = xElement;

I'm personally not a fan of implicit operators though, I find them less obvious when you're reading code.

So there you have it, a slightly obscure language feature to play with!

Umbraco AUSPAC January post-session stuff

Wednesday, 20 January 2010 by Aaron Powell

First off I'd like to say thanks to all who attended tonights Umbraco webinar, I think we had mid 20's for most of the session, really excited by the volume.

Anyone who hasn't already filled out the post-session review please do so, it'll help me make it more awesome next time ;).

As promised, here are the resources from tonights session:

Slide Deck

.NET project

 

For those who are interested I did record tonights session, but it appears that it stopped recording about 20 minutes before the end. I will try and get the last of the session recorded soon and posted up here as well.

Please be patient with that one :).

Comments (1) |  Umbraco Perminate Link

Why does this code work?

Tuesday, 19 January 2010 by Aaron Powell

In the discussion on the Umbraco forum about using LINQ to Umbraco I posted a short code snippet of something we write fairly frequently at TheFARM using our version of LINQ with Umbraco.

I thought I'd post the challenge to my trusty followers, for them to see if they know why the code works. First off the code:

IEnumerable<XElement> nodes = UmbXmlLinqExtensions.GetNodeByXpath(...); IEnumerable<IUmbracoPage> pages = nodes.Select(n =>(IUmbracoPage)(UmbracoPage)n);

What the XPath being evaluated isn't important, what is important is you'll notice that we have a collection of System.Xml.Linq.XElement's, but then it's directly casting each XElement to IUmbracoPage.

Here's the skeleton for the class and interface:

public interface IUmbracoPage { ... } public class UmbracoPage : IUmbracoPage { ... }

Again the body of the interface isn't important, what is important is that the class only inherits from the interface, it does not inherit from XElement.

So why does it work? What line(s) of code have I left out of this post that would make it work?

If you get it right I may just buy you a beer :P.

AUSPAC Umbraco January meetup webinar info

Monday, 18 January 2010 by Aaron Powell

As promised here is the webinar details for the Umbraco AUSPAC January meeting - http://connectpro95625839.acrobat.com/umbraco-auspac-jan-2010/

As I mentioned previously TheFARM has been kind enough to sponsor us with an Adobe Connect license, so you'll be able to join the session from any browser on any OS which supports flash (although I've found Chrome on OSX a bit flakey).

So the details just to recap:

When: Wednesday 20th January 2010

Time: 8pm AEDT (GMT +11)

Where: http://connectpro95625839.acrobat.com/umbraco-auspac-jan-2010/

You will need to provide your own beer :P

Comments (0) |  Umbraco Perminate Link

AUSPAC Umbraco January meetup details

Sunday, 10 January 2010 by Aaron Powell

In December last year I announced the next Umbraco AUSPAC meeting was going to be held in January and I also said that I'd provide some more details closer to the date about what would be happening.

But first I have to make a correct, the date of the meetup is being moved to Wednesday January 20th, not Monday January 18th.
Unfortunately I didn't plan far enough ahead and forgot that I would have bootcamp on that Monday night. After an hour with a personal trainer I'm not going to be in any state to run a presentation.
Sorry folks! (It does also give me a bit more time to get the presentations sorted though ;))

 

The major announcement is that TheFARM has kindly offered to sponsor us with an Adobe Connect account which we can use to run these sessions! Thanks guys :D.
I'll provide the link to the meeting 2 days prior on my blog, twitter feed and our.umbraco.org, so keep a look out.

 

Now on to what you may be wanting to know, what will happen in the session.
Well first there'll be a look at what's go on the core and where Umbraco 4.1 one is, when you can expect it and why the release schedule changed.

I also promised that I would be providing some ninja coding tips with Umbraco, and anyone who follows my twitter feed may have seen me dropping some hints over the past week of what to expect. 
The hints were rather cryptic (plus the 140 character limit didn't help :P) so if you worked it out then well done. But if you haven't I'll spoil the surprise now (or stop reading if you don't want to have it spoilt).

Ok, here it is.

.

..

... (ahh suspense)

I'll be looking at how to do unit testable Umbraco Macros under OS X with MonoDevelop, Web Forms MVP, Web Forms MVP Contrib and LINQ to Umbraco.
Just of note I wont be looking at how to run Umbraco under mono on OS X, but rather how to code for Umbraco under OS X.

Hopefully that level of craziness will suite ;)

See you at the session!

Oh woe is (Mobile)Me

Thursday, 7 January 2010 by Aaron Powell

Anyone who is (lucky enough to be) on my msn contact list (and signed in during my work hours) will have seen something curious happening over the past week since I returned back to work.

For those of you not, basically I was signing in and out constantly with a frequency of say every 10 minutes.
This oddly made is surprisingly hard to hold a conversation with someone.
But more problematic was that not only was msn dropping out but the whole internet was. You could hardly even achieve a successful Google search.

And this wasn't just a problem for me, but for everyone here at TheFARM.

The first assumption was that it was something wrong with our ISP, we're not on a super faster internet connection, and no one had problems outside of work, so it seemed like a logical assumption... right?

Well it turns out that when you assume you make an ass out of you and me (ha, see what I did there! :P).
The problem wasn't our internet, in fact the problem could be blamed on one individual, yep you guessed it, me :(.

Turns out that when I wasn't on the network everything was fine, everyone could use the web, chat on msn, do what ever they wanted, but as soon as I plugged in, BAM, the internet died.
So after a bit of detective work (mostly by Shannon) it was concluded that my computer was doing something nasty to the network.
So we cracked out a copy of Wireshark and decided to do some detective work with packet sniffing.

Immediately it was obvious what was happening, I was flooding our DNS server with requests, requests that the DNS server was returned as invalid. 
The requests kept looking for a URL along the lines of tcp.members.mac.com and after a bit of searching it turned out that that URL is related to the Apple MobileMe service.
So Shan asked if I was signed up with MobileMe, to which I responded "I don't believe so", but it turned out again I was wrong, I had signed up to MobileMe, but it must have been when I first got my iPhone.
When you get an iPhone you can sign up with a 60 day trail, something I must have done (hey, it said I was signed in, guess I signed up at some point :P).
After doing some quick math I concluded that it was ~60 days since I got my iPhone when we first started having internet problems (the last working week last year).

I instantly signed out of MobileMe, and low and behold the DNS flooding stopped happening!

 

Thank you Apple for producing a service which is capable of bringing down an office network, you've just made sure I strongly consider not purchasing MobileMe in the future!

Oh and I'm never going to live this down at work, Shan isn't a fan of Apple so this is just adding fuel to the fire!

Comments (0) |  Mac Rant Perminate Link

2009, a year in review

Friday, 1 January 2010 by Aaron Powell

So a new decade is upon us and with 2009 wrapped up it's time to look retrospectively at the year that was.

2009 was the biggest year professionally that I've had, the whole year has been filled with new adventures into the development world.

At the start of the year I announced my first Open Source project, the Umbraco Interaction Layer (UIL) was ceasing development as I'd joined the Umbraco core development team.

I had lot of fun delving into LINQ in greater depths, like commenting on the difference between LINQ query syntax vs LINQ methods syntax, then having more fun by writing a JavaScript LINQ implementation.

Next I took up a pleasure of mine, doing bizar coding, first with recursive anonymous self executing functions in JavaScript and then I wrote it in .NET too!

Also I was luck enough to get invited to Code Garden 09 in Copenhagen, which was an awesome trip and a great chance to meet other Umbracians from around the world. One of the outcomes was the first AUSPAC webinar (with the 2nd coming in the new year).
Also coming out of my Denmark trip was a new employment opportunity which saw me moving from my home town of Melbourne to Sydney to join Shannon at TheFARM.

Umbraco managed to get out Umbraco 4.1 Beta 1 on time, although the scheduled has since been revised (there will be more information coming shortly on this).
And to celebrate the occasion I released a set of videos on using LINQ to Umbraco.

Then to finish the year off I released a new Open Source project, ASP.NET Web Forms Model-View-Presenter Contrib.

What a busy year! Hopefully 2010 can prove to be just as exciting :D

 

Update - Fixed the link to the ASP.NET Web Forms Model-View-Presenter Contrib project. Thanks for spotting it Will :)

Comments (3) |  Random Junk Perminate Link

Announcing ASP.NET Web Forms MVP Contrib

Monday, 28 December 2009 by Aaron Powell

So it was Christmas eve and I was in my car driving down to Canberra to spend Christmas with my family.
It's not an exciting drive by any means, so I needed something to keep me entertained, and like any good nerd that is thinking about coding.

And then an idea hit me, ASP.NET Web Forms MVP Contrib Project!

But lets back up a second...

I've been using the Model-View-Presenter (MVP) pattern in ASP.NET Web Forms development for quite a while now. I help roll out a framework in Next Digital for all ASP.NET builds and I'll admit it wasn't a bad framework.
A few months before I moved on I noticed a tweet from Damien Edwards (Victorian-based Microsoft MVP for ASP.NET), stating that he was working on a MVP framework.
I immediately jumped at the idea, and had a look at the preview build, and I was hooked. Easy to use framework, code re-use and completely unit-testable ASP.NET Web Forms development? Why not!

One of the initial problems was that you had to register presenters at a page level, which wasn't possible from Umbraco development, I submitted a patch to allow it, but it eventually became redundant as the framework removed that limitation itself (after I pestered Tatham Oddie).

So I've been constantly been trying to find ways in which I can use or extend the framework. We've got a project already under way at The FARM which is using it, but I wasn't content there, and here is where the Contrib project comes in.

If you're not already familiar with ASP.NET Web Forms MVP I suggest you have a read/ watch of the framework documentation before you continue along.

What is the Contrib Project?

Since ASP.NET Web Forms MVP is little more than a framework you still have to do a lot of stuff yourself, stuff which you're going to probably do many times over, and this is what the Contrib Project is aiming to help you with.

Currently the Contrib consists of a few common presenters. They are presenters which represent functionality which I seem to be constantly building myself. At the point of writing the Contrib Project consists of the following presenters:

  • Authentication
  • News Archive
  • News Article
  • Google Analytics
  • Feedback Form

These presenters can almost be used straight off the bat, just the Authentication, News Archive and News Article all require a Data Service to be provided (more on that shortly though).

In addition to the presenters the following Views are provided:

  • IAuthenticationView
  • INewsArchiveView
  • IFeedbackView

These views are either for just wiring up events or providing some view-implementation data (such as with the INewsArchiveView interface).
But there are also a non-view interfaces provided which have some default operations, these are:

  • IValidatable
  • ISubmittable`T
  • ICancelable`T

These interfaces just provide some events or properties to a view which can be used if and when they are required (in fact they are used by some of the default views).

 

Data Services

As I mentioned above some of the presenters can't be directly used because they require a Data Service. This is something which we use at The FARM, which abstracts away the data interaction layer. 
Our data layer is exposed entirely as interfaces, and all interactivity is done through predefined methods.
All data is also returned in interface form.

Shannon has done a blog post which covers this in some detail on our company developer blog.
And going into the full details of how to use the Data Service as a pattern is beyond the scope of this post.
Essentially it is about IoC, you need to provide a data service. This is something that the framework can't provide for you.
To use these presenters you'll need to create an implementation of them yourself which passes in the appropriate data service into the presenter in the .ctor(IView view) call.

The provided data services are:

  • IAuthenticationService
  • INewsService

 

What now?

Now you should head over and check out the Contrib Project on Codeplex! I'll have an official release coming soon, along with more documentation about the presenters, views and data services.

And if you've got something you want to add to the Contrib project drop me a message.

AUSPAC Umbraco January meetup

Monday, 21 December 2009 by Aaron Powell

Earlier this month I put a survey up which I was asking for feedback from Umbraco users in the AUSPAC region in regards to what you are wanting in regards to community involvement.

The results of the survey weren't really different from what I was expecting them to be, the only oddity was I didn't receive 100% stating that beer should be involved (seriously I'd done more coding for Umbraco with beer than without!).

But anyways it's time to put a note in your calendars, as the 2nd Umbraco AUSPAC session will be held on Monday 18th January 2010 at 7pm AEST.
The session will be run online so even if you're not in Sydney you can easily join in.

So what will be covered? Well I'm going to keep that under wraps for a bit longer, but lets just say that it'll involve some ninja coding tips for Umbraco ;).
We'll also announce details regarding the 5 year celebration event.

So mark your calendar and keep an eye on my blog/ our.umbraco.org/ twitter for more information.

Comments (0) |  Umbraco Perminate Link
Next >