Notes from the trenches.

Favouritism

Posted: June 18th, 2009 | Author: admin | Filed under: Uncategorized | No Comments »

I was a fairly early adopter of Twitter. I like to think I keep my ear to the ground with regard to technology and try to give anything cool a little chance. Twitter has completely changed the way I use the web, and has completely killed social news for me. I don’t care what’s popular to everyone. I want to look at what my friends think is interesting. My new boss said “Twitter makes the web feel alive again”. I think he’s right, except that it’s sometimes too alive.

I find myself looking at things I would never have found, sometimes at the detriment to my progress. There’s also been stories of people being fired because of Tweets about a new job or regarding an opinion on something in their current one. Never mind the new employer seeing their huge amount of updates during work hours.

Twitter achieved Critical Mass, earlier in the year and that’s fantastic. The main stream has embraced the technology. This isn’t new though. On average I estimate 3 or 4 websites have reached that magic Critical Mass per year for the last 10 years. Lets list a few (lists are fun, even in no particular order) until we get bored or this blog post gets too long.

  • fb.

Ok, bored. All of these websites are important to me and I have used most of them since they were available to me. Am I in the mainstream even though I’m a massive technophile? Lets draw a Venn diagram to illustrate what I think is happening.

venn

Now this may seem like I’m being massively aloof. However, I think I find tools that what I perceive as the main stream of people don’t find and I also spend a lot more time online and so use more. I also think that the mainstream uses tools that I have dismissed because I’ve seen a better version or that I don’t even know about!

What I like to see is that the mainstream is moving closer to the technorati. There are more like minded people coming together.

I someday want to create something that achieves critical mass because I, like Jeff Atwood, think it is the ultimate accolade as a software developer.


Mind Programming, or How I Learned To Stop Fearing The Unknown and Get on with My Life

Posted: June 3rd, 2009 | Author: admin | Filed under: personal, social, tech | Tags: , , , , , | No Comments »

Collecting quotes from the web and books that I think are profound or funny is a hobby of mine. A simple sequence of words can change the way a person thinks. I find this fascinating and I’m not alone.

Read the rest of this entry »


Let’s take a shortcut

Posted: May 19th, 2009 | Author: admin | Filed under: code, personal | Tags: , , , , , | No Comments »

I’ve been working with a lot of new developers lately and have noticed that there’s a lot of useful keyboard shortcuts in Visual Studio that I never bothered to learn. Now I always stick with the default configuration unless it’s absurd or something I really like (for example turning hard corded strings yellow) because customisation doesn’t propagate.

Read the rest of this entry »


Best Hack

Posted: April 15th, 2009 | Author: admin | Filed under: code | Tags: , , , , , , , | No Comments »

I was just thinking what my best hack has been and I think it’s the fix for the following scenario.

I was refactoring the RSinteract source code to get rid of some duplicated classes that had over the course of a, shall we say, rigourous development schedule got disparate. Some classes were used from one set some from the other. I merged them into the common library and deleted all the old ones. This was fine until we ran an old report that had filters on it. Because the types had been serialized into the custom RDL of the report they had the old namespace stored there. Which threw an error when deserializing with the new hierarchy.

So what to do… I had a brainwave:

   1: using System;
   2: using System.Collections.Generic;
   3: using System.Text; 
   4:  
   5: namespace Ics.Reporting.Data
   6: {
   7:     [Serializable]
   8:     public class Dimension : Ics.Reporting.Common.Data.Dimension
   9:     {
  10:         //Proxy class to fix issues with old reports containing a reference to this class which has
  11:         //been moved to Ics.Reporting.Common.Data.Dimension
  12:     }
  13: } 

The empty proxy class in the old namespace that inherits from the new class. Leave a comment as to why. Et voila! No more broken old reports.

What’s your best hack imaginary readers?


Bad Project Top Trumps

Posted: April 2nd, 2009 | Author: admin | Filed under: rant | Tags: , , , | 2 Comments »

I’ve been hearing about a lot of bad and late projects lately. So I’ve come up with a game you can play with your friends to remind you how not to do things!

Bad project top trumps. [Disclaimer: This is just a bit of fun, figures are completely arbitrary and bear no relation to real projects].

Instructions:

  1. Print off this post 2 sets of these cards
  2. Find a friend
  3. Shuffle the cards
  4. Deal the cards such that each player has the same number
  5. Each player takes a card from the top of their deck
  6. Each player reads out his or her Likelyhood of failure
  7. The winner is the one with the highest of lowest (depending on the player’s disposition)
  8. The winner takes the loser’s card and chooses the next statistic to compare on the next draw
  9. The game is over when one player has taken all of the other’s cards

Cards:

Found Time

  • Task Lists: 0
  • Developers: 5
  • Deadline Proximity: 10
  • Remaining Work: 100
  • Architects: 1
  • Scope Creep: 0
  • Time spent on design: 20
  • Managers: 5
  • Likelyhood of failure: 85%

Death March

  • Task Lists: 1
  • Developers: 5
  • Deadline Proximity: 70
  • Remaining Work: 300
  • Time spent on design: 150
  • Scope Creep: 20
  • Architects: 2
  • Managers: 2
  • Likelyhood of failure: 90%

The Overengineer

  • Task Lists: 2
  • Developers: 10
  • Deadline Proximity: 100
  • Remaining Work: 100
  • Time spent on design: 200
  • Scope Creep: 50
  • Architects: 5
  • Managers: 0
  • Likelyhood of failure: 50%

Surgeon’s Theatre

  • Task Lists: 1
  • Developers: 10
  • Deadline Proximity: 100
  • Remaining Work: 500
  • Time spent on design: 500
  • Scope Creep: 75
  • Architects: 1
  • Managers: 8
  • Likelyhood of failure: 90%

Holy Grail

  • Task Lists: 1
  • Developers: 5
  • Deadline Proximity: 100
  • Remaining Work: 50
  • Time spent on design: 50
  • Scope Creep: 0
  • Architects: 1
  • Managers: 1
  • Likelyhood of failure: 10%

Hacking My Life

Posted: April 2nd, 2009 | Author: admin | Filed under: code, personal | Tags: , , , , | No Comments »

I’ve been in a bit of a slump recently. Life is good, but my personal development has been suffering due to my active social life and burgeoning fitness addiction (more on that later). I always feel a bit down when I’m not running at full revs on my personal development.

So what am I doing about it. Well I have a plan. A learning plan and a structured one at that. I’ve still been reading blogs and keeping up with the newest tech as much as I can but I find this doesn’t really give me that much. The plan then, is:

1. Reduce intake of useless blog information
2. Stop procrastinating on music, cartoons, youtube
3. Make a spread sheet for each topic to learn
4. In each spreadsheet put between 1 and 10 things to learn about the topic ending in a specific goal
5. Complete at least 5 items per week.

learning spreadsheet

learning spreadsheet

Simple plan, but is it going to work?

Last night I started writing a WordPress Theme for the first time, and I started getting excited again.

The first step was to mock it up and I discovered can still write a decent looking 3 column layout in pure CSS. The next step is to come up with a pretty design in Photoshop, something I’ve never done before!

Other topics I’m looking at are:

  • Revisiting ASP.NET MVC
  • Design
  • F#
  • WPF
  • TDD
  • PHP
  • Some Misc topics that I’ve wanted to do such as writing a Ubiquity command
  • Guitar
  • French

There’s also a couple of side projects on the go at the moment which are helping to drive this.

Watch this space for a new theme with my name on it!


TED Talk: The Sixth Sense

Posted: March 12th, 2009 | Author: admin | Filed under: news, social, tech | Tags: , , , , , | 1 Comment »

This absolutely blew my mind, the most advanced symbiois between human and technology I have ever seen. The singularity is upon us.


Improving in 6 minutes

Posted: February 24th, 2009 | Author: admin | Filed under: code, personal | No Comments »

Just read a post over at secretGeek on how to become a better programmer in 6 minutes. Leon explains a few quick activities that you should do to improve yourself.

My favourites are:

2: Make hard-coded strings look ugly.

I learnt this from Joe Cooney.

Go to your favourite IDE, and set it so that literal strings stand right out — for example a yellow background with a red font. Make ‘em ugly. Damn ugly. This will encourage you to perform less hard coding, and to notice when you are embedding strings in your text.

3: Pick an ‘obscure’ keyword and master it

Do you fail to yield?. Is there a keyword you never use?

Every keyword has a purpose. Learn to master those mystery keywords and your powers will become extraordinary.

Here are lists for a few .net languages: C#, VB.net, F#.

4. Increase code-coverage by 1%

Don’t kill yourself striving for 100% coverage of code with automated unit tests. But take a few minutes to increase your coverage by 1%.

Most likely, that means going from 0% to 1%. And that’s the biggest improvement of all.

Find a particularly ghoulish regular expression. Or a critical piece of business logic. These things can’t be trusted without tests.

7. Pick an ugly method to refactor

You know the method. That method you’re particularly ashamed of. That one that’s long and ugly and horrible. And it’s crucial to the whole application.

You don’t have to polish it from a turd to a diamond, but just neaten it up a little. Rename a variable. Hoist part of it out into a separate method. Start simple. The momentum will increase. Watch out.

These are all great little things you can do in those little time pockets where you’d usually just randomly click on stuff until an email comes back or someone responds on IM. I’ve got one more to add.

Automate a process
You know that thing that takes a few minutes and you sometimes have to do twice because you miss a step? You know the ones I’m talking about! The little oddity in your build, or that annoying service/api project, editting a version number for the latest build and putting it back into source control. Well, honestly you could probably do it with a script that you could write in under 6 minutes. I just wrote one to build and install a service for debug:

   1: @ECHO OFF
   2: CALL "C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat"
   3: msbuild "C:\Development\Solutions\Solution.sln"
   4: installutil /u "C:\Development\Solutions\Soution\bin\Debug\Soution.exe"
   5: installutil /username=IOC-DEV-UK5\Administrator /password=*** "C:\Development\Solutions\Soution\bin\Debug\Soution.exe"

Now I can get my service ready for debug in 1 click rather than openning the Visual Studio command prompt, typing in the folder structure, realising I’ve forgotten to do "Run as administrator" every bloody time!

You’ll be amazed how much time you save and the satisfaction you get from solving a little problem like this.


Experiences with Unity

Posted: February 18th, 2009 | Author: admin | Filed under: code, personal | Tags: , , , , , , , , , | No Comments »

I’ve been very busy over the last few weeks. The new RSinteract beta is due out at the end of this month (several clients are currently using it with no problems) and it looks sweeeet! Pretty proud of my contribution to that particular project and kind of sad that I’m no longer working on it. I’m now involved on a new project involving a certain sporting event taking place in 2012. It’s quite exciting and I’ve been given a fairly important part of the architecture to work on.

Finally, lots of new technology and challenges to overcome for me. One of these is dependency injection using an IoC container. I’ve worked on projects that have used it them and have understood the general principles but never have I had full control of it – it’s always been there already. This time I’m learning it properly myself. The technology that has been chosen is Microsoft’s Unity 1.2 which ships with the Enterprise Library 4.1 (Oct 2008 release). At first glance Unity appears overly complex because the documentation for it is – as Microsoft love to do – overly complicated and tries to show you everything on one page. For example:

   1: <?xml version="1.0" encoding="utf-8" ?> 
   2: configuration>
   3:  
   4: configSections>
   5:  <section name="unity"
   6:            type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection,
   7:                 Microsoft.Practices.Unity.Configuration, Version=1.1.0.0,
   8:                 Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
   9: /configSections>
  10:  
  11: unity>
  12:  
  13:  <typeAliases>
  14:  
  15:    <!-- Lifetime manager types -->
  16:    <typeAlias alias="singleton"
  17:         type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager,
  18:               Microsoft.Practices.Unity" />
  19:    <typeAlias alias="external"
  20:         type="Microsoft.Practices.Unity.ExternallyControlledLifetimeManager,
  21:               Microsoft.Practices.Unity" />
  22:  
  23:    <!-- User-defined type aliases -->
  24:    <typeAlias alias="IMyInterface"
  25:         type="MyApplication.MyTypes.MyInterface, MyApplication.MyTypes" />
  26:    <typeAlias alias="MyRealObject" 
  27:         type="MyApplication.MyTypes.MyRealObject, MyApplication.MyTypes" />
  28:    <typeAlias alias="IMyService"
  29:         type="MyApplication.MyTypes.MyService, MyApplication.MyTypes" />
  30:    <typeAlias alias="MyDataService"
  31:         type="MyApplication.MyTypes.MyDataService, MyApplication.MyTypes" />
  32:    <typeAlias alias="MyCustomLifetime" 
  33:         type="MyApplication.MyLifetimeManager, MyApplication.MyTypes" />
  34:  
  35:  </typeAliases>
  36:  
  37:  <containers>
  38:  
  39:    <container name="containerOne">
  40:  
  41:      <types>
  42:  
  43:        <!-- Type mapping with no lifetime – defaults to "transient" -->  
  44:        <type type="Custom.MyBaseClass" mapTo="Custom.MyConcreteClass" />
  45:  
  46:        <!-- Type mapping using aliases defined above -->  
  47:        <type type="IMyInterface" mapTo="MyRealObject" name="MyMapping" />
  48:  
  49:        <!-- Lifetime managers specified using the type aliases -->
  50:        <type type="Custom.MyBaseClass" mapTo="Custom.MyConcreteClass">
  51:          <lifetime type="singleton" /> 
  52:        </type>
  53:        <type type="IMyInterface" mapTo="MyRealObject" name="RealObject">
  54:          <lifetime type="external" />
  55:        </type>
  56:  
  57:        <!-- Lifetime manager specified using the full type name -->
  58:        <!-- Any initialization data specified for the lifetime manager -->
  59:        <!-- will be converted using the default type converter -->
  60:        <type type="Custom.MyBaseClass" mapTo="Custom.MyConcreteClass">
  61:          <lifetime value="sessionKey"
  62:                    type="MyApplication.MyTypes.MyLifetimeManager,
  63:                          MyApplication.MyTypes" />
  64:        </type>
  65:  
  66:        <!-- Lifetime manager initialization using a custom TypeConverter -->
  67:        <type type="IMyInterface" mapTo="MyRealObject" name="CustomSession">
  68:          <lifetime type="MyCustomLifetime" value="ReverseKey"
  69:                    typeConverter="MyApplication.MyTypes.MyTypeConverter,
  70:                                   MyApplication.MyTypes" />
  71:        </type>
  72:  
  73:        <!-- Object with injection parameters defined in configuration -->
  74:        <!-- Type mapping using aliases defined above -->  
  75:        <type type="IMyService" mapTo="MyDataService" name="DataService">
  76:          <typeConfig extensionType="Microsoft.Practices.Unity.Configuration.TypeInjectionElement,
  77:                                     Microsoft.Practices.Unity.Configuration">
  78:            <constructor>
  79:              <param name="connectionString" parameterType="string">
  80:                <value value="AdventureWorks"/>
  81:              </param>
  82:              <param name="logger" parameterType="ILogger">
  83:                <dependency />
  84:              </param>
  85:            </constructor> 
  86:            <property name="Logger" propertyType="ILogger" />
  87:            <method name="Initialize">
  88:              <param name="connectionString" parameterType="string">
  89:                <value value="contoso"/>
  90:              </param>
  91:              <param name="dataService" parameterType="IMyService">
  92:                <dependency />
  93:              </param>
  94:            </method>
  95:          </typeConfig>
  96:        </type>
  97:  
  98:      </types>
  99:  
 100:      <instances>
 101:        <add name="MyInstance1" type="System.String" value="Some value" />
 102:        <add name="MyInstance2" type="System.DateTime" value="2008-02-05T17:50:00"  />
 103:      </instances>
 104:  
 105:      <extensions>
 106:        <add type="MyApp.MyExtensions.SpecialOne" />
 107:      </extensions>
 108:  
 109:      <extensionConfig>
 110:        <add name="MyExtensionConfigHandler"
 111:             type="MyApp.MyExtensions.SpecialOne.ConfigHandler" />
 112:      </extensionConfig>
 113:  
 114:    </container>
 115:  
 116:    <!-- ... more containers here ... -->
 117:  
 118:  </containers>
 119:  
 120: </unity>
 121:  
 122: </configuration>

(Note this documentation is from 1.1)

Now I’m unit testing from the ground up. I don’t care about most of this stuff. I need the simplest implementation to start with. So all I really need in my config file is: the unity section declaration, a type alias and the container.  Like so:

   1: <?xml version="1.0" encoding="utf-8" ?>
   2: <configuration>
   3:   <configSections>
   4:     <section name="unity"
   5:                type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection,
   6:                  Microsoft.Practices.Unity.Configuration, Version=1.2.0.0,
   7:                  Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
   8:   </configSections>
   9:   <unity>
  10:     <typeAliases>
  11:       <!--IService-->
  12:       <typeAlias alias="IService"
  13:                  type="Project.Services.Contract.IService,
  14:                  Project.Services" />
  15:       <typeAlias alias="MockService"
  16:                  type="Project.Mocks.FakeService,
  17:                  Project.Mocks" />
  18:     </typeAliases>
  19:     <containers>
  20:       <!--Service is Mocked-->
  21:       <container name="UnitTest">
  22:         <types>
  23:           <type type="IService" mapTo="MockService" />
  24:         </types>
  25:       </container>
  26:     </containers>
  27:    </unity>
  28: </configuration>

That’s it. (Obviously any types referenced here need their assemblies referenced in the unit test project). Why isn’t there a good tutorial that points this out? It seems like Microsoft tripping themselves over again. I’ve found this with other parts of the Enterprise Library too. Thank god for StackOverflow!


Redirecting STDERR to STDOUT

Posted: January 7th, 2009 | Author: admin | Filed under: code | Tags: , , , , , , , | No Comments »

I like to post things that I just learned so here’s a good one. Some batch commands output their errors to the STDOUT and/or STDERR by default. If you’ve got a long batch script this can cause an issue because the output is lost due to the command line truncating the output.

Now most people know about redirecting the output to a file like so:

   1: command -option arg > commandlog.txt

However, this is only handling STDOUT, most commands will put error information (which is what we’re most interested in) to the STDERR. So how do we get at that?

Well to log both do this:

   1: command -option arg > logfile.txt 2>&1

The final token there redirects STDERR to STDOUT, thus putting it all into logfile.txt.

You can also log to seperate files if you like.

   1: command -option arg 1> stdoutlog.txt 2> stderrlog.txt

That concludes today’s lesson. I hope you find this useful at some point!

Good times.