Search This Blog

Monday, March 30, 2009

Bhai Log indoor cricket game (Grading game)

Our virgin game night (first game for our indoor season)…and in all honesty that’s exactly how we played smile_sad.

The game was highly anticipated by most players but especially me as I was captaining our squad this season after giving the veteran captain (Jacinth) a rest.  Big shoes to fill considering we won the last season we played when Jacinth was captain.

It did not start well for me…our first game and I had to sit out due to sickness but nonetheless we had enough players.  Luckily it was a grading game so it wasn’t that important.

Everyone got to the game in time…this is a rarity as we all follow IST (Indian Standard Time smile_wink) except this one dude who apparently forgot we had a game…Yes you know who you are smile_regular.  But then we did get a hold of him and managed to get him down to the venue in time.

Our batting performance was good, getting 140ish in the first game is not a bad effort at all but we were let down in the fielding department.  Not to mention that we nearly won the game too…the other team needed one run off the last ball to win as the scores was tied…it was a dot ball which the keeper struggled with (who can blame him…king does bowl which such sheer pace).  The batsmen had time to take a single and win the game…

Vengeance will be in our eyes next time smile_nerd…opps wrong emoticon…I meant smile_shades

Change

I have read quite a few blogs of people mentioning this word.  I am not going to provide a definitive answer and neither am I trying to “change” your viewpoint of what “change” is….I used the word “change” three times already without even analysing exactly of its definition.

What is change?

As per Google:
Definitions of change on the Web:

  • cause to change; make different; cause a transformation; "The advent of the automobile may have altered the growth pattern of the city"; "The discussion has changed my thinking about the issue"
  • an event that occurs when something passes from one state or phase to another; "the change was intended to increase sales"; "this storm is ...
  • undergo a change; become different in essence; losing one's or its original nature; "She changed completely as she grew older"; "The weather changed last night"
  • a relational difference between states; especially between states before and after some event; "he attributed the change to their marriage"
  • become different in some particular way, without permanently losing one's or its former characteristics or essence; "her mood changes in accordance with the weather"; "The supermarket's selection of vegetables varies according to the season"
  • the action of changing something; "the change of government had no impact on the economy"; "his change on abortion cost him the election"
  • switch: lay aside, abandon, or leave for another; "switch to a different brand of beer"; "She switched psychiatrists"; "The car changed lanes"
  • the result of alteration or modification; "there were marked changes in the lining of the lungs"; "there had been no change in the mountains"
  • change clothes; put on different clothes; "Change before you go to the opera"
  • the balance of money received when the amount you tender is greater than the amount due; "I paid with a twenty and pocketed the change"
  • exchange or replace with another, usually of the same kind or category; "Could you convert my dollars into pounds?"; "He changed his name"; "convert centimeters into inches"; "convert holdings into shares"
  • a thing that is different; "he inspected several changes before selecting one"
  • exchange: give to, and receive from, one another; "Would you change places with me?"; "We have been exchanging letters for a year"
  • a different or fresh set of clothes; "she brought a change in her overnight bag"
  • transfer: change from one vehicle or transportation line to another; "She changed in Chicago on her way to the East coast"
    wordnet.princeton.edu/perl/webwn

Rather complicated isn’t it…

How do I see change
Change is a mindset.  An inevitability which occurs sometimes even without you knowing.  You often change your mind, clothes, time changes, the weather changes, etc… Can you change something without actually changing it, absolutely! Well, that’s at least what I am getting at.  A change can be made simply by how you think about things.  You are changing your thinking and according to me that’s the most important kind of change and not to mention the most powerful change of all.  I do agree as humans we cannot change things which are out of our control…weather is a good example of that although if you can change a mind (your own or some else's) it is an amazing feat in a league of its own.  The greatest leaders in history, sporting legends, coaches, teachers are those who convince their disciples/students to change their way of thinking.  In effect changing their mind.  We are affecting free will, well not directly but nonetheless we are.

You must be thinking…blah blah blah, I know all of this which is true…everyone probably knows the above although this is not what the blog is about.  I am trying to determine and hopefully change (there the word CHANGE) the way you see “change”.

When you get faced with a change, how do you generally react?  I go through a range of feelings generally:

  • nervous
  • excited
  • anxious
  • scared
  • confidence

Now the above will definitely depend on whether the change was voluntary or involuntary and also how big a change is.  When you go through this emotions do you often take into consideration the implications of your change?  How often do you go through a “what-if” analysis trying out different paths of your decision making.  How often do you document or remember of what the reasoning behind your change was?  In all honesty I don’t think any person would go through this kind of analysis for a small to medium size changed…forget that…most people wouldn’t even do those kind of analysis for making bigger life changes (i.e. moving countries, changing jobs, marriage, etc).  Lets face it, we have big expectations from our brains, we attempt to remember the reasons for the change, completely possible to do…although how long will you remember this reasoning?

This forced me to think, can we make the process of change more reliable by remembering why and when we made a change.  Will this help us make better changes in the future?  This is a more generic solution, what I am currently in the process of doing is looking at this from a software developers perspective.

A software developer perspective…
Many a times have I done some work and come back to it and had trouble remember why and when the change was made.  If you work for a company surely they’ll have some sort of mechanism to document exactly this although more often than you think it will fall short of your personal expectations.  Maybe you are compulsive organiser like how I am and start writing endless pages of notes of why a change was required, where it was required, what other modules will the change effect, the tests you did to choose the optimum implementation of the change, etc etc.  Finally this will become hard to manage simply due to so much manual writing, sorting and especially searching back through pages of written work.  Isn’t there a better solution?

Surely there are better solutions out there…which you may have to pay for or other solutions which maybe completely generic and do not cater for your particular flavour of change management.  I really want something which I can use, modify and persist over years.  Something like a blog…but only for your coding changes.  This is when it came to me, I really want a visual DSL which can cater for my obtuse needs as they arise.  I can also use this wherever I go irrespective of the change I am making.

This system could not only help you document what change you made but also help you in determining how successful your change was 1-2 years down the line.  Did you make a change to fix your change, how did your change scale for the future, did you change too much so that you simply ended up writing a whole new feature (which defeats the purpose of change nonetheless it is still technically a change).

I will be documenting on how I went about designing such a DSL in later Blogs.  Hopefully it will give me a better understanding on how to manage change outside the IT sector and apply it to more generic changes…such as company decisions and risk analysis.

Keep an eye out…

Versioning DLLs in C#

Often I design and implement .NET projects never really worrying about their versions until sometime in the future someone comes back and says, "I have this problem, can you fix it", and then you end up thinking that you have provided a fix, just not sure which version the fix was in. Problems also arise when you are trying to find a threshold point of when an interface in a particular DLL changes so that other files using it are not supported.  Welcome to the age old problem of DLL versioning.  Mind you, at this point in time I am talking about singular DLL versioning and not versioning at a broader scale (product based).

I am not saying this is the best way or the only way, all I am saying is this is how I have addressed the problem in the past.

After surfing around and finding various versioning tools/articles like:
All the above versioning schemes are great although I chose to go with AssemblyInfoTask.  There are various (albeit more elegant ways) of using this simple tool but let us examine how I used it.

Step 1:
Well obviously download and install the tool from here.  The help file within the installer comes in very handy and it does explain how you can go about changing the version number according to whatever scheme you like.

Step 2:
Edit your project file to include the new versioning task in it.  This can be done by unloading your project in Visual Studio...

then you can right click on the unloaded project and go "Edit <ProjectName>".  This will open up your project as an XML file in the VS editor.  Most commonly your last Import statement will read the following:

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Add another line below it which tells your project to also invoke the AssemblyInfoTask targets, your project file will then look like:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<
Import Project="$(MSBuildExtensionsPath)\Microsoft\AssemblyInfoTask\Microsoft.VersionNumber.Targets" />
Save the XML file and reload your project now.

Step 3: 
Build the your project and you can see the DLL version skip every time you do a build according to the rules you defined in your AssemblyInfo target file.


Above you see that the file version is 1.0.327.0.  According to my target file I have set up the build number as the current date and the revision number simply increments every time I do a build.  I chose M-DD format as that allows me to go all year without changing my revision scheme.  But wait…this does create a problem when you cycle around a year end.  I thought of this and decided that if we do cycle around a year end I can simply change the minor versioning scheme.  This may not always be feasible depending on company regulations and also depends on your release cycle.  Well all I am saying is, use a scheme which works for you.  Depending on your project and it’s release cycle your versioning scheme will differ too.

Step 4: 
Great, so now you have a fully functioning versioning scheme.  Note that the above versioning propagates through to the DLL via the AssemblyInfo.cs file.

What happens if you use some sort of source control in which your files are locked?

A nice little error will be produced informing you that AssemblyInfo.cs file cannot be edited because it is read-only.  This happened for me as I was using Visual Source Safe, not sure exactly how other source control mechanisms react.  Anyways there is a simple solution: Simply check out AssemblyInfo.cs file.  

Checking out AssemblyInfo.cs

This will work well and good if you have only one project in your entire solution, although here are the problems you’ll come across:
  • What happens if there are 20 projects in your solution, will you be checking out each and every AssemblyInfo.cs file?

  • What happens if there are multiple developers working on different aspects of the solution, who decides when to check in such an AssemblyInfo.cs file?

  • A developer may do multiple builds every day, does that mean we are changing the revision every time?

Simply checking out the AssemblyInfo.cs file won’t work…what we need is some intelligent way of deciding when to kick off this AssemblyInfoTask target.  This is when conditional logic comes in handy.  Simply change your project XML file (we all know how to edit them now) to look like this:

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<
Import Project="$(MSBuildExtensionsPath)\Microsoft\AssemblyInfoTask\Microsoft.VersionNumber.Targets" Condition=" '$(Configuration)' == 'SpecialRelease' " />

All the above statement says is that we only want to invoke our AssemblyInfoTask target when our configuration is “SpecialRelease”.  What is SpecialRelease, it is an arbitrary string.  What is $(Configuration), it is the build configuration you use.  You may already know that every generic C# project comes with two configurations already added for you: Debug and Release.

image

We could have simply used release but I thought that as developers we may use “Release” for some special test cases which may not occur on a “Debug” build.  Anyways, so what we do now is add a new configuration called “SpecialRelease”.  Easily done by clicking on “Configuration Manager…” and the following window opens up:

image

There are two aspects to the above window: Solution Configurations and configurations for each project shown below.  Visual Studio comes in really handy in this case…we can add an entire new solution configuration and automatically propagate it down to every project within our solution.

  1. image  Click new

  2.  image Type in “SpecialRelease” and copy settings from “Release” (because we are only changing the version numbers on every release or whatever you want).  Make sure the check box which says “Create new project configurations” is checked.

  3. Voila! Your configuration manager will now look like:

    image

One more quirk!!!!!!

Doing the above will result in a build error:

image

This is because simply adding new configurations does not guarantee that we have done all the necessary steps to cater for this new configuration.  We edit our project XML again and add a block of XML (After the last PropertyGroup): 

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'SpecialRelease|AnyCPU' ">
<OutputPath>bin\ReleaseQA\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>

You’ll find that doing the above, setting your configuration as “SpecialRelease” and building your solution will still not work.  This is because $(Configuration) will be coming in as an empty string unfortunately.  I haven’t fully researched understood this issue but I did manage a workaround…use MSBuild.exe to build your solution.  Using MSBuild is really trivial, this is how you use it for the above mentioned “ClassLibrary1” solution:

MSbuild.exe “$(SolutionDir)\$(SolutionName)” /t:build /p:Configuration="SpecialRelease"

MSBuild.exe can be found in “C:\WINDOWS\Microsoft.NET\Framework\v3.5\”.  And also remember that there are different versions of MSBuild.exe depending on your .NET version so make sure you build your solution with the correct version of MSBuild.  More help on MSBuild here.

You can do this easily using automated build tools which allow you to checkout groups of files (AssemblyInfo.cs) and check them in afterwards.

Blogs to come

I am just about to get into blogging and every time I do so I find it hard to come up with a topic...I have decided that I am going to blog about random bits from work, sport and in general every day moments.  In the near future I am planning to blog about the following things:

  1. Reading a list of computers/users on a given domain
    Comes in really handy while remote desktoping into a computer only to find someone else is already using it.
  2. Guest lecturing at university
    I am about to give two lectures at uni about my recent thesis, that will be an interesting experience.
  3. WPF quirks and weirdness
    Will be compiling a list of those soon.

CS732 & SE450 Guest Lecture

I recently finished my ME at Auckland University and was privileged to be invited to give a couple of guest lectures to the current undergraduates.  It was a great opportunity and something definitely worth writing about.


I prepared a presentation outlining my research etc and used that as a teaching aid.  I was extremely nervous before giving the first lecture, it was a computer science honours class and I wasn't at all familiar with any of the students there but nervousness soon faded away and then it just felt like I was talking about my work to my peers.  I did feel like I rushed the presentation but I guess that happens naturally when you are slightly nervous.  Although one positive did come out of that, I had plenty of time to give a live demo of my tool which is always a good thing while talking.

The second lecture I was meant to give was on the next day but unfortunately I could not stick to that schedule as I was feeling a bit under the weather.  So we rescheduled and finally managed to give the lecture two days later.  This time it was a 4th year software engineering class.  Great class and the students were nothing like how "we" were back in university, they did actually listen...this time around the lecture seemed easier as I was familiar with the students and had tutored them the year before.  The lecture went well but unfortunately I could not give them a live demo of the tool as my laptop had no battery left :(.  Nonetheless the lecture finished early so I am sure the students must have been glad.

To sum things up...it was a great experience.  Giving a talk about something you spent a whole year on...designing and implementing is really easy.  Mind you this is me talking in hindsight...at the time I was shaking in my boots :)

Downloads: Presentation