On Interviews

Job Interviews are like double-edged swords. While it is an opportunity for the prospective employer to get to know you, what most people fail to do is getting to know your employer. Is that company a place you really want to work for? Will you be happy there or will it be an endless battle with management until someday you decide that you have had it and move to yet another Dilbertesque place, to work for yet another pointy-haired boss. Please, do yourself a favour and use the other side of the proverbial sword and take your cut. Ask pertinent questions that will influence your decision whether they are a good employer for you.


However, when its time to for you ask questions, most people can think of nothing too interesting to ask. I have interviewed a few candidates in the past, and I do not recall a single one of them asking a notable question that can influence their decision to work there or not.


So what do you ask? Have you heard of the Joel test? If you haven’t then take your 3 minutes and follow the link. Go on. In fact, Joel writes an excellent blog, go read it and don’t even come back here.


The problem with the Joel Test is that, as Joel himself points out, most companies run at 2-3. (ok, if you haven’t read the Joel Test, it is about a 12-point scoring system that tells you how good a company’s development team is). If you are going to use the Joel Test, and will be picky about companies scoring at least a 10 on the test, let me tell you my friend that you will be looking for a job for a long time, and most likely you will miss out working for some of the most fantastic companies out there. I don’t know about you, but I do not really care if a company doesn’t have a bug database, or they cannot make daily builds. These are things that the company should care about, not me (not yet anyway).



Instead, I prefer to use my “question time” at the interview and ask these 5 questions:

1. How do you measure your developers performance?

2. What level of support is required of your developers?

3. How much/often do your developers go on training / What/when was the last training they attended?

4. What tools do you give your developers to do their job?

5. What are the career advancement opportunities at your company for a Software Developer?



These are things I care about. Let me elaborate.


1. Performance Measurement

Most companies you work at will have some kind of Bonus / Revenue sharing scheme that is directly related to your performance at work. This is something that affects your bottom line, so before putting pen to paper and accept the contract, you will want to know how you are going to be measured. Often enough, this is not on the contract itself.

Imagine starting your employment at a company, and finding out later on that your performance will be measured by the number of lines of code you write, or the number of source control check-ins you commit. Or that your performance will be measured by the number of bugs the software contains (yes some managers do think they can create bug free software by stating it in the developer’s KPI), or by the accuracy of estimates on vague requirements. This is a crazy world, and people do crazy things. Are you prepared to have your KPI set on crazy benchmarks?

2. Support

Have you heard of that place where software implementations require the developer, dba, sys admins, application support, management, janitors and cleaners to be on site? This is what happens when “You will be required to do support work on an ad-hoc basis” is slapped on your work contract and you think nothing of it. Don’t get me wrong, I am not saying you need to shy away from support, but a functional organisation will have procedures in place so that developers do not get called on the weekend at 4am. These include a tough and thorough test cycle, a proper hand over to applications and system support, and training of helpdesk people to manage issues as they arise.

In order for this to happen, support cost for developers should be expensive. I have heard of phone handset companies where when the developer is to be “available”, it cost the company money – actual money in the bank, not funny “Time-in-Lieu” money. The rate is even higher if you indeed get called, consistent with penalty rates for weekend/out of hours support.

This provides a clear benefit to companies whereby it encourages them to properly release maintainable and supportable software. Often enough, documentation is what gets axed when a project overruns. Without proper documentation, proper support is impossible, and the developer will get called at the proverbial 4am when the disk is full and the application throws SQL Exceptions.

3. Training

When was the last time you got quality training from work? I’m not talking about gimmicky MS conferences  such as Heroes Happen. I’m talking about a real training session with real trainers. Is your new employer committed to the ongoing professional development of its team? Sure a lot of development and learning is on a per-needed basis: I need to do database access, let me read up on Linq2Sql. That is fine. But generally excellent developers will want to know more than just what they work on. The Microsoft Factory spits technologies at a dizzying rate: Linq2Sql, EF, WCF, WPF, WWF, WTF, etc. While you may not necessarily want intimate knowledge of the subject matter, excellent developers will at least want some ideas about it, and preferably see a seasoned developer use it a little bit to appreciate all its capabilities. Enter training sessions. Training with these real-world citizens with the likes of Juval Lowy, Dino Espositos, etc gives you that kind of exposure and an opportunity to pick the finest brains.

4. Tooling

What do you do when you have a performance problem in your application? Quite a few developers I have worked with attempt to guess where the bottleneck is, and start optimising. Did you know there are tools out there that will allow you to measure (profile) your application to your heart’s content – memory usage, execution times, etc. What are the odds of your company buying these tools should you request for it? How quickly can they purchase it? On numerous occasions I have worked with developers who will install trial software in order to fix real production issues.

Does your 15-year old niece have a faster computer than your work PC? Does it take forever to compile code? In my previous job, the latest computers were always given to the sales team because “they needed the application to run fast when they did a demo”. Opening the solution in Visual Studio took me 15 minutes every morning. Compiling? I used to make my cup of tea when code was compiling.

We are in 2010 now. Does your company allow you to install and run the beta version of Visual Studio 2010 on your machine or on a virtual machine? Or do you have to wait till 2011 “till the dust settles”? Bold companies out there have awesome software built and released to production with pre-release versions of various frameworks (go-live licence). Do you want to work in a company where the dust has settled and everyone else in the industry is working on the next big thing?

5. Career Advancements

What are the career prospects available to developers at the company you are interviewing? Are you expected that once you reach a certain level of proficiency, to take a role in Management in order to move to the next pay bracket? Joel Spolsky calls this “promoting someone to their level of incompetence” and I could not agree more with him when he says that the best programmers do not necessarily make the best managers.


Final thoughts

This is not, by any means, a complete list of questions of what you should ask at an interview. Go ahead, ask about flexible working hours and work life balance or anything else that is important to you. This list above isn’t a list of what you absolutely must ask your interviewer. Rather it is a list of things that over time I found to be pertinent to me – these are the things I care about. I would happily work for less money if I could get a fast pc, dual monitors, proper training and not getting woken up at 4am because the disk is full. I would be happy doing what I like doing best: programming. Are you happy to go to work everyday? Are you having fun? Are you motivated? Do you get to play with the latest technology? If you are, ignore everything I wrote here and do not change your job because you are lucky, my friend.

Posted in Programming

How to get data in chunks from a WCF Service

This is a simple solution on how to get data in chunks from a WCF service (e.g. a paged list of results)

Assuming that your service pulls data from a SQL Server database, you can use Linq2Sql and create your data context, OR if you are not using SQL Server, then the Microsoft Entity Framework may suit you.

Here is the code:

public IList <customers> GetCustomers(int pageIndex, int pageSize, out int total)
  using (var db = new NorthwindDataContext())
     var customers = db.Customers;
     total = customers.Count();
     var results = customers
      .Skip(pageIndex * pageSize)
     return results.ToList();
Posted in Programming

Discover and Invoke methods programmatically at runtime

I had a fairly simple problem recently (well, most problems are simple – solutions are not always so). I had an interface for a class that exposed about a dozen or so methods, and I needed to call them all, one at a time. The methods were parameterless and the return types were identical. Basically the methods was returning Generic dictionaries of Strings.


IStaticData staticData = StaticDataImporterFactory.GetStaticDataAdapter();
Dictionary <string, string> dic = staticData.GetSomeValues();

Rather than writing code line by line that would call each method in that interface, I reflected (pun intended) there must be a better(?) way of doing this, and came up with the idea to use Reflection to discover the methods in the interface programmatically and then call them. Here is the code:

IStaticData staticData = StaticDataImporterFactory.GetStaticDataAdapter();
Type type = typeof(IStaticData);
System.Reflection.MethodInfo[] methodInfos = type.GetMethods();
foreach (System.Reflection.MethodInfo methodInfo in methodInfos)
    Dictionary result = (Dictionary)methodInfo.Invoke(staticData, null);
    // do whatever work I have to do with the result
  catch (Exception ex)
    // handle the error
    txtError.Text += "Could not execute " + methodInfo.Name + Environment.NewLine;

The above code relies on the assumption that the methods to call are parameterless. If you wish to pass parameters to the methods, have a look at MethodInfo.GetParameters() to determine at runtime what the parameters are, and you can then pass them as additional arguments to the Invoke method (noticed I passed null above?)

And the deed is done.

Ash Moollan

Posted in Programming

Choosing a blogging software

I have tried various blog software in the past to run this blog.


I started using the now defunct .TEXT . In my opinion, .TEXT was excellent. It has a nice feature set and was more than good enough to run a personal blog. In addition, it had a 3rd party MS Access data adapter with everything requires to run it against it – it even had ms access versions of the stored procedures! Before we start shouting shenanigans, I know of all the evils that Access represents, but I still used it because it saved me an extra expense of MsSql hosting.



According to the makers of SubText,

Subtext is a personal blog publishing platform that focuses on usability, elegance, and simplicity. “

I gave it a test run on my local machine and it quite literally impressed me. The user interface was clean and easy to use, and offered just the features I needed to run my blog. It also exposed a great plug-in architecture which made it quite extensible.


Then I noticed something. Their website is powered by dotnetnuke!!! If they don’t think that SubText is good enough to run their own website, then why should I run mine on it? It’s a concept called dogfooding . Dogfooding is a pain, it is difficult and it tastes bad. But it shows me that if its good enough to run your own site on it, then i can consider running mine on it too. Community Server does it, Dotnetnuke does it and WordPress does it. Subtext doesn’t.



DotNetNuke is an extensible content management system. It is not a blogging platform per se. The appeal of dotnetnuke is that the average Joe can create and maintain their website without requiring a web professional to help them. There are convenient buttons and the text is editable in-place in a rich-text format ala Microsoft Word.

So why did I put dotnetnuke here as a blogging software? Because dotnetnuke is extensible, people have extended it to include a blog module. The blog module make dot net nuke behave as a blog engine and will run your blog sweetly on it.

I confess that I have used dotnetnuke in the past to run this website. I loved it. The user interface was friendly and it was very easy to add and edit posts and best of all, the post entries were fully SEO (Search Engine Optimised).

Having said all this, my design skills suck. I started, like most, with the basic default skin. Eventually I went on to create my own skin, and I can tell you – creating a skin in dotnetnuke is a Royal pain in the A**. Excuse the language.

Community Skins are rare. Most (of the few) persons who could make good skins for dotnetnuke try to make a profit by selling the skin (rightly or wrongly). And finally I gave up on my website looking good with dotnetnuke, and i tried Community Server.


Community Server

Community Server is used by MySpace and powers 70 million+ users. That is incredible. Community Server has more to it than Blogging – it has forums, photo gallery and file sharing as well. Community Server is created by the Author of .TEXT, Scott Watermasysk along with other guys from the nGallery and ASP.NET forums.

I gave Community Server a shot for a little while, and while sporting quite an impressive feature set, it was not suitable for a 1-person site running nothing more than a blog. While it does work for that scenario, it is just an overkill. The default skins were better than the dotnetnuke skins by yards and miles, but it had that “generic” feel to it. And so I dumped it.



And here I am running this blog on WordPress. There is a buzz around wordpress. Lots of people use it, and what more so, lots of people like it. It’s clean, simple to use and has a powerful plugin framework (yes i know, they are the rage) .

Speaking of plugins, WordPress has an addin called Askimet that is very very good at sorting out spam comments without needing a captcha! (you know those images that you need to type in a box?)

The skins are customisable and there are tons and tons of free wordpress themes all over the internet . Heck the one I am using at the moment is one of them (thanks wpthemespot)

The only caveat so far about WordPress is the amount of database calls it makes to load each page. Why should you care? Let me tell you. If a blog does not have that many visitors, then that is fine. but the more visitors a blog has, the more database calls it makes, and the slower the website responds. And with the database calls, the server also uses more CPU to render your website, which does not help to make it run faster.

Having said this, the WordPress community has quickly caught on and developed plugins that will cache your pages and serve from the page where possible – and this drastically improve performance. Pity that this isn’t an out-of-the-box feature.


Closing Comments

Interresting (but totally useless) piece of information. All blogging software mentioned except for WordPress are built in .NET (and thus requires a windows hosting environment). What IS interresting is that they all use a database as a back-end and sql server (that is what the windows based applications generally use as a database server) hosting tend to be a lot more pricey than their non-windows counterpart.

WordPress on the other hand is built on php and uses MySql as the backend. Both are cheap as dirt to host.

And the question I get asked more often by my friends is “why the hell did you use a php blog software when you are clearly such a .NET guy!”. Heck I AM a professional .NET developer after all. Why I chose a php solution? Simple. The implementation of the blog software is the least of my concern. As a user, what I do care about is a hassle free, clean and easy to use software. WordPress gives me that.

All of the blogging software discussed here are free software that you host on your own domain. I have not discussed hosted blog software such as blogspot etc, althouth wordpress does offer free hosting for you.


Now that I have confused you with all these, my work is done.

Thank you.

Ash Moollan.

Posted in Programming

Community Server

I currently run my website on DotNetNuke as a content management server. I am considering changing to Community Server instead. I will give that a spin over the next few days at home, and if I am happy enough I will change this site to run on Community Server.

Typically I am considering Community Server because of its cool photo gallery (yes i know DNN has one too, but the community server is, IMHO, sexier). I also plan to add extra stuff on my website soon that would otherwise be a pain to do with DNN. Having said that, i need to experiment with Community Server first to see if it fit my needs.

The downside of all that is that, inevitable, all my links will change. I will aim to keep the RSS feed link unchanged (http://www.moollan.net/rss.aspx). If you are not using this one, then please update your bookmark since it is the only one that I support.

Posted in Programming

How to Serialize an Object to XML and then Deserialize back to its Object

I often get asked questions about serializing a class to XML and then deserializing it back to its original object.

There are numerous reasons why you would do this, but more commonly I found that it is the preferred way to persist objects in a database.

I’ve put together these two methods that will take any object and serialize it to XML and vice versa. I have added the option to set the encoding type as a parameter to the method instead of going by the default Unicode encoding. Although Unicode encoding is the preferred way to serialise when persisting to a SQL server database (talking about the XML data-type that will only accept UTF-16), this method can be put to other uses as well. I have opted to fully qualify my namespaces in this example so that you can copy-paste it without having to worry about imports.

Say you have a class called person defined as such which you want to serialize:


   1: public class Person 
   2: {
   3:   String name;
   4:   public String Name 
   5:   {
   6:     get { return name; }
   7:     set { name = value; } 
   8:   }
  10:   String surname;
  11:   public String Surname 
  12:   {
  13:     get { return surname; }
  14:     set { surname = value; } 
  15:   }
  17:   DateTime dateOfBirth;
  18:   public DateTime DateOfBirth 
  19:   {
  20:     get { return dateOfBirth; }
  21:     set { dateOfBirth = value; }
  22:    }
  23: }


You can call then serialize/deserialize as such:
   1: Person p = new Person();
   2: p.DateOfBirth = DateTime.Now;
   3: p.Name = "Ash";
   4: p.Surname = "Moollan";
   5: String xmlPerson = SerializeToXml<person>(p, Encoding.UTF8);
   6: Person personFromXML = DeSerializeFromXml<person>(xmlPerson, Encoding.UTF8);

And the actual implementation of the serializer and deserializer:


   1: using System.Xml.Serialization;
   2:   public String SerializeToXml(T o, Encoding encoding)
   3:   {
   4:       XmlSerializer serializer = new XmlSerializer(typeof(T));
   5:       using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
   6:       {
   7:           using (System.Xml.XmlTextWriter xmlWriter = new System.Xml.XmlTextWriter(ms, encoding))
   8:           {
   9:               XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();
  10:               namespaces.Add(String.Empty, String.Empty);
  11:               serializer.Serialize(xmlWriter, o, namespaces);
  12:               return encoding.GetString(((System.IO.MemoryStream)xmlWriter.BaseStream).ToArray());
  13:           }
  14:       }
  15:   }
  16:   public static T DeSerializeFromXml(String xmlString, Encoding encoding)
  17:   {
  18:       Byte[] aBytes = new Byte[encoding.GetByteCount(xmlString)];
  19:       aBytes = encoding.GetBytes(xmlString);
  20:       System.IO.MemoryStream ms = new System.IO.MemoryStream(aBytes);
  21:       XmlSerializer xs = new XmlSerializer(typeof(T));
  22:       return (T)xs.Deserialize(ms);
  23:   }

Hope it is useful to someone. Do bear in mind that only the public properties will be serialized. There are also extra serialization attributes that you can add to the class to shape the way it gets serialized.

Ash Moollan

This post applies to
.NET 2.0
Visual Studio

Posted in Programming

Hello GI-Jane Grandma!!!

The Australian Tech-Ed 2006 this year is hosted in Sydney. I’ll make sure I attend the session How to get your grandmother building Missile Defence Systems, it sounds like a lot of fun 😉

Posted in Programming

Forcing a Page_Load on BACK button in .NET

There’s a little tip on how to force a page_load when the user press the back button on the browser.

In your page_load section, add this line of code:


By disabling ASP.NET Caching on a page, we can force a Page_Load on BACK button. There are a few reasons why you would want this kind of behaviour.

1. Populating a page with data from database/session variables
2. More importantly, going back to a page that previously posted back to itself.

Point 2 is noteworthy. It avoids the unpleasantness of having a “page has expired” when pressing back. This is because when a page posts back to itself, it does a form submit. Navigating back to such a page forces the submit again, with an IE prompt. By storing the page values temporarily (e.g. in, say, a collection pushed in a session variable) we can then check for the existence of that session variable and then reload these values on the page on the back button. In doing so, we nicely avoid the page is expired issue. All it takes is a little extra effort, but the user experience is greatly ameliorated.

In my case I had a page that was creating a temporary XML file that I use to create SVG Pie Charts and I clean (read delete) the XML file when the page finished loading. This causes problems when the user navigates back to the page and it can’t find the XML file to draw the Pie.

Any which way, Response.Cache.SetCacheability(HttpCacheability.NoCache) is a useful code snippet to have in your ASP.NET repertoire.

Ash Moollan

This post applies to
.NET 1.0, 1.1, 2.0
Visual Studio
Back Button .NET

Posted in Programming

Hmmmm Something!!!

It’s a bit of a disappointment that “Something” hasn’t been added to the Visual Basic Language. I have been dreaming of a day when I can use

Dim Blah as New Person
If IsSomething(Blah) Then
   ' Do Stuff with Bla
   MessageBox.Show(”Blah has not been initialised”)
End If

Well, until that day comes, I refuse to use

If Not IsNothing(Blah) Then …

and instead I have created a global public function

Public Function IsSomething(ByVal Expression As Object) As Boolean
 If Expression Is Nothing Then 
   Return False
 ElseIf TypeOf (Expression) Is String AndAlso CType(Expression, String) = "" Then
   Return False
 ElseIf TypeOf (Expression) Is DBNull Then
   Return False
   Return True
 End If
End Function 

So that I can still use the IsSomething method until it becomes part of .NET.

I enjoy things like testing datarow items with this method, which will test if the item is either DBNULL or an empty sting.

If IsSomething(ds.tables(0).rows(0).item(2)) Then
End If

Ash Moollan www.moollan.net

This post applies to
.NET 1.0, 1.1
.NET 2.0
Visual Studio 2005
Is Nothing


Method Discovery

Posted in Programming

Coding by IntelliSense and the issue with Class and Method discovery

Discoverability is a tough nut to crack. When we are writing code, very often we need to create static (shared) methods, and the naming convention of static methods is an important part in helping the discoverability of the method.

Do you prefix with Get, Create, Add? The question you tend to ask yourself is "Get or Find?"

MyClass.GetName("Ash Moollan")
MyClass.FindName("Ash Moollan")

Which one of these to implement/call? Often we rely heavily on Intellisense.

Dim str as string
str. (dot)

And this is where IntelliSense usually kicks in and provides a list of static (shared) methods. In VS 2005, IntelliSense is taken off shared members for instance variables. This highly hinders discoverability.

Recently when I was doing a code review for migration to VS 2005 and I stumbled upon a pretty fancy piece of code that sorts the contents of an array. Apart from bad naming conventions, the only way I knew what it was doing is the little comment that the author luckily put of top of the code snippet. I didn’t check if the code was efficient, or that whether it actually worked. My first reaction was to delete the code and replace it with


If course if the author was using visual studio to write the code to begin with, doing myArray. (dot) would have brought up IntelliSense and (at least in 2002/2003) found out there is a Sort static method for arrays. (Sidestepping the issue of accessing shared members from instances), it sure does not help when one is using Notepad to write open source asp.net pages.

Scott Allen seems to think highly of discoverability in the .NET class library and generally he is right (excluding the System.DirectoryServices namespace of course)

Discovery is a new ball game in VS 2005. As I mentioned above, shared members are taken off instances, and VB9 warns you when you are attempting thus.

Dim myArr() as string = {"Ash", "Moollan" }
myArr.Sort(myArr) ‘ // what is this???

It works, but that does not make it right. VS2005 stops you from doing that but takes down discovery with it. Not many will actually try


(Ok, maybe not with arrays because Array.Sort is a common method, but with other more obscure namespaces, I’m not too sure anymore.)

There does not seem to be a setting where you can turn that off so that the shared members are then shown in IntelliSense. Fair enough to blow the whistle when trying to use them (compile time warning), but I am against hiding of the shared variable in general.

This is what I call "Coding by IntelliSense ". Quite often I’m faced coding with a library for which the documentation is not available. I’m down to typing down the class name and a dot and look at the list in IntelliSense and ask the famous "I wonder what this method does" and then try it out and see for myself.

At the cruelest sense, I am coding in the dark, not having a clue about what I am doing. It is pure guesswork, but let’s face it – we do not always get a documentation with a library for various reasons – the author does not want to make it available, the documentation is old, and the list can go on. Coding by IntelliSense then becomes the only "real" way of determining what a method does.

I am an IntelliSense coder. Microsoft I ask you this: Give me my IntelliSense back!

BTW, I love the IntelliSense suggestions by Roland

Ash Moollan www.moollan.net

This post applies to
.NET 1.0, 1.1
.NET 2.0
Visual Studio 2005
Class Discovery
Method Discovery

Posted in Programming