Someone once wrote: Build IT and they shall come.

We came, we saw, and we rejoiced. For it was Developer Developer Developer Sydney. And it was awesome!

One of the largest free developer turnouts that I have had the privilege to attend. Rumors on the day were that over 150 .NET developers over Sydney and Brisbane (and possibly other areas) converged on the Microsoft headquarters for free coffee and a lot of nerd talk.


Scott Hanselman speaking at DDDSydney. (Photo courtesy of rbanks)

Windows Phone 7

There are probably a lot of rumors that are going around about how Microsoft will be marketing the new windows phone 7. What I can tell most definitely is that the new phone is NOT a normal windows phone. Microsoft have woken up and smelled their own manure when it came to PDA’s and phones and decided to do it differently, and by differently I mean taking the best parts of apples iPhone and Googles Android and making a hybrid clone.

Read the rest of this entry »

Here’s a helper that will allow you to compare 2 objects using reflection.

Note: that this will also go through the objects base class and compare the base class fields and properties. I found it necessary to do this, however for speed you may want to add BindingFlags.DeclaredOnly to type.GetProperties() and type.GetFields() to limit the depth of the comparison.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
public static class Helper<t>
{
	public static bool Compare(T x, T y)
	{
		var type = typeof(T);
		var properties = type.GetProperties();
		var fields = type.GetFields();			
 
		foreach (var p in properties)
		{
			var valueOfX = p.GetValue(x, null) as IComparable;
			if (valueOfX == null)
				continue;
			var valueOfY = p.GetValue(y, null);
			if (valueOfX .CompareTo(valueOfY) != 0)
				return false;
		}
 
		foreach (var f in fields)
		{
			var valueOfX = f.GetValue(x) as IComparable;
			if (valueOfX == null)
				continue;
			var valueOfY = f.GetValue(y);
			if (valueOfX.CompareTo(valueOfY) != 0)
				return false;
		}
 
		return true;
	}
}
</t>

Read the rest of this entry »

Every now and again it’s necessary to resolve a dependency at runtime. When this happens you don’t really have much of a choice but to insert mock objects into your test fixtures IoC container. The following patterns allow me to specify 1 abstract base class and have all dependent unit tests inherit these stubs thus satisfying their dependencies.

An example class that uses a service locator pattern. Note: This will also work for constructor based dependency injection as well.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public class CustomerLeaseTerm
{
    public virtual Lease Lease { get; set; }
    public virtual Invoice Invoice { get; set; }
    public virtual long AdditionalDataTransfer  { get; set; }
 
    // Lazy Load the Additional Data Transfer Broker using the Service Locator Pattern
    private IAdditionalDataTransferBroker _additionalDataTransferBroker = null;
    public virtual IAdditionalDataTransferBroker AdditionalDataTransferBroker
    {
        get { 
            return _additionalDataTransferBroker 
                ?? (_additionalDataTransferBroker = IoC.Resolve<iadditionaldatatransferbroker>()); 
         }
    }
 
    // Return a calculated cost at runtime using the Additional Data Transfer Broker
    public virtual decimal AdditionalDataTransferCost { 
      get 
      {
          return AdditionalDataTransferBroker
                   .GetByUnitsInGigabytes(AdditionalDataTransfer)
                   .EffectiveCost;
      }
    }  
 
   (...)
 
}
</iadditionaldatatransferbroker>

Read the rest of this entry »

If you don’t have an automated build and deploy script to deploy your latest web application to IIS7 you may have problems.

Here is a solution that uses Cygwin and SSH that can allow you to build your application once and deploy to as many windows servers as you’d like.

What you’ll need

Installing Cygwin on your Windows Server

Download Cygwin and and install the following packages:

  • wget
  • openssh
  • openssl
  • zip
  • unzip

Read the rest of this entry »

Compiling and installing the latest release of Mono (version 2.4 at time of writing) on Ubuntu is not as hard as it sounds, these instructions should also work on newer versions of Mono.

IMPORTANT: If you’re installing on a VPS, make sure that you have at least 128 MB of RAM available, or otherwise the mono compilation process will fail.

WARNING

Following these instructions will result in all your pre-installed Mono applications being removed from your Ubuntu box. In most cases the only way to get them back is going to be by installing them from source too (not always a bad idea).

Installing Mono

Open a terminal window if you’re using the Ubuntu GUI or log on using SSH if you’re accessing a remote server.

All these instructions assume that you have root privileges, so if you’re not logged in as root, enter the following and enter you password when prompted.

$ sudo bash

First you need to remove the version of Mono that is pre-installed with Ubuntu.

$ apt-get remove mono-common

That will remove all the extra packages that are installed with mono as they all depend on it. Be aware that it will also remove applications like f-spot and beagle, which will have to be re-installed after the mono upgrade if you wish to use them.

Read the rest of this entry »

Here is a bash script to automatically download, compile and install Mono on Ubuntu. It installs Mono 2.4.2.3. Should this be outdated, you can simply modify the install script to download the latest files.

A word of warning: This script will remove any previous installations of Mono done via apt-get. This means that existing Mono applications may cease to function or be removed entirely.

Before we begin, make sure you’re running with root privileges:

Read the rest of this entry »

About Justin

justin

Justin is a Senior Software Engineer living in Brisbane. A Polyglot Developer proficient in multiple programming languages including [C#, C/C++, Java, Android, Ruby..]. He's currently taking an active interest in Teaching Kids to Code, Functional Programming, Robotics, 3D Printers, RC Quad-Copters and Augmented Reality.

About This Blog

Software Engineering is an art form, a tricky art form that takes as much raw talent as it does technical know how. I'll be posting articles on professional tips and tricks, dos and donts, and tutorials.

profile for Justin Shield on Stack Exchange, a network of free, community-driven Q&A sites

Photostream

  • What I look for in a senior software engineer Justin Shield: […] I’m not going to list the design patterns that you’ll need, I’ve already [...]
  • Justin: Hi Ross, I do actually like Umbraco, it provides some nice abilities for creating websites that I [...]
  • Justin: Hi GordonBGood, Thanks for taking the time in replying. You're absolutely correct, it is turners s [...]
  • Ross Gallagher: Hi Justin, I'm a fellow Aussi looking to use Umbraco to create a simple website. I have downloaded [...]
  • GordonBGood: This is the "Turner Sieve" which **IS NOT** the Sieve of Eratosthenes (SoE) neither by algorithm nor [...]