18/02/2010

AOP: Aspect Oriented Programming

AOP goes like this: If it's not part of your core logic it's an aspect and should in some way be separated from your core algorithm.

In a more literal sense, Aspects are application infrastructure components, as a foundation is to a house, Aspects are to a software application. Now how does this differ from OOP?

The intention of Aspect Oriented Programming is two fold:
  1. Separation of Concern: the separation and centralization of application logic in a non redundant fashion.

  2. Cross Cutting: entanglement of application logic within a program resulting in scattering tangling or both.
"For instance, if writing an application for handling medical records, the bookkeeping and indexing of such records is a core concern, while logging a history of changes to the record database or user database, or an authentication system, would be cross-cutting concerns since they touch more parts of the program." - Wikipedia

Some of you may argue AOP is no more than another level of abstraction in OOP, and you'd be correct in saying that. I personally find the theory interesting, but the practice a bit defeatist. As a .Net developer, I'm sure I'd prefer using the built in .Net Roles & Members over AOP, but, heck, if I can make my code more readable I'm up for giving it a shot.

Here are some interesting articles which talk to AOP, and a simple AspectF implementation (which isn't real AOP) by the creator of pageflakes.com:

Aspect Oriented Programming Wikipedia

AspectF Fluent Way to Add Aspects for Cleaner Maintainable Code

AspectF Simple way to cache objects and collections for greater performance and scalability

What do you think about AOP?

Over and Out

09/11/2009

Uri Extension Method: AbsolutePathNoFile()

How often do you want to determine the absolute URI from any url without the specific file reference and without the query string variables. This is especially useful in many SharePoint tasks.

Here is a little extension method that can do just that. Pop this in a static class and try calling it on your Uri object:

public static UriExtensions {

public static string AbsolutePathNoFile(this Uri theUri)
{
string retVal = "http://" + theUri.Host + (theUri.Port == 80 ? "" : ":" + theUri.Port.ToString());
for (int intCnt = 0; intCnt < theUri.Segments.Length-1; intCnt++) {
retVal += theUri.Segments[intCnt];
}
return retVal;
}
}

// somewhere else:

Uri u = new Uri(Request.Url);
MessageBox.Show(u.AbsolutePathNoFile());

Over and Out

02/11/2009

Google Wave Is Here: But I have no Friends

I am online with the Google Wave beta. It is cool, takes a bit of getting use to. But this is NOT going to replace my normal email account anytime soon - This is no Tsunami. I do however hope it does replace my email account ASAP - Especially on my iPhone!

The most major thing I don't understand about Google Wave is: How can I message people that do not have Google Wave accounts? Wouldn't this be the obvious way to get other people on board (is this merely not happening because this is a VERY early preview version)? Right now I can't so this means I can't use it for much (start playing little violin here).

My main contacts did not jump at the chance to subscribe to the Beta so I am now sitting in an ocean waiting to catch a wave.

Stay tuned for Google Wave invitation give away. I have nominated 20 of my closest digital friends for Google Wave accounts and am waiting for google to lick the stamps.

And so goes the life of a surfer.

Over and Out.