Thoughts on Source Control

I get a few questions that come up repeatedly as a developer and this is one of them; Why should I use source control?; Which should I use?

I used to be in that position at the beginning of my career, now? There’s no way I’d go back to this:

Here’s the scenario I think a lot of companies out there are working with:

  • One (or more) server(s) containing
    • Files
    • MS Exchange
    • Intranet
    • Customer accounts
    • Other business specific data
  • Several PC/Laptops connected to the server

In these companies I think people work by copying files from your server, modifying files on their own PC, then saving them back into the respective clients’ folders. This may work for the first few clients because you can’t keep track of the latest version of your product/sotware but when it comes to upgrade to your latest and greatest version…uh oh. Migration is a pain.

Problems I imagine they may still encounter:

  • Bugs reappearing
  • Not knowing which version of code is the right one or latest
  • Two people can’t work on the same project very easily
  • You shout across the office to say “is anyone using xxx”

Not all source control systems fix all of these issues but many will make your life easier.

Read this to explain why you need source control!

I have some experience with the following and will try to explain my thoughts

  • Microsoft Visual Source Safe
    • An old souce control solution now and much hated by many who have had any experience with any other system!
    • Avoid
    • Developer must check in a file before another can access it. If the first developer leaves without checking files in, you had better get their password!
    • Not free
  • Microsoft Team Foundation Server
    • This is a powerful enterprise tool at enterprise prices
    • Good integration with Visual Studio (which I imagine you don’t use)
    • Integration with a build server (more info on request)
    • Supports branching and merging
    • Very not free
  • Subversion
    • Centralised Source Control – there is a master copy of all code. You have to check in to the master code repository
    • You can work offline locally but you can’t check anything in
    • Windows integration with http://tortoisesvn.tigris.org/
    • Free with support option
  • Git
    • Distributed Source Control – each copy of the source control is its own repository and you can work on code, checking in changes, without having a connection to the server
    • Command line but has tools available for windows shell integration (TortoiseGit)
    • Free
  • Mercurial

I’m interested in more but I see the above reappearing most often, in my work at least

I think this is a good illustration of source control with Subversion (borrowed from http://hginit.com/top/00.html):

This is a really good article discussing what source control provider to use based on your needs:
http://stackoverflow.com/questions/111031/comparison-between-centralized-and-distributed-version-control-systems

A quote from the above Stackoverflow question regarding Subversion (SVN) vs Git:

… say you are a solo developer working on your own personal project. A centralized repository [SVN] might be an obvious choice but consider this scenario. You are away from network access (on a plane, at a park, etc) and want to work on your project. You have your local copy so you can do work fine but you really want to commit because you have finished one feature and want to move on to another, or you found a bug to fix or whatever. The point is that with a centralized repo you end up either mashing all the changes together and committing them in a non-logical changeset or you manually split them out later.

Another quote from http://hginit.com/top/ regarding distributed (Git/Mercurial) source control:

.. you can have a QA repository that lets the QA team try out the code. If it works, the QA team can push it up to the central repository, meaning, the central repository always has solid, tested code. And it works!

That means you can run experiments in separate repositories, and if they work, you can merge them into the main repository, and if they don’t work, you can abandon them, and it works!

What would I do?

From my current experience I’d choose either Git or Mercurial. Making merging a simpler task sounds like win-win from my point of view.

More on Distributed Version Control:
http://www.infoq.com/articles/dvcs-guide

The Git vs Mercurial Debate:
http://importantshock.wordpress.com/2008/08/07/git-vs-mercurial/

Learning Mercurial (and an introduction to source control):
http://hginit.com/top/

Other random tools I use that you may find useful

Twitter – http://www.twitter.com – not for celebs, for geeks! I only follow people who talk about the technology stuff I’m interested in. Try to find a twitter list of geeks

Balsamiq – http://www.balsamiq.com/ – Awesome prototyping tool. I think prototyping could be another post on its own.

Here’s the scenario I think a lot of companies out there are working with:

· One (or more) server(s) containing

o Files

o MS Exchange

o Intranet

o Customer accounts

o Other business specific data

· Several PC/Laptops connected to the server

These people may work by copying files from your server, modifying files on their own PC, then saving them back into the respective clients’ folders. This may work for the first few clients because you can keep track of the latest version of your product/sotware but when it comes to upgrade to your latest and greatest version…uh oh. Migration is a pain.

Problems I imagine they may encounter:

· Bugs reappearing

· Not knowing which version of code is the right one or latest

· Two people can’t work on the same project very easily

· You shout across the office to say “is anyone using xxx”

Not all source control systems fix all of these issues but many will make your life easier.

Read this to explain why you need source control!

I have some experience with the following and will try to explain my thoughts

· Microsoft Visual Source Safe

o An old souce control solution now and much hated by many who have had any experience with any other system!

o Avoid

o Developer must check in a file before another can access it. If the first developer leaves without checking files in, you had better get their password!

o Not free

· Microsoft Team Foundation Server

o This is a powerful enterprise tool at enterprise prices

o Good integration with Visual Studio (which I imagine you don’t use)

o Integration with a build server (more info on request)

o Supports branching and merging

o Very not free

· Subversion

o Centralised Source Control – there is a master copy of all code. You have to check in to the master code repository

o You can work offline locally but you can’t check anything in

o Windows integration with http://tortoisesvn.tigris.org/

o Free with support option

· Git

o Distributed Source Control – each copy of the source control is its own repository and you can work on code, checking in changes, without having a connection to the server

o Command line but has tools available for windows shell integration (TortoiseGit)

o Free

· Mercurial

o I have no experience with

o Command line much like Git but also has tools available (http://tortoisehg.bitbucket.org/)

I’m interested in more but I see the above reappearing most often in my work at least

I think this is a good illustration of source control with Subversion (borrowed from http://hginit.com/top/00.html):

Figure <!–[if supportFields]> SEQ Figure \* ARABIC <![endif]–>1<!–[if supportFields]><![endif]–> http://hginit.com/top/00.html

http://code.google.com/p/tortoisegit/wiki/HOWTO_CentralServerWindowsXP

A really good article discussing what source control provider to use based on your needs:
http://stackoverflow.com/questions/111031/comparison-between-centralized-and-distributed-version-control-systems

A quote from the above Stackoverflow question regarding Subversion (SVN) vs Git:

… say you are a solo developer working on your own personal project. A centralized repository [SVN] might be an obvious choice but consider this scenario. You are away from network access (on a plane, at a park, etc) and want to work on your project. You have your local copy so you can do work fine but you really want to commit because you have finished one feature and want to move on to another, or you found a bug to fix or whatever. The point is that with a centralized repo you end up either mashing all the changes together and committing them in a non-logical changeset or you manually split them out later.

Another quote from http://hginit.com/top/ regarding distributed (Git/Mercurial) source control:

.. you can have a QA repository that lets the QA team try out the code. If it works, the QA team can push it up to the central repository, meaning, the central repository always has solid, tested code. And it works!

That means you can run experiments in separate repositories, and if they work, you can merge them into the main repository, and if they don’t work, you can abandon them, and it works!

What would I do?

From my recent web research I’d choose either Git or Mercurial. Making merging a simpler task sounds like win-win from my point of view.

More on Distributed Version Control:
http://www.infoq.com/articles/dvcs-guide

The Git vs Mercurial Debate:
http://importantshock.wordpress.com/2008/08/07/git-vs-mercurial/

Learning Mercurial (and an introduction to source control:
http://hginit.com/top/

Other random tools I use that you may find useful

Twitter – http://www.twitter.com – not for celebs, for geeks! I only follow people who talk about the technology stuff I’m interested in. Try to find a twitter list of geeks

Balsamiq – http://www.balsamiq.com/ – Awesome prototyping tool. I think prototyping could be another post on its own.

Using the Ribbon Control in MS Office 2007/2010 with C#

One of our clients has a complex Excel 2007 spreadsheet they need to do some automation with. The current solution involves lots of manual steps to create charts in a PowerPoint presentation. To this end I started researching how to add items to the ribbon bar so they could automate tasks with Macros.

However, when I started looking into it more deeply I discovered you could easily create plugins using Visual Studio and manipulate spreadsheets and most of the Office 2007/2010 suite using the Office.Interop DLL.

These are the helpful resources I used to get some development underway:

I did have some trouble with Windows 7 UAC because everytime you build your application, it reinstalls the plugin. There are some helpful posts about fixing this.

Next thing for me to learn and post about is doing something useful in C# to change the Excel Data…

Learning ASP.NET MVC

I’ve found there is A LOT of information on the net about learning the MVC framework. I thought it might be helpful for others to read about my experiences while I’m learning.

So, my starting point: http://asp.net/MVC Scott Hanselman has a really fun and interesting presentation regarding a OSS website he’s developed called Nerddinner.com

I’ve had some experience with TDD and ASP.NET webforms from a previous project I was working on and we were using a Model-View-Presenter pattern which as far as I can see is pretty much the same as MVC.

The View – This is a dumb portal to communicate information to the user

The Controller – This communicates information to the view and translates it to and from the Model. It is generally unit tested and could communicate with the view via a View Model.

The Model – Contains business logic, stores and retrieves data in a database and is really the concrete information regarding your software project. This is also the data that you may need to mock to check your controller handles user input correctly.

More buzz words I needed to look up/I feel are never explained particularly well:

  • View Engine – A method of displaying information to the user. See wikipedia for a better description
  • Routing policy – Rather than using Viewstate, URLs can tell the controller what to display
  • Dependency Injection – DI allows you to inject objects into a class, instead of relying on the class to create the object itself. (Microsoft)
  • IOC
    • “Inversion of Control – IOC specifies that if an object requires another object, the first objects should get the second object from an outside source such as a configuration file. This makes testing easier.” (Microsoft)
    • Car requires seats. Car should get seats from factory (not the driver/user).
  • URLRoutingModule – Guesses the page you are trying to reach. No match means it falls back to the default IIS settings. In MVC a URL does not equal a page. Browser requests are mapped to controller actions.
  • MvcHandler – Selects the controller that will handle the request
  • JSON – JavaScript Object Notation

The Controllers Execute method, invokes an action method associated with the controller, which in turn, receives user input, prepares a response and returns the requested type. The built in result types are:

  • ViewResult (which renders a view and is the most-often used result type),
  • RedirectToRouteResult,
  • RedirectResult,
  • ContentResult,
  • JsonResult, and
  • EmptyResult

ASP.NET Routing

An ASP.NET Web Forms application is content-centric. An ASP.NET MVC application, in contrast, is application logic centric. It uses a route table to work out which controller to use and associated input data. What I’m not sure about yet is how to save data back to the Model through the view.

Using JSON – Another post for that I think!

Using Meta Data – data that describes data!

References

Microsoft. (n.d.). MVC Overview. Retrieved from http://asp.net: http://www.asp.net/learn/mvc/tutorial-01-cs.aspx

Why WordPress?

I had several (thousands) of options when choosing a blog engine. I chose WordPress for a few reasons:

  • I’ve not used it before and wanted to learn something new
  • It’s easy to export to another blog engine easily should I want to change
  • Although I have hosting elsewhere, this was free and easy

So far I’ve been impressed. It has a mobile version built in that looks good on my phone and most functions are easy and work well.

I couldn’t find a way to use Google analytics with the hosted solution. If I downloaded it and installed on my own server then there are lots more options. Perhaps a task for another day!

Hello world!

Surely every blog starts with this! Why should mine be different?

I’m planning on writing a few posts on various technologies. You can get the theme of this blog from the About page.