Friday, August 31, 2007

Product Development vs Software Development

In software business, a lot of people use the term product development and software development synonymously. However, IMHO, I think it is two distinct discipline or job.

Software development mainly consist of major phases and activities such as understanding requirements, software design and architecture, coding, testing, QA and other engineering practices such as performance and technical benchmarking.

However, in software business, simply developing and shipping software is not enough to keep the company going. The company needs not just to develop the software, but to develop a product.

Product development include activities such as analyzing market trends and customer need, crafting a product vision of what you want to deliver and how you differentiate from your competitors, creating market awareness and communicating your vision to your customers, develop a strategy to capture and fulfill the market need, platform to deliver the product and of course shipping the product just in time to capture the market.

Once you have the software piece ready to ship, you also need to make sure you have the necessary infrastructure to support your software, for example training your customer support personnel, documentation, maintenance release, and channel for customer to provide feedback and so on.

Then, you need a plan to nurture the product. This includes branding; strengthen the customer relationship, making the product more mature by fixing short coming and incorporating customer feedback and so on.

All these are part of the product development activities.

To sum up, I would like to use the following diagram to illustrate my point:

Product Development vs Software Development

Click to view in full size.

Labels:

Thursday, August 30, 2007

NET: Checking what is the type argument

The following code sample show how you can check what is the type of the type argument passed to instantiate the generic type.


public class TypeDisplayer<T>
{
public string GetTypeArgument() { return typeof(T).FullName; }
}
 
static void ShowGenericTypeArgument()
{
//This will print System.Int32.
TypeDisplayer<int> i = new TypeDisplayer<int>();
Console.WriteLine(i.GetTypeArgument());
 
//This will print System.String.
TypeDisplayer<string> s = new TypeDisplayer<string>();
Console.WriteLine(s.GetTypeArgument());
}

Labels: , ,

NET: Generic Constraint Type - Default Constructor Constraint Type

Default Constructor constraint allow you to specify that the type parameter must have a default/parameterless constructor. This is useful if you want to create a new object instance of the type argument.


public class DefaultConstructorGenericType<T> where T : new()
{
public T Value;
 
public DefaultConstructorGenericType()
{
Value = new T();
}
}
 
public class ClassWithDefaultCon
{
public ClassWithDefaultCon() {}
}

public class ClassB
{
public int a;
public ClassB(int v) { a = v;}
}
 
static void InstantiateDefault()
{
// This code will compile fine.
DefaultConstructorGenericType<ClassWithDefaultCon> vt =
new DefaultConstructorGenericType<ClassWithDefaultCon>();
 
// This code will give compile error
// because ClassB does not have default constructor
DefaultConstructorGenericType<ClassB> vt =
new DefaultConstructorGenericType<ClassB>();
}


In the above sample, DefaultConstructorGenericType can only accept a type argument that has a default constructor. where keyword is used to specify a generic constraint in C#. In the above code sample, I specify that type parameter T has to have default constructor (indicate by where T : new()).

Labels: , ,

Wednesday, August 29, 2007

NET: Generic Constraint Type - Inheritance Constraint Type

Inheritance type constraint allow you to specify that the type parameter must be derive from certain base class or interface. It is useful if you want to assume the type argument to be of certain type so that you can call method on the instance of the type argument. Visual Studio will give you full intellisense support.


public interface IPrint
{
void Print();
}
 
public class Printer : IPrint
{
public void Print()
{
// Do something
}
}
 
public class PhotoCopier
{
public void PhotoCopy()
{
// Do something.
}
}
 
public class DeviceWrapper<T> where T : IPrint
{
public T Device;
}
 
static void InstantiateDevice()
{
// This code will compile fine.
DeviceWrapper<Printer> vt =
new DeviceWrapper<Printer>();
 
// This code will give compile error
// because PhotoCopier is not derive from IPrint.
DeviceWrapper<PhotoCopier> vt2 =
new DeviceWrapper<PhotoCopier>();
}

In the above sample, DeviceWrapper can only accept a type argument that is derive from IPrint.
where keyword is used to specify a generic constraint in C#. In the above code sample, I specify that
type parameter T has to be derive from IPrint (indicate by where T : IPrint).


Visual Studio Intellisense support
Visual Studio Intellisense support.

Labels: , ,

NET: Generic Constraint Type - Reference Constraint Type

Reference type constraint allow you to specify that the type parameter must be of reference type.

class GenericReferenceType<T> where T : class
{
public T Value;
}
 
static void InstantiateRefType()
{
// This code will compile fine.
GenericReferenceType<System.Text.StringBuilder> vt =
new GenericReferenceType<StringBuilder>();
 
// This code will give compile error
//because Point is not reference type.
GenericReferenceType<System.Drawing.Point> vt2 =
new GenericReferenceType<System.Drawing.Point>();
}


In the above sample, GenericReferenceType can only accept a reference type as its type parameter.
where keyword is used to specify a generic constraint in C#. In the above code sample, I specify that
type parameter T has to be of reference type (indicate by where T : class).

Labels: , ,

NET: Introduction to Generic Constraint Type

Generic constraint allow you to specify constraint/rule that limit what .net type can be used as type argument when you instantiate a generic type.

In this post, I will show a short code sample of how to use the various generic constraint.
For more explaination about Generic Constraint, visit msdn

How to specify constraint value type


Value type constraint allow you to specify that the type parameter must be of value type.

class GenericValueType<T> where T : struct
{
public T Value;
}
 
static void InstantiateValueType()
{
// This code will compile fine.
GenericValueType<System.Drawing.Point> vt =
new GenericValueType<System.Drawing.Point>();
 
// This code will give compile error
//because StringBuilder is not value type.
GenericValueType<System.Text.StringBuilder> vt2 =
new GenericValueType<StringBuilder>();
}


where keyword is used to specify a generic constraint in C#. In the above code sample, I specify that type parameter T has to be of value type (indicate by where T : struct).

Labels: , ,