Monday, 3 May 2010

Moving this blog

I am slowly moving all my blogs, etc. and hosting them on my domains. Mainly because it gives me more control and to some extent I find BlogSpot a bit constricting.

This blog has now moved to codeface.tebco.com

A list of technologies I think I need to learn

I am struggling under the load of new and updated technologies that I want to learn. For work I need to understand, Administer and be able to develop using .NET, C#, LINQ, Java 1.4, Visual Basic 6, InstallShield (MSI & InstallScript), Nant, Ant, CVS, SVN, Gemini, Team City and the rest.

However I also want to become proficient in areas I have not spent a lot of time working namely .NET Web Development. To this end I have decided I need to learn the following as part of a couple of private projects I am undertaking.
  • Visal Studio 2010
  • C# 4
  • .NET 4.0
  • ASP.NET MVC 2.0
  • Enterprise Library 5.0
  • LINQ
  • Entity Framework
  • NUnit
  • Moq
Wish me luck...

Wednesday, 28 April 2010

Learning something new every day

I learned something new today, I learned that stealing someone elses idea is far less satisfying than I had hoped.


What Mark Learned Today

Wednesday, 1 July 2009

Boxing and Unboxing Variables

When using variables in C# you need to be aware of and careful with boxing and unboxing. For example the following code;

int discount = 20;
object discPerc = discount;
discount = 15;

intdiscPercent = (int)discPerc;

In this instance the value of discount is 15 but the value of the implicitly converted discPerc and the explicitly cast discPercent are still 20.

This is because when converting from a value type to a reference type a copy of the value is taken not a reference to the value.

Given that the move from the Value type to the Reference type was implicit you could wind up with an ugly little bug.

Tuesday, 9 June 2009

Generic Classes

You can declare a class with a generic type so that you can later instantiate it specifying the type at that point.

public abstract class genericListClass<t>
{
protected virtual add(T value)
{
...
}
}

You can then instantiate a GenericListClass for different type as follows;

genericListClass<int> integerList = new genericListClass<int>()
genericListClass<long> LongList = new genericListClass<long>()
genericListClass<string> stringList = new genericListClass<string>()

You can also accept different generic types as parameters to methods in a generic class

public abstract class genericClass<t>
{
protected virtual CheckBoxOption[] WrapCheckBoxOptions<u>(string id, IEnumerable<checkboxoption> options)
{
...
}
}

The use of the <u> is to ensure it is taken as different from the type reperesented by <t>. <u> is a new different type.
In addition to this you can constrain the type of the class to a specific interface or behaviour;

public abstract class genericListClass<t>
{
protected virtual CheckBoxOption[] WrapCheckBoxOptions<u>(string id, IEnumerable<checkboxoption> options) where U : new()
{
}
}

This allows you to constrain the type <U> to a specific type or more usefully, Interface. You can also use it, as in this case,

where U : new()

to constrain the type to one that can be instantiated with a default constructor. In other words it does not require parameters to be passed to the constructor. So

U newInstance = new U();

will not raise an error.

Monday, 4 May 2009

Extension Methods

By using the this keyword you can add to (extend) any class, even sealed classes. So

public static string ToTitleCase(this string value)
{
...
}

allows you to do the following;

string state = "south west australia";
Console.WriteLine(state.ToTitleCase());

You can extend even interfaces so if you create;

public static IEnumerable WhereEven(this IEnumerable values)
{
...
}

You will find the WhereEven method is available on List, Collection, int[ ] and anything else that implements IEnumerable.

Monday, 27 April 2009

Java now...

I had another project added to my list, now I need to try and get my head around an authoring system in Java, Perl and JavaScript using the Tomcat server. I may have even less time to try and keep this thing up to date...

I'll still tag this as Learn but will try to use appropriate tags for the subject (Java, etc.)