Skip Navigation Links

Posts for: May 2007

Go BlogML!

Robert McLaws has created a new logo for BlogML and here it is:

BlogML logo

Way to go Rob!  I'd also like to call out a great effort on the part of Keyvan who has really taken the lead on BlogML and allowed it to move forward in a truly excellent way - thanks Keyvan! smile_regular

posted on 5/31/2007 10:39:54 PM ( 2 Comments )


Dev Centre Software Creation Process

The other day Mitch had some kind words to say about the Dev Centre at Readify and so I thought that I'd take the time to summarize the processes that we use.  First I'll start by stating the goals that I have for the Dev Centre:

The goal of the Dev Centre is to deliver usable software that helps our customers get their job done.

Sounds simple enough? smile_regular  I believe that it's super important to keep things as simple as possible at all times.  So many times you see projects get bogged down in red tape and process.  By trimming away as much of the fat as possible you can hopefully avoid falling into the trap of spending too much time doing things that don't matter.

After stating the goal I can now elaborate on the actual process itself which is broken down into the following 4 parts:

  1. Plan
    Duh!  All processes start with this smile_regular  During this phase we spend a lot of time gathering scenarios so that we can distill the actual requirements.  The scenarios give us enough information to break out the tasks.
  2. Design
    Technically speaking this is really part of the formal planning phase, but I like to separate it out on its own so that we can really focus on creating software that is usable - remember our goal smile_wink  This phase will contain as much mocking-up and prototyping as is necessary for the customer to feel comfortable with the overall design.  Drawing things in OneNote doesn't take long but doing it will help your customer begin to visualize the end-user experience.
  3. Create
    The emphasis here is on short, iterative cycles.  The more customer involvement and feedback that you can gather here will again assist with overall ownership at the end of the day.  Rule of thumb: 2 week iterations; at least weekly collaboration with customer.
  4. Deploy
    Sit with the customer and take notes about any additional requirements.  Use this time to plan and prioritize future work.  The goal here is to get your customer to get their hands on the software and to have their say about things that could be better and hear about what they like.

That's it.  Overall, a very agile process where we get early feedback at each stage in the process.  Remaining close to the customer in the Create and Deploy stages allows us to gather real-time feedback and means that we can easily get the business to buy-off of adapting and refining what we are doing to constantly align to the needs of the customer.

posted on 5/31/2007 6:28:04 PM ( 7 Comments )


My SecondLife

OK, I've taken the plunge and created my SecondLife persona.  I don't know much about SecondLife etiquette yet so I'm not sure whether or not I'm supposed to blog my SecondLife name in real life - for that matter, should my second life persona have a blog?  Who knows?

Anyways, having worked in a virtual environment for some time now I can certainly see the benefits in a place like SecondLife where you can quickly go to catch up and meet your real world (and SecondLife) friends.

I'd actually like to see Readify have a SecondLife virtual apartment where we could meet up and go to to chill out.

I know that sounds a little wierd but unless you work for a virtual company you probably cannot fully appreciate the need to find virtual water coolers.  I imagine that having a SecondLife apartment that you'd bump into other Readifiarians quite regularly.  It could be a quick chat at breakfast or you might grab lunch together and chat about the day.  I think that there could even be a place for virtual SCRUMS to take place in an online location.

I'm going to play around with creating a few virtual meetings online and give it a try - but who knows, hopefully there could be a Readify meeting place in SecondLife soon smile_regular

posted on 5/29/2007 2:32:53 PM ( 2 Comments )


SharePoint -> Popfly -> SharePoint

Here's an interesting article whcih talks about using SharePoint as a data source for Popfly blocks and then hosting Popfly mashups within SharePoint itself:

Link to Microsoft SharePoint Products and Technologies Team Blog : SharePoint and Popfly integration -- yes, really!

Pretty cool.  Getting Popfly mashups "out there" is a significant step forward.

posted on 5/28/2007 10:41:05 AM ( 0 Comments )


My World : A Blogging Endeavour...

Ducas finally blogs smile_regular 

Link to My World : A Blogging Endeavour...

'bout time Duke!

posted on 5/27/2007 9:25:16 PM ( 0 Comments )


Now using Popfly

Yesterday I received my invite to start using the Popfly beta.  I wrote a little bit about Popfly the other day and explained the high level concepts behind it.  Having now created my first mashup I must say that I'm very impressed by the simplicity.  Within 30 minutes of logging in I had created a simple mashup which took data from a Flickr 'block' and displayed it using a Carousel 'block' to display a carousel of images of Readify from Flickr.  You can view a video of my first simple mashup here:

Simple Mashup 

Conceptually there's 3 main types of blocks that you can create:

  1. Data providers - the Flickr block is an example of this type of block.  Basically, the Flickr block connects to the Flickr web services to return data from them.
  2. UI Presentation - the Carousel is an example of this, so is the Page Turner.  In the case of the Carousel, it accepts data from a data provider and renders the pictures from that data in a carousel.  Likewise, the Page Turner takes links to URL's and displays them in a Silverlight "book" that allows you to flip through the pages to view images.
  3. Functions - yep, you can write blocks which take input and transform it into something else.  The RegExp block is an example of this.  With the RegExp block you provide the input, define an expression and choose a method that is exposed by the block.  The most interesting method that it exposes is getMatches.  One way to use getMatches might be to find a block which returns a string and then create a regex which scrapes that string to return all image URL's and then pipe the matches of that to a Carousel block.

I've also created a few blocks now and that is also very simple.  All you have to do is to create a bunch of Javascript which "does stuff" and then describe the metadata of your javascript via an XML manifest file.

Overall, Popfly looks like an interesting platform for creating high level functions and running them from the cloud.

posted on 5/27/2007 3:14:06 PM ( 0 Comments )


First Impressions on BlogML.vNext - Keyvan Nayyeri

Keyvan has been a busy guy and, over the past month or so has really taken over BlogML to plan a new release.  In the following post he talks about plans for a new release this summer which will be version 2.5: 

Link to First Impressions on BlogML.vNext - Keyvan Nayyeri

The list of features that are planned include:

  1. Create rich documentation for everything
  2. Unit test .NET API component
  3. Create a logo for project
  4. Add support for link lists
  5. Add supports for pingbacks
  6. Add supports for non-author users
  7. Improve the support for extended properties

These changes will really help to make BlogML much tighter and therefore help with adoption.  If you'd like to get involved with any of these tasks, please stroll over and register to join the project.

posted on 5/26/2007 9:42:51 AM ( 4 Comments )


YouTube - Microsoft Intern Video 2004

Found this classic via Berno's blog: 

 smile_regular

posted on 5/26/2007 9:37:30 AM ( 1 Comments )


Successful CrowdSourcing applications will require Reputation

Today I was thinking about virtual marketplace applications that provide services to customers by farming out requests to helpers.  This concept is known as CrowdSourcing and some examples might include things like Google Answers and Amazon's Mechanical Turk.  I expect the opportunities that exist for this style of application will grow in parallel with the growth of mash-up style applications on the web.  The rise of mash-ups and the success of folksonomy-style activites such as tagging have created an environment where CrowdSourcing is growing as a business model.

One of the barriers that I see to the growth of this new business model is working out how to provide service level agreements (SLA's) for activities that are outsourced to groups of participants over the internet.  I mean how do you start a business that relies on a crowd to be able to run - it's a bit of a chicken and egg problem in that until you have some inertia you may not be able to attract sufficient resources and you may not generate enough resources until you have a high enough profile.

So having an SLA which states that you can provide X within Y minutes or hours may be difficult.

Another barrier to the success of CrowdSourcing as a viable business model could be Reputation.  I mean would you pay big bucks for a Ferrari if you knew that it may have been assembled and designed by rank amateurs?  No, of course you wouldn't.  The quality of an item is usually linked to its reputation in some way... and so it will be with knowledge that is served up by the crowd.

So it's probably timely that, in my thinking about these types of problems that there's currently a bit of a blogging discussion going on Microsoft's next community reputation initiative: Claimspace.  Here's the thread as I've seen it so far:

Korby describes Claimspace

Ted Haeger asks whether we can trust Microsoft

Korby's reply to Ted's post

Reputation and Federated Reputation could certainly have a very significant role to play in the future, collaborative web, so conversations such as these fascinate me.

 

NOTE: I just realized that Korby linked to ProjectDistributor in his article about Claimspace... cool! smile_shades

posted on 5/24/2007 5:01:30 PM ( 1 Comments )


Popfly

I’ve been looking at Popfly this week and it started a whole lot of searching and reading.  If you haven't seen Popfly yet I'd highly recommend that you head off and watch this video now and then come back:

http://msdn.microsoft.com/vstudio/media/en/popfly/PopFlyin15.wvx

Popfly is a tool for building mash-up style applications.  With this application you create Blocks that connect data and visualize it somehow.  Sample scenario:

Connect a VirtualEarth Block to a Twitter Block and produce a mash-up map showing where on the planet conversations are taking place in real time.

The concept is extremely cool and I've already applied to use the system in its infancy.  Popfly will empower a whole new breed of people to build and deploy mashups on their blogs and community sites - so it's really needed.

posted on 5/24/2007 4:31:33 PM ( 0 Comments )


Does your architect scale?

I'm sure that, you've architected applications and then managed teams as they've gone about implementing your designs to produce a final product.  As the architect you typically get involved in the process from the start and therefore have a good understanding of the requirements underlying the design.  In the case where you are a small team you've probably also designed and written quite a bit of the framework code and done most of the hard-core prototyping yourself. 

Quality assurance

As your primary tasks come to an end, the development team tend to take over with development and then maintainance of the application.  At this point what is your ongoing role with the application?  Are you still charged with the responsibility of ensuring the performance and maintainability of the application?  If so, what is your strategy for having continued visibility over changes to the codebase and, ultimately the structural design of the applicaiton?  How do you maintain the quality assurance of your application?  Or do your applications all face a gradual decline in quality after their careful, initial design and creation?

Clearly you cannot keep an intimate knowledge over all of the applications in your stable because, as time increases, so does the number of applications that you've been involved with.  But what are the key indicators that you can leave in your wake to alert you about the general state of degradation over time?

posted on 5/22/2007 7:44:41 AM ( 4 Comments )


Forward Movement

This exercise is good with a small group and is designed to:

  1. Help forwards to become more dynamic in the circle
  2. Have a strategy on set plays taken within 5 yards of the top of the 'D'

The reason for wanting dynamic movement within the circle when you have a set free just outside is that you want the defenders to be moving.  Allowing the defenders to remain static gives them a much better opportunity to trap the ball and clear it out.

 

Forward Movement

 

In the drill you have an attacker (A1) positioned a couple of yards outside of the top of the circle.  You also have 2 attackers within the circle (A2 and A3) who are positioned where they want to ultimately receive the ball.  When A1 is in place, the two attackers move quickly out from their position to a cone that is positioned about 5 yards away and then they dart back to their original position to receive the ball.  Attacker A1 will hit a hard ball to either A2 or A3.

Stress the importance of knowing where the zones are and work the drill until there is confidence by all players that they know where to aim for.  This drill is about:

  1. Knowing the zones
  2. Practicing the timing of the runs

posted on 5/21/2007 8:29:18 AM ( 0 Comments )


Catching up with colleagues

During the week we had some information meetings for Readify staff in Melbourne and Sydney.  These events were a great way for us to all catch up with one another and, because we've had so much growth over the past 6 months, for some it was the first time that we'd met.  Unfortunately I was unable to attend the Melbourne event - due to family commitments.  The Sydney event was well attended with about 24 of us on deck to keep the beer and wine flowing and to talk about where we're headed as a company over the next 12 months.

Chatting with Grant

Mark Landells, Phil Beadle, me, and Grant Holliday.

There were many things to discuss during the evening because we've grown both in terms of number of consultants but also we've nearly doubled the size of the management team.  Grant talked about our IT infrastructure and where we are at with our MOSS implementation as well as with Exchange 2007.  Andrew Parsons talked about Readify's upcoming involvement with ReMIX and also our plans for Tech.Ed attendance later this year.  I talked about what I've been up to with the Dev Centre and also explained how the PD program will be run next year.

Talking about our PD program and the new Dev Centre

Talking about the new Dev Centre and PD program.

All-in-all it was a terrific evening and it was great to catch up with all the guys again.  You can well imagine the amount of passion and the number of interesting conversations that ensue when you have people like Mitch Denny, Paul Glavich, Greg Low, and Paul Stovell (to name but a few) in a room together smile_regular

posted on 5/19/2007 9:36:33 AM ( 0 Comments )


Enthusiasm

 

Nothing great was ever achieved without enthusiasm.
Ralph Waldo Emerson
US essayist & poet (1803 - 1882)

Source: Quote Details: Ralph Waldo Emerson: Nothing great was ever... - The Quotations Page

posted on 5/16/2007 5:43:01 AM ( 0 Comments )


Hrm, should I be worried?

I was walking past the fridge today when I saw this post-it note stuck to the calendar in the kitchen:

How to kill your husband

I'm not worried or anything, Anne and I have a great relationship. But if you don't see me post here for a while... smile_omg

posted on 5/13/2007 9:33:21 PM ( 1 Comments )


Rule-based reporting

This week we had a requirement to display many differently filtered views of data within a web page.  In this particular instance, the data represented a resultset of items from one of our line of business apps.  Each view of the data was based on a particular set of logic and needed to be displayed in a grid like so:

rule processor

 

The report was for showing various exceptional states of resource scheduling data and so each category represented a different exceptional state, such as:

  1. Over allocated entries
  2. Under allocated entries
  3. Entries where the submitted values were less than the scheduled values
  4. Entries submitted on days when the sun was shining and where there were 3 or more red cars parked in the carpark

You get the idea smile_regular  In creating the report I wanted to ensure that we could easily add new category sections quickly and so I went for a processing system where you could easily create and add new rules to a single processing pipeline.  So we start with a generic definition of a rule and an item that the rule will act upon:

internal class GenericItem {

     private int _id;
     public int ID { get { return _id; } set { _id = value; } }

     public GenericItem(int id) { this._id = id; }

     public override string ToString() { return "Name: " + _id.ToString(); }
}

internal abstract class ItemRule {

     List<GenericItem> _matches = new List<GenericItem>();
     public List<GenericItem> Matches { get { return this._matches; } set { this._matches = value; } }

     abstract public void Evaluate(GenericItem item);
     virtual public void Complete() { this.Clear(); }
     virtual public void Clear() { }
}

You can see from this code that each rule will receive an item to evaluate and will expose a Matches collection of the items which match the rule definition.  The ItemRule class is abstract so the implementation logic for each rule will be contained in the Evaluate method of each of the derived rule classes.  Here's a couple of simple rules which filter items based on whether they are odd or even:

internal class IsEvenRule : ItemRule {
     public override void Evaluate(GenericItem item) {
          if (item.ID % 2 == 0) this.Matches.Add(item);
     }
}

internal class IsOddRule : ItemRule {
     public override void Evaluate(GenericItem item) {
          if (item.ID % 2 == 1) this.Matches.Add(item);
     }
}

These rules are very simplistic.  They perform a simple piece of logic and then if the item matches that logic they add the item to their Matches collection.  Some rules would be much more complex though.  Consider a rule where you need to match where there are a certain number of items in the list - meaning that you couldn't fully report until you had done a complete scan of all of the items.  Here's a rule for such a situation where the Match collection is populated only where there are greater than 10 instances of odd-numbered items in the list:

internal class TenOddsRule : ItemRule {

     List<GenericItem> _evaluatedItems = new List<GenericItem>();

     public override void Evaluate(GenericItem item) {
          if (item.ID % 2 == 1) {

               if (this._evaluatedItems.Count == 9) {
                    foreach (GenericItem evaluatedItem in this._evaluatedItems) {
                         this.Matches.Add(evaluatedItem);
                    }
               }

               this._evaluatedItems.Add(item);

               if (this._evaluatedItems.Count >= 10) {
                    this.Matches.Add(item);
               }
          }
     }

     public override void Complete() {
          this._evaluatedItems.Clear();
          base.Complete();
     }
}

Notice that the rule adds has a private list that it adds items to and only populates its Matches collection when the inner-list grows to beyond 9 items.

Now we can wrap our rules logic within a generic processing pump that will contain the logic for performing iteration and applying each of the rules to the items in the list, like so:

internal class ItemProcessor {

     List<ItemRule> _rules = new List<ItemRule>();
     public void AddRule(ItemRule rule) {
          rule.Clear();
          _rules.Add(rule);
     }

     public void AddRules(IEnumerable<ItemRule> rules) {
          foreach (ItemRule rule in rules) { AddRule(rule); }
     }

     public void ProcessItems(List<GenericItem> items) {

          foreach (GenericItem item in items) {
               foreach (ItemRule rule in _rules) {
                    rule.Evaluate(item);
               }
          }

          foreach (ItemRule rule in _rules) {
               rule.Complete();
          }
     }
}

Then we can create some rules and add them to our processor:

IsEvenRule evensRule = new IsEvenRule();
IsOddRule oddsRule = new IsOddRule();
TenOddsRule tenOddsRule = new TenOddsRule();

ItemProcessor processor = new ItemProcessor();
processor.AddRules(new ItemRule[] { evensRule, oddsRule, tenOddsRule });

processor.ProcessItems(items);

With the items processed, we can now use the Matches collections to bind to our UI elements, like so:

rpt1.DataSource = evensRule.Matches ;

rpt2.DataSource = oddsRule.Matches ;
rpt3.DataSource = tenOddsRule.Matches ;

The real beauty of using this approach is that new rules can be created quickly and easily to meet the needs of the business while keeping the processing logic distinct and easy to maintain.

posted on 5/11/2007 6:12:18 PM ( 0 Comments )


Article submission to ASP.NET declined

In the past I've regularly written articles about topics which relate to ASP.NET - particularly web parts - and submitted them via the Article of the day feature so that I might increase the scope of articles that I consider to be of higher quality.  Today, for the first time I got a rejection notice:

Thank you for your article submission, "Dynamic Tabbed Web Part Pages".
http://markitup.com/Posts/Post.aspx?postId=b26cb7a6-451b-4398-bbfd-ff31fa50309b

All articles are reviewed to determine if they meet the following criteria:

1) The article must be directly relevant to ASP.NET. An article concerning general .NET development or general web development will not be accepted.
2) The article must be freely accessible to the public. Pay-for-access articles will not be accepted.
3) The article must be of high technical quality. An article that does not follow recommended practices will not be accepted.
4) The article must be of high editorial quality. An article marked by poor spelling, grammar, or style will not be accepted.
5) The article must be an independent online publication. A weblog entry or a code snippet will not be accepted.

Unfortunately, your article did not meet one or more of these criteria and therefore we have decided not to publish it on the site. If you feel there has been an error then simply reply to this message and we can discuss the decision not to publish the article. Thank you for your understanding on this matter and we look forward to future submissions from you.

Fair enough, maybe I have to start writing articles about ActiveX or how to use IIS6 and Community Server. Bitter? Who me? Naaaahhhhh! smile_devil

grumble, mumble...

posted on 5/10/2007 2:16:08 PM ( 6 Comments )


Predicates as rules

Generic predicates are a great way to encapsulate the logic for filtering collections.  Recently we had a business application where we had to show various views of a collection based upon certain business rules and generic predicates were the perfect match.  Generic predicates are methods that work on a List<T> and which take a delegate that works on each item in the list to return only the items that conform to a specific piece of logic.  Let's look at an example, we'll start by creating a List<T> which contains 10 items:

List<TestClass> tests = new List<TestClass>();

for (int i = 0; i < 10; i++) {
    tests.Add(new TestClass(i + 1));
}

In the above code snippet we have a List<T> variable named 'tests' which contains 10 elements and within that list each element holds an instance of the TestClass type.  Now let's imagine that this list is a list of Timesheet entries and that we are given a request to display a subset of those entries based on some business rules

The List<T> class has a FindAll method on it which takes a Predicate<T> argument and returns a List<T>.  Inside of the the FindAll method, each item in the List<T> is enumerated and evaluated against the Predicate<T> argument passed in to it.  The Predicate<T> is the place where we can add our business rules to return the subset list.  So based upon the list in the above snippet, let's imagine that we have a business rule to return only TestClass instances that are odd numbered.  To do this we would first write a method which represents our business rule that we can use to inspect a TestClass instance and return true or false based on whether that instance is odd numbered or not.  Such a method might look like this:

public static class BusinessRules {
     public static bool IsOdd(TestClass target) {
          return target.ID % 2 == 1;
     }
}

Because List<T>'s FindAll method takes a Predicate<T>  - a signature that our IsOdd method conforms to - we can use our IsOdd as the filter for the FindAll evaluator on our List<T. collection instance like so:

List<TestClass> odds = tests.FindAll(new Predicate<TestClass>(BusinessRules.IsOdd));

Interestingly we can also replace the argument with a delegate which matches the same signature like so:

List<TestClass> odds = tests.FindAll(delegate(TestClass target) { return target.ID % 2 == 1; });

However I like the first method because it's more self-describing to see a delegate named BusinessRules.IsOdd to infer the meaning of what's going on.  Below is the code for a program which displays the output for 2 lists based on a different set of business rules.  1 list displays even numbers while the other displays odd numbers:

 

private static void RunPredicateRules() {
    List<TestClass> tests = new List<TestClass>();

    for (int i = 0; i < 10; i++) {
        tests.Add(new TestClass(i + 1));
    }

    List<TestClass> evens = tests.FindAll(new Predicate<TestClass>(BusinessRules.IsEven));
    List<TestClass> odds = tests.FindAll(new Predicate<TestClass>(BusinessRules.IsOdd));

    Console.WriteLine("Displaying Evens:");
    evens.ForEach(new Action<TestClass>(DisplayAll));

    Console.WriteLine("Displaying Odds:");
    odds.ForEach(new Action<TestClass>(DisplayAll));

    Console.ReadLine();
}

 

static void DisplayAll(TestClass target) { Console.WriteLine("ID = {0}", target.ID); }

 

public static class BusinessRules {
    public static bool IsOdd(TestClass target) { return target.ID % 2 == 1; }
    public static bool IsEven(TestClass target) { return target.ID % 2 == 0; }
}

public class TestClass {
    public TestClass(int id) { this._id = id; }

    private int _id;
    public int ID { get { return _id; } set { _id = value; } }
}

posted on 5/9/2007 9:49:22 PM ( 2 Comments )


2 on 1 agile, problem solving

This exercise is good when you have a small'ish group:

2 on 1

Attacker (A1) delivers a firm ball to attacker (A2) who has the defender hot on his tail.  As soon as A2 receives the ball he peels off and it becomes a 2-on-1 against the defender (D2).  The goal of this exercise is to have lots of repetitions to try different ways to defeat D1. 

posted on 5/9/2007 12:37:10 PM ( 0 Comments )


Silverlight Install Modes

I saw this via Duncan's blog this morning.  With Silverlight there are apparently two install modes.  You can either provide users with an inplace install experience whereby the Silverlight plug-inwill install while your users remain on the page whereas my understanding is that the alternative - an external install of the plug-in - will redirect your users to the Microsoft site to get the plug-in.  Click on the following link for more information:

Link to Web.Next : Silverlight Install Modes

posted on 5/9/2007 12:09:19 PM ( 0 Comments )


WordPress BlogML Export - Keyvan Nayyeri

Wow!  As Keyvan blogged, Rob McLaws has created a WordPress to BlogML converter and added it to the BlogML project on CodePlex.  Awesome!! smile_teeth

That makes Live Space and WordPress implementations both added during the week.

posted on 5/8/2007 2:10:50 PM ( 0 Comments )


4 on 2 drill to sharpen up teamwork between forwards

Four on one

 

  1. Ball starts with defender (D1)
  2. D1 passes firmly to attacker (A1)
  3. A1 dribbles in an arc around a small group of cones
  4. Attackers A2, A3, and A4 are released to support A1 and make attacking position
  5. The drill becomes a 4-on-2.

posted on 5/7/2007 8:27:31 PM ( 1 Comments )


Pink Floyd - The Great Gig in the Sky (1988)

Source: YouTube - Pink Floyd - The Great Gig in the Sky (1988)

posted on 5/6/2007 10:18:17 PM ( 1 Comments )


YouTube - Green Day - Brain Stew/Jaded

Source: YouTube - Green Day - Brain Stew/Jaded

posted on 5/6/2007 9:58:32 PM ( 0 Comments )


Seth's Blog: The most important rule

By a factor of three, what you do is not nearly as important as how it makes people feel

Source: Seth's Blog: The most important rule

posted on 5/6/2007 10:24:08 AM ( 0 Comments )


Bud Light Ads

Brazillian Fighting Cockatoo

 

Magic Fridge

posted on 5/5/2007 9:51:41 AM ( 0 Comments )


Which is faster, K&R or Allman?

The other day I was profiling some code for a new application that we're building at work and I came across some interesting performance data.  I was profiling the app because, under certain conditions we were noticing that the client was acting sluggishly and so I wanted to try and speed things up.  And of course you should never change code for perf. without measuring first - so measure I did. 

The code that I was measuring at the time used the Allman style of bracing where bracing starts on a newline - whereas my editor preferences are the One True Style of bracing - K&R. 

In between running one set of tests and the second set I accidently did a "Control-A, Control-X" and cut all of the code from the page.  Noticing my error I quickly pasted the code back.  This of course had the effect of changing the bracking style to K&R throughout the document.  I didn't think much of it and re-ran my tests.  To my surprise the results were different - quite different!

I ran the tests several more times and it turns out that code written using K&R style bracing is almost 1% faster than code written using Allman style!

Here's some tests that I used to demonstrate this behaviour.  The Pop methods come from within a class named StackHelper<T>:

public T Pop() {
    if ( this.offset == growthSize ) {
        this.stack = this.stack.Next;
        this.offset = 0;
        this.growthSize >>= 1;
    }  

    return this.stack.Data[offset++];
}

public T Pop2()
{
    if ( this.offset == growthSize )
    {
        this.stack = this.stack.Next;
        this.offset = 0;
        this.growthSize >>= 1;
    }

   return this.stack.Data[offset++];
}

Then we run some tests to see how they perform (I've left a lot of the initialization code out for clarity):

Stopwatch watch = new Stopwatch();
watch.Start();

for( int i=0; i<1000000; i++ ) {
    helper.Pop<int>() ;
}

watch.Stop();
Console.WriteLine("K&R: {0}", watch.ElapsedMilliseconds);

watch.Reset() ;

watch.Start();

for( int i=0; i<1000000; i++ ) {
    helper.Pop2<int>() ;
}

watch.Stop();
Console.WriteLine("Allman: {0}", watch.ElapsedMilliseconds);

And as we can see from the numbers below, our winner here is clearly the K&R style:

K&R: 99976
Allman: 100866

posted on 5/3/2007 7:22:54 PM ( 7 Comments )


ShowUsYour<Regex> : Death by Abstraction

In my known universe everything sits on a plane - and there are many planes. Some planes are close together and some are far apart; some are thick and some are thin; some are wide and long while others are short and narrow; others still intersect. Most importantly some planes can be grouped together to form larger entites. When planes are grouped together they form a hierarchy and within that hierarchy each plane contains the knowledge that is required to understand the plane and also information regarding the plane(s) that it is preceded by.

You can traverse planes by locating gates but, as a general rule you cannot simply open the gates - although you can get through that way - but you must climb, or transcend them.

I can still remember my first plane traversal, it was only 3 years ago but it stands as a significant achievement. At that moment I stood in a new place amid rare air and could survey all planes that I had travelled to arrive there. Looking back through them gave me a view that, until that moment I had never seen.

I am reminded of some words that belong to someone that I believe has been to that place:

"My comprehension of things at this level of abstraction usually only lasts for a few hours (at best) but at least it's fun once in a while to climb up to the mountaintop and breathe the fresh air!"

Where am I now? Why transcending new planes of course!

Source: ShowUsYour : Death by Abstraction

posted on 5/3/2007 12:08:36 AM ( 4 Comments )


Home

Here's a link to the documentation for the new May 2007 Futures CTP release for asp.net:

ASP.NET AJAX Futures Release

posted on 5/2/2007 11:01:34 PM ( 0 Comments )