Monday, June 30, 2008

RequiresElevation property

RequiresElevation property

Recently upgraded a 'vdproj' installation from 2005 to 2008 and encountered new 'RequiresElevation' property.

"MsiBootstrapper"
{
"LangId" = "3:1033"
"RequiresElevation" = "11:FALSE"
}

Sunday, June 29, 2008

C Sharp Interview Questions: Keywords

C Sharp Interview Questions: Keywords

1. List several C# keywords.

abstract
as
base
bool
break
byte
case
catch
char
checked
class
const
continue
decimal
default
delegate,
do,
double
else
enum
event
explicit
extern
false
finally
fixed
float
for
foreach
goto
if
implicit
in
int
interface
internal
is
lock
long
namespace
new
null
object
operator
out
override
params
private
protected
public
readonly
ref
return
sbyte
sealed
short
sizeof
stackalloc
static
string
struct
switch
this
throw
true
try
typeof
uint
ulong
unchecked
unsafe
ushort
using
virtual
volatile
void
while

2. List Several C# Contextual Keywords

from
get
group
into
join
let
orderby
partial (as a type)
partial (as a method)
select
set
value
var
where (generic type constraint)
where (query clause)
yield

3. List several C# Value Type keywords.


bool
byte
char
decimal,
enum
int
long
sbyte
short
struct
uint
ulong
ushort

(note string is a built in reference type, your call on grading it)


4. List several C# Reference Type keywords.


class,
delegate,
interface

(object and string are built in reference types)



5. List several C# Access Modifier keywords.

internal
private
protected
public


6. List several C# Modifier keywords (class modifiers, method modifiers...)

abstract
const
event
extern
override
readonly
sealed
static
unsafe
virtual
volatile



7. List several C# keywords involving iteration statements.

do
for
foreach
in
while


8. List several C# keywords involving selection statements.

if
else
switch


9. List several C# keywords involving jump statements.

break
continue
goto
return

10. List several C# keywords involving Exception Handling statements.

throw
try
catch
finally


11. List several C# keywords involving method parameters.

params
ref
out


12. List several C# keywords involving namespaces.

namespace
using


13. List several C# keywords involving operator.

as
checked
is
new
sizeof
typeof
true
false
stackalloc
unchecked


14. List several C# keywords involving conversion operators.

explicit
implicit
operator



15. List several C# keywords involving access (class access).

base
this


16. List several C# default keywords.

true
false
null

Saturday, June 28, 2008

Other than RDBMS.

"A database is a structured collection of records or data." Wikipedia.

That is how the Wikipedia article for Database starts and it is a good beginning. The article then proceeds to talk primarily about Relational Databases. Which is not surprising since Relational Databases and Relational Database Management Systems are the dominant solution to many of the problems encountered when trying to maintain and use a collection of data.

These are problems are non trivial to say the least and often have conflicting requirements for their solution which results in the RDBMS feeling heavy and bloated.

So it is not surprising there are quite a few special purpose databases (again a database is a collection of data) to handle unique needs and these databases are not RDBMS. There are also some practices routinely engaged in by developers when they do not want the heavy weight of an RDBMS on their development.

Here is a non exhaustive list:

1) configuration files
These files help an application answer some questions:
In what context do I run?
How do I find the resources I need? Like the RDBMS I use.

It should be noted their a couple of common implementation of configuration databases. Their is the Registry and there are INI or config xml files.

2) log files
As soon as an application is running in productions it will encounter difficulties and there are some common questions that need to be answered:
What happened recently?
What is note worthy?
In what order did things happen?

Even if things are okay you will always want some source for diagnostic information.

Two dominant databases in this area are text files that are simply appended to and the Event Log.

3) documents and xml
Often the data needs to be transported, in fact a lot of the terminology in the early days of the web talked of documents and transporting documents. XML due to it's internal structure and syntax is becoming the dominant solution for transferring data. In fact the config files mentioned earlier are XML because they solve the problem of how to get the initial start up data installed.

3)Directory Services (Active Directory)
Separate from configuration that is unique to a program there is information that is global in nature:
Where are things located? People, printers, computers.
What is allowed? Who can view what? Who can change what.
Given these require security and security is itself a global concern it is natural to locate all the security in the Active Directory as well.

4) programs
You might make the case that programs are nothing more than documents and you would be correct. Which makes them a database as well. However they are enough of them and they have some unique concerns. At their core, programs are nothing more than ordered lists of instructions. But to provide anything useful there must be a means of interacting with flow of the program. Either people interact with the program or other machines or programs interact with the program.

5) file systems
Again back to the original definition any collection of data is a database. A file system is a collection of information on how to find files and details like creation date, ownership and so forth.

6) traditional RDBMS
This is a not a complete list of databases other than RMDBS so I will close with RDBMS but only to point out a couple things about them.

RDBMS seek to answer a question authoritatively:
What happened to the data across all of time and space?

This is a hard thing to do and immediately issues arose involving performance and reliability. Reliability forced the notion of transactions which can be summarized in a odd way as "until it happens, it did not happen".

Friday, June 27, 2008

Regular Expressions: Special Characters And Escape Sequences

Regular Expressions: Special Characters And Escape Sequences

Special Characters

"^" Beginning of text
"$" End of text
"." Any single character but (\n) the newline
"*" Previous expression 0 or more times
"+" Preceding character 1 or more times
"?" Preceding character 0 or 1 times
"" Alteration used in Groups
"(" Used in Groups
")" Used in Groups
"[" Used in Ranges
"]" Used in Ranges
"-" Used in Groups and Ranges
"{" Used in Quantifiers
"}" Used in Quantifiers


Escape Sequences

"\b" Word boundary
"\B" Any non Word boundary

"\d" Any digit
"\D" Any non digit

"\s" Any whitespace character; space, tab, newline
"\S" Any character that is not whitespace

Thursday, June 26, 2008

Last Day of Current Month

Some C# code to determine the last day of the current month.

//One liner
DateTime lastday = DateTime.Today.AddMonths(1).AddDays(-DateTime.Today.Day);

// Extra line to make it more readable
DateTime today = DateTime.Today;
DateTime lastday = today.AddMonths(1).AddDays(-today.Day);

Wednesday, June 25, 2008

Index of Indexes

Index of C#
c#

Index of labels
labels

Index of Visual Studio
Visual Studio

Tuesday, June 24, 2008

Regex Characters Digits and Underscores

Regex to validate a string is composed of only characters, numbers and underscores.

==comments==

Brackets mean match any one of:
"[abcde]" means match any one of a,b,c,d,e.

Dash between characters is a short hand for include all characters between.
"[a-z]" any lowercase letter
"[A-Z]" any uppercase letter
"[0-9]" any digit

Plus sign after a bracket means match one or more
"[a-zA-Z_0-9]+" will match any substring composed of only letter, digits or the underscore, the substring must have at least one

Dollar Sign matches the beginning of a string and Hat '^' matches the end of a string.
"$[a-zA-Z_0-9]+^" will match any substring composed of only letter, digits or the underscore, the substring must have at least one. Also there can be no characters before or after the matching substring.

==code==

public bool ValidateIdentifier(string identifier)
{
Regex re = new Regex("^[a-zA-Z_0-9]+$");
MatchCollection match = re.Matches(identifier);
if (match.Count != 1)
{
//_LastException = new Exception("Identifier must have only characters, digits and underscores");
return false;
}

return true;
}

Monday, June 23, 2008

Index Of Software Development Practices

Index Of Software Development Practices Resources

Posts of interest:

Labels of interest:

Actors

Agarwal Corollary

Agarwal's Law

AP Calculus

ASPNET account

backupfile

backupset

Bright Shiny Object

Bug Focus

Build

C#

Calculus

Code Pattern

Cognitive Load

Compact Net Framework

Coroutine

Daisy Chain Bug

Desktop Virtualization

DEV

Dot Net Framework

Dot Net Singularity

DotNet Singularity

Enterprise Agreement

enum

Even More Law

EventHandler

Exception

Exception Handling

Feature Focus

FileSystemWatcher

Firefox

Five Nines

Full Package Retail

Generator

GPS

helpctr.exe

hex literal

Hyper VTM

IEnumerable

IIS

Index

installer

INT

integer literal

Intellisense

Internet Explorer

Interviewing

Join

Linux

Micro Dot Net Framework

Microsoft Application Virtualization

Microsoft Team System

Microsoft Virtual PC

Mono

Moonlight

Moore's Law

msdb

msinfo.exe

msinfo.htm

MsTest

MultiBrain

MultiCore

multiplatform

MultiThread

Net Framework

NETWORK SERVICE

NUnit

Open Business

Open Value

Open Value Subscription

Parse

Permutation

Poisoned Candy

Prod

Production

QA

Refactor

Regex

Regression Bug

Requirements

Select License Agreement

Separation of Concerns

Serial Port

Server Virtualization

ServiceController

ServiceProcess

Silverlight

Snippets

Software Development

Software Development Practices

Source Control

Sprint

Sprint Aircard

SQL Server

Subroutine

System

System Info

System.Exception

Team Server

Team System Build

TfsBuild

Thread

ThreadStart

Three Nines

TryParse

UAT

uint

Unix

Use Case

User Acceptance Testing

VB.net

Version Control

Virtualization

Visual Studio

VJ#

Web Service

Win32

Win64

Windows Server

Windows Terminal Services

Windows XP

yield

Sunday, June 22, 2008

Index Of C#

Index Of C# Resources

Posts of interest:

Labels of interest:

Actors

Agarwal Corollary

Agarwal's Law

AP Calculus

ASPNET account

backupfile

backupset

Bright Shiny Object

Bug Focus

Build

C#

Calculus

Code Pattern

Cognitive Load

Compact Net Framework

Coroutine

Daisy Chain Bug

Desktop Virtualization

DEV

Dot Net Framework

Dot Net Singularity

DotNet Singularity

Enterprise Agreement

enum

Even More Law

EventHandler

Exception

Exception Handling

Feature Focus

FileSystemWatcher

Firefox

Five Nines

Full Package Retail

Generator

GPS

helpctr.exe

hex literal

Hyper VTM

IEnumerable

IIS

Index

installer

INT

integer literal

Intellisense

Internet Explorer

Interviewing

Join

Linux

Micro Dot Net Framework

Microsoft Application Virtualization

Microsoft Team System

Microsoft Virtual PC

Mono

Moonlight

Moore's Law

msdb

msinfo.exe

msinfo.htm

MsTest

MultiBrain

MultiCore

multiplatform

MultiThread

Net Framework

NETWORK SERVICE

NUnit

Open Business

Open Value

Open Value Subscription

Parse

Permutation

Poisoned Candy

Prod

Production

QA

Refactor

Regex

Regression Bug

Requirements

Select License Agreement

Separation of Concerns

Serial Port

Server Virtualization

ServiceController

ServiceProcess

Silverlight

Snippets

Software Development

Software Development Practices

Source Control

Sprint

Sprint Aircard

SQL Server

Subroutine

System

System Info

System.Exception

Team Server

Team System Build

TfsBuild

Thread

ThreadStart

Three Nines

TryParse

UAT

uint

Unix

Use Case

User Acceptance Testing

VB.net

Version Control

Virtualization

Visual Studio

VJ#

Web Service

Win32

Win64

Windows Server

Windows Terminal Services

Windows XP

yield

Saturday, June 21, 2008

Index Of Visual Studio

Index Of Visual Studio Resources

Posts of interest:

Labels of interest:

Actors

Agarwal Corollary

Agarwal's Law

AP Calculus

ASPNET account

backupfile

backupset

Bright Shiny Object

Bug Focus

Build

C#

Calculus

Code Pattern

Cognitive Load

Compact Net Framework

Coroutine

Daisy Chain Bug

Desktop Virtualization

DEV

Dot Net Framework

Dot Net Singularity

DotNet Singularity

Enterprise Agreement

enum

Even More Law

EventHandler

Exception

Exception Handling

Feature Focus

FileSystemWatcher

Firefox

Five Nines

Full Package Retail

Generator

GPS

helpctr.exe

hex literal

Hyper VTM

IEnumerable

IIS

Index

installer

INT

integer literal

Intellisense

Internet Explorer

Interviewing

Join

Linux

Micro Dot Net Framework

Microsoft Application Virtualization

Microsoft Team System

Microsoft Virtual PC

Mono

Moonlight

Moore's Law

msdb

msinfo.exe

msinfo.htm

MsTest

MultiBrain

MultiCore

multiplatform

MultiThread

Net Framework

NETWORK SERVICE

NUnit

Open Business

Open Value

Open Value Subscription

Parse

Permutation

Poisoned Candy

Prod

Production

QA

Refactor

Regex

Regression Bug

Requirements

Select License Agreement

Separation of Concerns

Serial Port

Server Virtualization

ServiceController

ServiceProcess

Silverlight

Snippets

Software Development

Software Development Practices

Source Control

Sprint

Sprint Aircard

SQL Server

Subroutine

System

System Info

System.Exception

Team Server

Team System Build

TfsBuild

Thread

ThreadStart

Three Nines

TryParse

UAT

uint

Unix

Use Case

User Acceptance Testing

VB.net

Version Control

Virtualization

Visual Studio

VJ#

Web Service

Win32

Win64

Windows Server

Windows Terminal Services

Windows XP

yield

Friday, June 20, 2008

Index Of Labels

Index Of Labels

Actors

Agarwal Corollary

Agarwal's Law

AP Calculus

ASPNET account

backupfile

backupset

Bright Shiny Object

Bug Focus

Build

C#

Calculus

Code Pattern

Cognitive Load

Compact Net Framework

Coroutine

Daisy Chain Bug

Desktop Virtualization

DEV

Dot Net Framework

Dot Net Singularity

DotNet Singularity

Enterprise Agreement

enum

Even More Law

EventHandler

Exception

Exception Handling

Feature Focus

FileSystemWatcher

Firefox

Five Nines

Full Package Retail

Generator

GPS

helpctr.exe

hex literal

Hyper VTM

IEnumerable

IIS

Index

installer

INT

integer literal

Intellisense

Internet Explorer

Interviewing

Join

Linux

Micro Dot Net Framework

Microsoft Application Virtualization

Microsoft Team System

Microsoft Virtual PC

Mono

Moonlight

Moore's Law

msdb

msinfo.exe

msinfo.htm

MsTest

MultiBrain

MultiCore

multiplatform

MultiThread

Net Framework

NETWORK SERVICE

NUnit

Open Business

Open Value

Open Value Subscription

Parse

Permutation

Poisoned Candy

Prod

Production

QA

Refactor

Regex

Regression Bug

Requirements

Select License Agreement

Separation of Concerns

Serial Port

Server Virtualization

ServiceController

ServiceProcess

Silverlight

Snippets

Software Development

Software Development Practices

Source Control

Sprint

Sprint Aircard

SQL Server

Subroutine

System

System Info

System.Exception

Team Server

Team System Build

TfsBuild

Thread

ThreadStart

Three Nines

TryParse

UAT

uint

Unix

Use Case

User Acceptance Testing

VB.net

Version Control

Virtualization

Visual Studio

VJ#

Web Service

Win32

Win64

Windows Server

Windows Terminal Services

Windows XP

yield

Thursday, June 19, 2008

Dot Net Singularity Approaches

Quote, man made intelligence is 30 years away, by just about anyone in the last 300 years.


So having taken my poke at the Singularity that is near (and always will be), I would like to propose that the Dot Net Singularity (DotNet Singularity) is near. And it will change everything.

The Dot Net Singularity will occur when the Dot Net Framework is free of the Win32 API (and Win64).

I can envision two responses. Oh that's already here and it has not changed anything. Or that will never come you have to have an OS and the API talks to the OS.

On the already here front, I agree there are manifestations near the Singularity. Silverlight ships a stripped down version of the framework. The Mono project is an open source port of Dot Net. Mono can be run on Mac OS X, Solaris, Linux, BSD and even on some Windows operating systems. There is a special versions of the framework, the Compact Framework that is useful in embedded applications; the Micro Framework for even more constrained apps. And in the case of Moonlight you have a Silverlight on Linux courtesy of the existence of Mono.

Moonlight illuminates an interesting feature of the Dot Net Singularity. Is it a cause of the Singularity or a result of the Singularity? Well both, and it is also a rebuttal to the 'won't change anything' argument.

Now in response to the "you always need an OS and thus you will always need an API like Win32 or Win64", I can just point to the above. The Compact and Micro versions as well as the Silverlight version are doing two things at the same time. On the one hand they put pressure to free the framework from the OS. At the same time, the apply pressure to retain as much of the features of the framework as possible at the least resource cost. Nice pair of evolutionary pressures.

So when will the Dot Net Singularity occur? I am guessing 2020.

Wednesday, June 18, 2008

Forcing The Compile Order Of Projects In Visual Studio

For managed code projects, setting project references causes Visual Studio to do the right thing in terms of building dependencies and linking them in the right order. It does the job so well I do not care how it goes about it.

But in the case of Unmanaged Code you will occasionally want to move the outputs around so they can be found by other projects.

To do this right click on the solution in the Solution Explorer, select Properties from the menu.

In the property pages dialog, under Common Properties, select Project Dependencies.

Here you will be able to select a project, then select which projects it Depends on.

Note if the checkbox for a project is grayed out it means a dependency already exists going the other way.

Tuesday, June 17, 2008

Bright Shiny Objects

Bright Shiny Objects abound.

If you attempt software development for any length of time you will encounter Bright Shiny Objects. They come in multiple forms. They could be the latest features your competitor has in their products. They could be the latest language, which uses the latest language feature, which will save us from the latest looming Y2K disaster. Or it is a new platform which will make everything self managing. The list is endless.

If they have one thing in common it is newness. All things new tend to have bright shiny exteriors. Part of the draw is simple curiosity. But for developers of any moderate experience there is a deeper pull.

As I pointed out in “The golden first year" you get paid for your experience. Thus you get paid in your next job for what you did in your current job. If you lived thru the tech bubble you saw this first hand as html developers were paid more than client server whizzes.

Technical people are excellent problem solvers, so it does not take them long to realize this dynamic and solve it by loading their current project up with all the current hot Bright Shiny Objects.( Your website may have no real use for AJAX but you have it now.)

The danger is Bright Shiny Objects tend to be loaded with Poisoned Candy. Poisoned Candy are those features or tricks that make the Bright Shiny Objects work in limited circumstances like development or in a beta situation but fail horrendously in production.

Unless you are eternally vigilant, you will find your project overrun by Bright Shiny Objects and their problems. If a developer wants to use a Bright Shiny Object, you are going to find it nearly impossible to stop them. Keep in mind, that even if you control their employment, they perceive that the market will reward them with a better job in the short term if they can master this technology.

So what can you do?

Insist on Small Doses and Results. Ask the developer to do the smallest thing possible with the Bright Shiny Object, and give it a short deadline; a day or something less than a week. If it is more than a week it runs the risk of evolving into a project of its own. As soon as something is displayed insist on running it through the entire process all the way up to the edge of deploying it to production. This will reveal all the poison in the candy.

Occasionally there is no poison and you have found a better way. Congrats and beware. The more likely case is a mixture of good and bad. Here you will have to insist that the defects be remedied by making the developer address them. By sharing this pain with the developer they will start to gain an understanding for the dark side of Bright Shiny Objects.

Monday, June 16, 2008

Poisoned Candy and Bright Shiny Objects

Heard a great line on Dot Net Rocks.

The guest compared the connection objects in Visual Studio to Poisoned Candy.
They work great in development. That is the candy part.

But when he went to deploy his SQL Server project they did not exist, hence the poisoned part.

This sort of problem is a classic 'you do not know what you do not know'.
What will save you here is testing combined with frequent releases.

How does this relate to Bright Shiny Objects? It has been my experience that Bright Shiny Objects have a lot of Poisoned Candy in them.

Sunday, June 15, 2008

-0X80000000 is not -2147483648

Got an obscure one today.

The code that follows illustrates the problem but is not the code where the problem was
found.

We were expecting that the hex integer literal 0X80000000 would correspond to the integer value of (-1)(2^31) since this is a legal value. We tried this several ways (2) (3) (4) and they all resulted in an error. This is because the code which parses hex integer literals does not recognize the 0X80000000 as valid int value as such it then tries to create it as uint. If you remove comment (1) you will see these (2) works.

What is a little disturbing is (5) the decimal integer literal for (-1)(2^31) is a valid value.

===Code Follows===
enum Range //(1)// : uint
{
flag1 = 0X1,
flag2 = -0X2,
flag3 = 0X4,
flag4 = 0X8,
flag5 = 0X10,
flag6 = 0X20,
flag7 = 0X40,
flag8 = 0X80,

flag9 = 0X100,
flag10 = 0X200,
flag11 = 0X400,
flag12 = 0X800,
flag13 = 0X1000,
flag14 = 0X2000,
flag15 = 0X4000,
flag16 = 0X8000,

flag17 = 0X10000,
flag18 = 0X20000,
flag19 = 0X40000,
flag20 = 0X80000,
flag21 = 0X100000,
flag22 = 0X200000,
flag23 = 0X400000,
flag24 = 0X800000,

flag25 = 0X1000000,
flag26 = 0X2000000,
flag27 = 0X4000000,
flag28 = 0X8000000,
flag29 = 0X10000000,
flag30 = 0X20000000,
flag31 = 0X40000000,
//2// flag32 = 0X80000000 // Cannot implicitly convert 'uint' to 'int'
//3// flag32 = -0X80000000 // Cannot implicitly convert 'uint' to 'int'
//4// flag32 = 0X80000000u // Cannot implicitly convert 'uint' to 'int'
//5// flag32 = -2147483648 // Works
}

Saturday, June 14, 2008

Easy To Do Right, Hard To Do Wrong

Easy To Do Right, Hard To Do Wrong

Part of the reason that technology workers are compared to cats (managing developers is like herding cats) is a misunderstanding of how their work is structured.

Quite often rewards are given for doing the wrong thing and the right thing is punished.
Praise is given for pushing a release out before it is ready.
Even more praise is heaped upon them for fixing the bugs in the early release.
Yet more praise is layered on top for tracking down and fixing all the data corrupted by all the bugs that were in the early release.
And on and on.

As a manager of technology workers the goal is to put in structure so the easiest thing to do is the right thing. And it is at the same time hard to do the wrong thing.

Take the one two three combo of 'Source Control is Authoritative' and 'Daily Build' and 'Automated Builds'
By insisting that the only code that matters is the code in Source Control, you make it hard for developers to create local branches that are far out of date with the main branch.

The 'Daily Build' reinforces checking in often and verifying that all local dependencies are fixed.
The 'Automated Builds' make it easy to verify that the checkin have not broken the code.

Friday, June 13, 2008

Stacking Exceptions

The System.Exception object has an interesting member "InnerException".

Which solves the age old delimma "I caught an exception, now what do I do with it?"

By adding context to where the exception was caught you can assist the troubleshooting that will occur in production. This is because the "ToString" method will faithfully walk down the list of all the exceptions and report their contents as the following code shows.

====Code Starts=======

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplicationNestedException
{
class Program
{
static void Main(string[] args)
{
Exception exception = OuterException();
Console.WriteLine(exception.ToString());
Console.ReadLine();
}

static public Exception OuterException()
{
Exception twoDeep = new Exception("Two Levels Deep");
Exception innerException = new Exception("Inner Exception",twoDeep);
return new Exception("Outer Exception",innerException);
}
}
}

===End Code, Output Follows====

System.Exception: Outer Exception --->
System.Exception: Inner Exception --->
System.Exception: Two Levels Deep
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---

Thursday, June 12, 2008

Interviewing For Big Project Experience

In Interviewing For Artifacts :

I introduced the idea of assessing for candidates by looking like an archaeologist for the artifacts of experience. Skill in a language will tend to create a familiarity with all the keywords of the language for example.

When assessing candidates for big project experience a similar approach can be used with a slight adjustment. You need to define what is motivating the desire for big project experience. No doubt the current project or the project you are about to start will be a big project. What are the difficulties you have experienced or expect to experience?

Process is a typical candidate. Usually with large projects you need heavier processes to both keep the project on track to the intended goal and to assure the project is making progress.

Sometimes the complexity of the code is the issue. You know the project will be compose of multiple assemblies, libraries or components.

Another common source is the need to leverage a large preexisting code base.

There are others, for them follow the pattern I will describe for the previous three.

Start off by asking the interview to describe the biggest project they have done. You are hoping for a brief synopsis or overview so that you can ask followup questions.

If the candidate responds with a project that is small then you are done. He has no big project experience.

On the other hand if the candidate describes a big project, you will then need to followup to see if they gained the experience you are looking to find. The first followup question is also simple; What challenges did you encounter?

If you are lucky they will describe the problems you encountered. If not you will then need to ask a leading followup question. One of :

What sort of processes were used, how did they affect the way you worked?
How many assemblies were there, what were their purposes, how did they interact?
Did you have to use a preexisting code base or framework?

What you are looking for is that the candidate encountered the problems you expect them to handle and that they learned from the experience. Now as a friend of mine pointed out, usually what he learned is he never wanted to do that again. I have had candidate express this feeling during interviews.

It is a mixed bag. On the one hand it is clear evidence of experience on the other hand, especially in the case of process, it may indicate they will not be happy in your environment. You should recap at the end of the interview that the job involves this particular challenge.

Wednesday, June 11, 2008

Fixing the: System.InvalidOperationException: Unable to generate a temporary class : Error

More testing on our new Application Server and I encountered the error

System.InvalidOperationException: Unable to generate a temporary class(result=1). error CS2001: Source file ...

Unfortunately Microsoft offers this advice:
"To avoid this problem, give read/write priviledges for the Temp folder to the ASPNET account"

While technically correct, this treating the symtom instead of the root cause.
Chances are if the ASPNET account does not have one permission it needs, then there are other permission missing. These accounts and permissions are usually missing because IIS is installed after the Dot Net Framework.

When the Framework is installed after IIS, it detects the existence of IIS and configures the appropriate accounts.

To do this manually you need to run the following command:
aspnet_regiis.exe -i

This registers aspnet with IIS. The side effect is all the appropriate account are created.

Tuesday, June 10, 2008

Fixing the: The current identity (NT AUTHORITY\NETWORK SERVICE) does not have write access to error

Doing some testing of our website on a new server.

Encountered the following error when testing a web service:

"The current identity (NT AUTHORITY\NETWORK SERVICE) does not have write access to "

The fix for this is pretty simple run the following command:
aspnet_regiis -ga "NT AUTHORITY\NETWORK SERVICE"

If this command is not recognized at the command line you will need to find aspnet_regiis, for the 2.0 Framework it is usually in the following path:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

Monday, June 9, 2008

Interviewing for Artifacts

A broken pot tells an archaeologist a story. It illuminates the civilization that once was and now has only its remnants to speak for it.

Interviewing IT candidates serves a similar purpose. In an interview we are looking for artifacts of experience. We ask about one keyword after another. We ask about one Code Pattern and then another. How the candidate responds is important. Zero level experience candidates tend to deflect and divert. They will mention Google. They will talk about how they are a great learner. Their expression of enthusiasm will grow ever higher.

After just a little bit of non response joined with expression of enthusiasm from a candidate it is interesting to see the spilt response from a panel interview. The panel was a mixture of technical and business types. The more business oriented the more positive the response, the more technical the individual, the more negative the evaluation.

Business types value that enthusiasm, and for their problems Google always seems to have the answer.

Technical types know that lacking the basics skills in the language is bad news. Only after one has the basic language skills down, does the formation of Code Patterns or Coding Idioms take shape.

Sunday, June 8, 2008

Five Nines

Five Nines of Uptime.

So as we sit thru multiple hours of downtime a discussion of uptime batted around.
Five Nines of Uptime would be 99.999%.
The nines before the decimal are counted.

In the case of Two Nines we should be down only 3.65 days out of 365 days for the year.
Five Nines would be an outage of 5.26 minutes.
So being down for an hour means we are at best Three Nines.

Saturday, June 7, 2008

Passing Parameters to Threads in C#

A followup question that was asked on the "Waiting on a thread" post was how to pass parameters in the ThreadStart method.

This misunderstands what the Threadstart needs. It need the location of the function to pass control to when the thread is started. But you could create an object and use it to identify a method as the following code illustrates.

===Code Follows===

using System;
using System.Threading;
namespace ConsoleApplicationThread
{
public class ThreadClass
{
private int _Count = 0;
public ThreadClass(int count)
{
_Count = count;
}
public void ThreadMethod()
{
for (int i = 0; i < _Count; i++)
{
Console.WriteLine("ThreadClass.ThreadMethod {1}: {0}", i, Thread.CurrentThread.ManagedThreadId);
Thread.Sleep(100);
}
}
}
public class MultiThreadStart
{
public static void Main()
{
Console.WriteLine("Main thread: Create multiple threads");
ThreadClass threadClass1 = new ThreadClass(10);
Thread thread1 = new Thread(new ThreadStart(threadClass1.ThreadMethod));
ThreadClass threadClass2 = new ThreadClass(20);
Thread thread2 = new Thread(new ThreadStart(threadClass2.ThreadMethod));
ThreadClass threadClass3 = new ThreadClass(30);
Thread thread3 = new Thread(new ThreadStart(threadClass3.ThreadMethod));
ThreadClass threadClass4 = new ThreadClass(40);
Thread thread4 = new Thread(new ThreadStart(threadClass4.ThreadMethod));
Console.WriteLine("Main thread: Start threads");
thread1.Start();
thread2.Start();
thread3.Start();
thread4.Start();
Console.WriteLine("Main: Call Join() on each thread to wait for thread to end.");
thread1.Join();
thread2.Join();
thread3.Join();
thread4.Join();
Console.WriteLine("Main: All threads have ended");
Console.ReadLine();
}
}
}

Friday, June 6, 2008

Just Waiting On Thread

The Join method of a thread is what you use to wait for a thread to finish

===Code Starts===
using System;
using System.Threading;
namespace ConsoleApplicationThread
{
public class MultiThreadStart
{
public static void ThreadMethod()
{
for (int i = 0; i < class="blsp-spelling-error" id="SPELLING_ERROR_4">WriteLine("ThreadMethod {1}: {0}", i,Thread.CurrentThread.ManagedThreadId);
Thread.Sleep(100);
}
}
public static void Main()
{
Console.WriteLine("Main thread: Create multiple threads");
Thread thread1 = new Thread(new ThreadStart(ThreadMethod));
Thread thread2 = new Thread(new ThreadStart(ThreadMethod));
Thread thread3 = new Thread(new ThreadStart(ThreadMethod));
Thread thread4 = new Thread(new ThreadStart(ThreadMethod));

Console.WriteLine("Main thread: Start threads");
thread1.Start();
thread2.Start();
thread3.Start();
thread4.Start();
Console.WriteLine("Main: Call Join() on each thread to wait for thread to end.");
thread1.Join();
thread2.Join();
thread3.Join();
thread4.Join();
Console.WriteLine("Main: All threads have ended");
Console.ReadLine();
}
}
}

Thursday, June 5, 2008

Event Handlers Are On Separate Threads

You know you are an engineer if you spend an hour arguing over something that can be tested in five minutes.

Below is some code from the Microsoft site that illustrates how to handle FileSystemWatcher events.

I added a few more write lines to report out the thread ids. This clearly shows the event handlers are occurring on separate threads. As an aside, this reinforces the 'bring on the cores' attitude to multicores, since applications tend to be multithreaded even the most simple of applications.


===Code Start===

public static void Main()
{
Watch();
}
public static void Watch()
{
string[] args = System.Environment.GetCommandLineArgs();
// If a directory is not specified, exit program.
if (args.Length != 2)
{
// Display the proper way to call the program.
Console.WriteLine("Usage: FileWatch.exe (directory)");
return;
}
// Create a new FileSystemWatcher and set its properties.
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = args[1];
/* Watch for changes in LastAccess and LastWrite times, and
the renaming of files or directories. */
watcher.NotifyFilter = NotifyFilters.LastAccess NotifyFilters.LastWrite
NotifyFilters.FileName NotifyFilters.DirectoryName;
// Only watch text files.
watcher.Filter = "*.txt";
// Add event handlers.
watcher.Changed += new FileSystemEventHandler(OnChanged);
watcher.Created += new FileSystemEventHandler(OnCreated);
watcher.Deleted += new FileSystemEventHandler(OnDeleted);
watcher.Renamed += new RenamedEventHandler(OnRenamed);
// Begin watching.
watcher.EnableRaisingEvents = true;
//
Console.WriteLine("main thread: " + System.Threading.Thread.CurrentThread.GetHashCode());
// Wait for the user to quit the program.
Console.WriteLine("Press \'q\' to quit the sample.");
while (Console.Read() != 'q') ;
}
// Define the event handlers.
private static void OnChanged(object source, FileSystemEventArgs e)
{
Console.WriteLine("OnChanged thread: " + System.Threading.Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);
}
private static void OnCreated(object source, FileSystemEventArgs e)
{
Console.WriteLine("OnCreated thread: " + System.Threading.Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);
}
private static void OnDeleted(object source, FileSystemEventArgs e)
{
Console.WriteLine("OnDeleted thread: " + System.Threading.Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);
}
private static void OnRenamed(object source, RenamedEventArgs e)
{
Console.WriteLine("OnRenamed thread: " + System.Threading.Thread.CurrentThread.ManagedThreadId);
// Specify what is done when a file is renamed.
Console.WriteLine("File: {0} renamed to {1}", e.OldFullPath, e.FullPath);
}
}

Wednesday, June 4, 2008

Parse TryParse Code Pattern

In c# the int data type has two functions for parsing strings that represent integers; Parse and TryParse.

Parse can throw an exception to indicate failure and TryParse returns a bool to indicate success or failure.

This represents a useful Code Pattern that frameworks can employ to address the needs of those who use them. On the one hand throwing an exception is the traditional way that frameworks indicate something went wrong. It leaves it up to the calling entity to catch and handle the exceptions. The weakness here is that the catching and handling structure can be overwhelming. Not to mention the overhead involved.

The TryParse on the other hand allows the calling entity to branch on success or failure without exception overhead. It also allows for several quick successive checks of parsing to find the best fit.

Neither is superior, it is simply a case of what is needed. So in creating frameworks it is best to provide both.

Tuesday, June 3, 2008

MsTest and NUnit; Using Both

If you can use MsTest; you should. The integration benefits will pay dividends over and over.

But if it is not available across your company, you need not settle for the least common denominator of NUnit. And you may want to develop with MSTest but deploy with NUnit to keep the footprint light.

Fortunately there is an almost one to one mapping between the namespaces of the two.

So using the following conditional code at the top of your test class file, will enable you to alternate which testing harness you use.

==============
Code Start

==============
#if MSTEST
using Microsoft.VisualStudio.TestTools.UnitTesting;
#else
using NUnit.Framework;
using TestClass = NUnit.Framework.TestFixtureAttribute;
using TestMethod = NUnit.Framework.TestAttribute;
using TestInitialize = NUnit.Framework.SetUpAttribute;
using TestCleanup = NUnit.Framework.TearDownAttribute;
using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute;
using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute;
#endif
==Code End==
Some things like Categories have no direct equivalent so you will need to conditionally compile their attributes:
==Code Start==
[TestClass ]
#if MSTEST
//Intentionally empty
#else
[Category("Web Service")]
#endif
public class QA_Feature_2_1
==CodeEnd==
And another gotcha occurs around the test and suite set up and tear down functions:
==Code Start==
[ClassInitialize()]
#if MSTEST
public static void MyClassInitialize(TestContext testContext)
#else
public void MyClassInitialize()
#endif

=========================

Monday, June 2, 2008

Art of Software Development

The short answer is their is none.


Software development is a science. It should be treated as such. So it is always perplexing when software developers are referred to as artists or the software development process as black art.

Go ahead and Google the words and you will be overwhelmed.

Read a good sample of the articles and you will not an underlying surrendering to the developers by quite a few.

This does not need to be the case. Other complex fields are successfully managed and applying some of the principles found software development is also manageable. To take three under used principles Accountability, Responsibility and Transparency would be a good start. Applying the three starts software development down a road of Repeatable and Testable actions. This in turn makes software development into a Science.

Sunday, June 1, 2008

How to not do QA.

I write so much about QA you would never know that my primary focus is software development.

There was not one event that formed this unshakable belief in QA. (Just to refresh..Good QA can save you from bad developers but good developers can never make up for no QA.)
But I can recall several first hand experiences that drove home this painfully gained experience.

And looking back, they all have a common theme of:
"How can we do this without QA?"

Here are three approaches that were tried and where I directly felt the pain:
1. Have the customers test it.
2. Have the engineers test their own code.
3. Have the engineers test each others.

The first one, of having the customers test it, was at the insistence of a bright individual who insisted that there was no time. We had to get it to the market now. This was at the same time that we were trying to get a round of formal testing added to the project plan. I did not have a lot of experience at the time and neither did many of my colleagues but we instinctively knew this was a really bad idea. Another bone of contention was getting a cycle to fix anything found in testing together with another round of testing.

What was offered was; we will do a limited beta and fix all the complaints that our users told us about. An obvious difficulty we had with this proposal was that we could not get to our customers machines to see what was wrong or experiment with fixing them.

The compromise was we would have everyone in the company install the product. That is we would use ourselves as 'internal customers' first. Then we would quickly do an external release.
This failed miserably. Not surprising since this was an untested product that was developed against one environment that was deployed through out a company with numerous differences between the machines.The only upside was the failure was so grand that we did not move on to victimize the external customers.

The second and third options of having the engineers test, either their own or each others ended poorly. I was with a company that after a round of layoffs that included nearly all of the QA group, announced that the software developers needed to test their own code. This way we could keep all the products alive for less cost.

At this point you should step back and wonder, if this is a successful practice, why haven't we done it from the start?

Of course this failed miserably. The first release without QA was the second worst one ever. Features were colliding with each other and numerous bugs were added. In hindsight the best thing would have been to back out the release and deputize some developers to be full time QA.

This was not to be. Instead we followed up the second worst release with the absolute worse release that was to be a "bug fix only" release. What went wrong here was all of those bugs that were introduced had not been found. At the same time, our reliable means of verifying features and bug fixes and now most important assuring no regression bugs was gone.

Now I mentioned that the way out might have been to "deputize some developers to be full time QA". This sounds an awful lot like "Have the engineers test each others code."

The key difference is that in the first case they would be "Full Time", in the second case they would be "Part Time". I have experienced the benefit of 'part time' QA. The feeling that the other engineers are just 'phoning it in' is the best you can hope for. In reality what that other engineer wants to do is get this testing over with as quickly as possible so they can get back to the fun of actually doing what they consider real work.

So there you have it. Three ways to not do QA. They do not work, since you did not do QA.