Wednesday, 31 December 2008

To Become an Enterprise Software Architect

Ok, what are the skills required to become a great enterprise software architect?

Skills required:

1) Modelling

A big part of the job of a Software Architect is about modelling. Modelling helps understanding the system from a high level.

Drawing, understanding and communicating the models of the existing or new systems.

Modelling types:
  • Deployment Model
  • Components Model
  • Class Model
  • ...
Best Modelling Tools:
  • Pen and paper
  • Whiteboard
  • Microsoft Visio
  • Sybase PowerDesigner


NHibernate and Fluent NHibernate

Fluent NHibernate
Approaches to write queries:
  • Create HQL Query
  • Create Criteria
  • LINQ to NHibernate and Query

Thursday, 25 December 2008

Job Agency Lies Revealed

I don't say everybody lies at all but I think we need to be aware that there are some inevitable strategies which are based on dishonesty.

1) Fake Adverts.

Sometimes, you see an advert on a job site such as but it's indeed fake.

It's fake which means that the job doesn't exist really but it is faked to identify the available candidates in the market for their future jobs or to fill in their database.

Can you really identify the fake ones? It's too hard to be honest, so I suggest keep doing what you used to do!

2) Information Extraction

Some agents say they have a job for which I believe you are a very good fit while they don't really have it.

They are after your detailed information, the interviews you have had so far and the interviews you are going to.

The reason they are not honest with you sometimes is that they have a responsibility to fill in their database, also getting information from you helps them know which jobs are really available in the market.

The best strategy I think is to be honest as well as wise and move forward.

3) Fake Tasks

Some tasks which are asked from you to do are fake and do not belong to any project.

Again, I am not saying you shouldn't do the tasks you are given.

General advice:
  • Create rapport with agents and stick to them
  • Be honest and know that nothing is more compelling than honesty.
  • Be courteous and respectful
  • Be wise
  • Remember that Companies will give you the job ultimately not agents (although I believe God provides my job not Companies nor agents).

Wednesday, 24 December 2008

All About REST

REST Design Constrains:
  • Web is RESTful because the resources can be accessed using a url. The url itself can be accessed using GET, PUT, POST, DELTE or other verbs over HTTP. As long as a WCF service can be accessed using HTTP protocol over web it is RESTful.
  • Message structure?


Tuesday, 23 December 2008

All about IT Contracting...

ASP.NET Presentation Patterns

Click here to see an article about ASP.NET presentation patterns including MVC and MVP.


MVP pattern is best for WinForms, WPF and Silverlight applications.


MVC is best for ASP.NET Applications although you can use MVP as well.


Great comparison:

Job Hunting in IT

1. Prepare your CV and covering letter
  • Write your CV and get a professional friend or previous colleague to provide you feedback for improvement
  • Write a general Covering Letter

2. Find an appropriate job advert

  • Find a relevant job advert, know about the advertiser
  • If you can find the final Company from yellowpages for instance, that's great.

3. Apply

  • Apply for the job only by sending an email to the advertiser expressing your interest in the role - don't click the "Apply" button.
  • Suggestion: leave at least half an hour, then call them to check whether they have received your application and what they think (Don't wait until they call you, be proactive)
  • Get the name of the Company, Location and Job Description - it's possible that another agency has sent your application to them, so you need to avoid these jobs. Agencies are responsible to give you these details before sending your application to the client.
  • After reading the JD, confirm with the agent to send your application to the client.
  • If the agent asks you to give them the name of the Companies you have sent your application to, say that it's confidential. Aks them to give you the name of the company they want to send your application to emphasizing that it will remain confidential.
  • Try your best not to let agents send your application to the same client more than once because it will ruin all your applications with that client.
  • Record the important parts of your conversation with the agent, location, company ... in an excel file for further refer.
  • It's good sometimes to ask from the advertiser if they have any useful feedback about your CV to optimize it.
  • Create an excel file and put all the information you have so far got about agents, clients and jobs there. This is an excellent idea and plays an important role to manage your contacts and remembering the history of your calls.

4. Interview

  • Agency will contact you and arrange an interview date with you
  • Before the interview, read about Company, prepare questions you want to ask them, anticipate the Company's questions and practice them
  • Dress professional and attend the interview in advance
  • Sometimes more than 1 person interview you, so be prepared for that
  • Negotiate the role and be confident at all times
  • Be honest but professional

5. Job Offer

The client will contact you and give you a job offer, most often it's a bit less than what you initially asked because they want to feel that they have won the negotiation so if your bottomline is £50k, say £55k. Then negotiate you might get what you have negotiated.

Where to find an IT Job?
1) Your personal and professional network such as

  • Previous colleagues
  • Your professional contacts e.g. from LinkedIn
  • From communities you are member of e.g.

I had a friend who had 13 years of working experience and he said he has always got his jobs through word of mouth and never used any agency, so you can imagine how powerful this method is.

2) It's good to have a register containing list of IT Companies, then to send them an email with your CV and Covering Letter e.g. to ThoughtWorks

This way is better than using job adverts and agencies since Companies themselves prefer to round the agencies because they are costly, but obviously you need to have proper contacts.

I suggest using YellowPages...

3) Online Job Adverts

One good advice is to stick with an agent and try to create rapport. Remember their name. Write a diary of your conversations with them.

The other thing to remember is that untimately Companies are important although through Agencies.

How long does it take?

It depends on many factor including

  • How well your CV is written
  • How well your Covering Letter is written
  • How well you can manage the interviews and create rapports
  • Economic climate
  • Need of your skills
  • And above all LUCK!
But normally the process from writting your CV to starting a job takes about a week to 4 months depending on the situation and how quickly you can learn from your mistakes.

General tips:

  • Be proactive is very very important and it's often the main factor that determines you get your next job in 6 months or 3 weeks!
  • Be self-confident
  • Be unafraid of failure
  • Develop good communication skills
  • Be autodidact and learn from your mistakes

Monday, 22 December 2008

NCache and TierDeveloper are now Free!

"NCache is a high performance in-memory object caching solution for mission critical .NET applications with real-time data access needs."

"TierDeveloper is an object to relational mapping (O/R mapping) code generator that lets you develop extremely high performance .NET applications in record time."

TierDeveloper apparently is better than NHibernate because it generates code for you as well.

Click here to download both which are free.

ASP.NET 4.0 on CodePlex

Here, you can find the CodePlex project containing the latest codes and features of ASP.NET 4.0. Having said that ASP.NET 4.0 is not yet released but you can find its core components such as ASP.NET Dynamic Data, ASP.NET Dynamic Language Runtime (DLR)...

When to implement ISerializable interface?

Implementing ISerializable interface enables us to control how an object is serialized. In the other words, we can serialize an object to xml to reprst in the exact format we require.

In web services development, we also sometimes need to have full control over the way an object is serialized and passed over the network.

Have a look at this example.

Sunday, 21 December 2008


Download MVC3:

Tutorial, sample codes, webcasts:

Wednesday, 17 December 2008

Microsoft TechNet Virtual Labs

I was thinking whether it's possible to work and test technologies without actually installing them on my PC.

I found this, which povides so many interesting virtual labs to learn different technologies such as SQL Server Reporting Services.

Download Visual Studio 2010 CTP

This download gives you the virtual machine and virtual hard disk, then you will need Virtual PC or Virtual Server to open it.


Tuesday, 2 December 2008


JSON (JavaScript Object Notation) is a lightweight data-interchange format
  • It is easy for humans to read and write.
  • It is easy for machines to parse and generate. 

XML string:

Same data represented by JSON:

{"menu": { "id": "file", "value": "File", "popup": { "menuitem": [ {"value": "New", "onclick": "CreateNewDoc()"}, {"value": "Open", "onclick": "OpenDoc()"}, {"value": "Close", "onclick": "CloseDoc()"} ] } }}
More Info:

Wednesday, 26 November 2008

WCF - Hosting Solutions?

A WCF Service can be hosted in 8 different ways each which has pros and cons:
  • IIS
  • WAS (a component in IIS 7.0)
  • Windows Forms Application
  • WPF Application
  • Console Application
  • ASP.NET Application
  • Windows Services
  • Using WcfSvcHost.exe tool

Here are the details:

WCF - Ways to Create Proxy Class?

In WCF, There are 4 ways to create the proxy class:

1. Using the Add Service Reference dialog box in Visual Studio
2. Using svcutil.exe
3. Creating the proxy class manually by inheriting from ClientBase or DuplexClientBase class
4. Creating the proxy class dynamically at runtime using ChannelFactory class

Here are the details:

WCF - Which Serializers?

WCF supports 2 serializers:

1. DataContractSerializer
2. XmlSerializer

Here I will explain when to use which:

WCF - Message Encoding Types?

There are 3 message encoding types in WCF:

1. Text encoding
2. MTOM encoding
3. Binary encoding

Here I will explain where to use which:

WCF - Message Exchange Patterns?

Message Exchange Patterns in WCF are:

1. Request/Response
2. OneWay
3. Duplex

Here I will explain where we should use which:

Wednesday, 19 November 2008

Castle ActiveRecord Project

The Castle ActiveRecord project is an implementation of the ActiveRecord pattern for .NET, which consists of:
  • Instance properties representing a record in the database
  • Instance methods acting on that specific record
  • Static methods acting on all records.

Castle ActiveRecord is built on top of NHibernate, but its attribute-based mapping free the developer of writing XML for database-to-object mapping, which is needed when using NHibernate directly."

I was just thinking to create a project using ASP.NET MVC, NHibernate and Castle ActiveRecord. This combination makes sense.

ASP.NET MVC and NHibernate

Have a look at Sharp Architecture which uses ASP.NET MVC and NHibernate.

Can you write a code generator for this?

Tuesday, 18 November 2008

OSLO - Model Driven Platform

”Oslo” is the codename for Microsoft’s forthcoming model-driven development platform.

Microsoft is making a big investment in modeling and aims to remove the gap between designing and development.

Currently, people using many modeling tools such as Visio and Rational Rose to create design models and UML models, then developers have to understand and develop these. My understanding is Oslo is to resolve this gap.

In the other words, with Oslo Microsoft significantly simplifies the effort required to design, build, deploy and manage distributed applications. The technology to deliver these capabilities will be delivered through BizTalk Server, System Center, Visual Studio, BizTalk Services and .NET Framework.

Learn more:

Wednesday, 12 November 2008

Email Management Techniques

  • You don't have to answer to all of your emails. Before answering, ask yourself "is that necessary to answer"?
  • Don't read junk emails, remove them quickly
  • Group your emails where possible

How to negotiate WIN-WIN?

to be investigated...

Tuesday, 11 November 2008

POX Messaging Style

To be investigated...

REST Architecture

to be investigated...

Professionalism - Part1

How to be professional?

The only way to become a professional is to discipline yourself to think, speak, look and act like a professional.

Example 1: If you want to be a professional salesman, you must think, speak, look and act like a professional salesman.

Example 2: If you want to be a professional Principle Technologist, you must think, speak, look and act like a professional Principle Technologist.

Business Awareness

You must be aware of the business circumestances of the society and the following can help:

I suggest spending at least 20 minutes every day for this.

Industry Awareness

You must be aware of the
  • Latest technologies e.g. ASP.NET MVC
  • Future technologies e.g. SQL Server 2010 code named Kilimanjaro
  • Available market tools/products and their prices to resolve problems e.g. NUnit, NMock
  • New product releases e.g. Windows 7.0
  • Competitors, their products and prices

The following can help to gain this knowledge:

Microsoft PDC is where Microsoft announces many new technologies and releases.

You gain lots of infomation about

Tuesday, 4 November 2008


Learn LINQ easier by LINQPad

Microsoft Windows 7

It's the new operating system of Microsoft after Windows Vista. It was previously known as Windows Viena and is supposed to be released in 2010.

New Features/Enhancements:
  • Touch recognition
  • Speech recognition
  • Supported virtual hard disks (VHD): you can attach a new VHD natively or even boot to an already attached VHD
  • Improved boot performance
Learn more:

Friday, 31 October 2008

Using MSBuild in automated building and testing

MSBuild.exe command

  • Using this command we can execute some other commands (such as aspnet_merge or xcopy) or custom actions. We can pass a .proj file (a MSBuild script file) as an input argument to this command.
  • You can find it here: C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe
  • You can easily add this tool to Visual Studio; go to Tools/External Tools/Add tool

MSBuild script

MSBuild script file is an xml file with the extension of .proj in which we can define what actions we want the MSBuild.exe to execute.

Example of MSBuild script:

Using the following MSBuild script you can compile a website solution, merge the assemblies created and copy the contents of the compiled solution to a destination folder (Please remove the br elements):

Why using MSBuild?

Using MSBuild we can have automated build and testing. We can use CruiseControl.NET to listen to the events (such as a checkin or commit) happening in source controls (such as Visual SourceSafe or SubVersion), then to run a pre-defined MSBuild command. In which way, we can have automated build and testing.

Learn more:

Thursday, 30 October 2008

Microsoft Office Live Workspace

Microsft announced office live workspace, something less functional than what google has but more user friendly interface.

In this "cloud" you can work with your documents on the fly (internet) without the need to save them locally on your pc.

For more information, please see

What you can do with it?
  • Create document, save it, edit it, add comment, see the version history, etc
  • Create to do list
  • Create workspaces for hom, work, etc
  • Adding events, removing, updating
  • Adding contact list
  • You can share your documents or to do list with whoever you want
  • ...

Tuesday, 28 October 2008

Code Generator for Microsoft Enterprise Library

What is Microsoft Enterprise Library?

"The Microsoft Enterprise Library is a collection of reusable software components (application blocks) designed to assist software developers with common enterprise development cross-cutting concerns (such as logging, validation, data access, exception handling, and many others). Application blocks are a type of guidance; they are provided as source code, test cases, and documentation that can be used "as is," extended, or modified by developers to use on complex, enterprise-level line-of-business development projects."

How to get started?
Download the latest version including the code examples. Check the quick start section which has sample applications to demonstrate how to use Enterprise Library.

Code Generator for Enterprise Library?

Why not using a code generator to build your business logic, business entities and data access layer for you?

One of the communities in CodePlex are working on this and I found it very interesting:

I will use this for my next project :)

Friday, 17 October 2008

An Event from UK SQL Server User Group

Last night I attended an event about SQL Server from UKSSUG, and this is a summary:

SQL Server 2008 Videos on MSDN
It's great to know that they have uploaded Videos for SQL Server 2008 learning here.

SQL Server Integration Services on the web:

Kilimanjaro is the code name for the next version of SQL Server for H1 2010.

Mandison is the code name for the full integration of DATAllegro's technology into Kilimanjaro (SQL Server 2010).

Gemini is the code name for a key component of Kilimanjaro and it is about self-service BI using Excel. "The vision behind Gemini is to free IT resources by giving business intelligence analysis and reporting capabilities to the end-users without IT losing control".

Disable temporary object caching:
Christian Bolton, MVP, showed us how to disable temporary object caching in SQL Server 2008. It's on by default.
The scripts for this should be found on his blog here soon.

Passing Table Value Parameters:
Traditionally, we had to pass xml data type to a stored procedure to do that which has high performance cost. James Boother showed us how to pass Table Value Parameters to db objects. For this to work, we need to

  1. Create a new user defined type (UDT) in SQL Server containing the data structure of the table we want to pass
  2. Create a stored procedure having an input parameter of this type
  3. Pass a DataTable, IList or DbDataReader object from code to this stored procedure directly.
INSERT INTO Improvement
in SQL Server 2008 you can do this

INSERT INTO MyTable (MyId) VALUES (1), (2)

instead of


Service Broker
Simon Munro presented about Service Broker, which is a platform to build asynchronous & queued db applications.

He also showed us how to use Service Broker to send messages and data from one location to the other. Then, there was about half an hour discussion about great advantages Service Broker has over Biztalk such as performance and reliability.

His slides and scripts can be found here.

The next FREE UKSSUG event is on 20th November.

Thursday, 16 October 2008

Understanding Scrum

What is Scrum?

  • An agile software development framework.
  • Requirements are captured as items in a list of product backlog
  • Work is structured in cycles of work called sprints, iterations of work that are typically two to four weeks in duration.
  • Sprint is analogous to Extreme Programming Iterations
  • During each sprint, teams pull from a prioritized list of customer requirements, called user stories, so that the features that are developed first are of the highest value to the customer.
  • At the end of each sprint, a potentially shippable product is delivered.

Main Roles

Main Artifacts

User Groups and Communities:
Scrum Project Management Tools/Platforms:

You don't have to use any tool and many team have succeeded without it but if you insist, here are some:
ok, thanks you managed to make me confused! which one to use then? perhaps doesn't matter; pick a good one and use it.

CollabNet and RallyDev are recommended from the free ones.

More Info

Wednesday, 15 October 2008

jQuery Support in Visual Studio

jQuery is an open source javascript library to emphasize the interaction between javascript and html.

Microsoft announced that Visual Studio 2008 SP1 will have jQuery with intellisense annotation support which will benefit ASP.NET and ASP.NET AJAX developers.

However, it's good to know that there are many other javascript framworks available as well like
Click here to find great code samples using JQuery in ASP.NET MVC...
Prototype is another popular javascript framework.

Setup Visual Studio Intellisense for jQuery:
Read more:

Technology Event Providers

Why attending a technology event every month?
  • Meeting new people
  • Learning new things about technology
  • It's often fun


1. Find an event from the list below:

2. Register for an event

3. Send an email to your friends to register for this event

4. Attend the event, with your friends possiblly, and write notes

5. Write a new post about the interesting points of the event in your blog



Thursday, 9 October 2008


Resharper, it's coool!

Agility - Agile Software Development


The world is changing and it's natural as well as inevitable. The world has been designed to change from the beginning. Nothing is stable and nothing can be insured in the real meaning.

That's why we have risks, because nothing is completely predictable and we are living in the world of uncertainty.

Our body, our neighbours, the earth, our parents, our society, our economy, our sky, seas, technology, structures.

There is no guarantee that when we sleep tonight, we will wake up tomorrow!
There is no certain guarantee that the job we have today, we will have tomorrow as well.
When driving everything is changing in the road.
Our body cells are changing every second.
Our economy is changing.
The weather is changing.
So many books that we have read and were the latest at the time, are joining the history.

It's important to acknowledge that everything is changing; few with our will and many without our will, some rapidly some slowly. This acknowledgement helps us think about the solutions to handle these situations.


How can we control and manage the changes?

"Agility is the ability to respond rapidly and effectively to the changes which are happening in the world."

It's good to say that agility is contextual. Values are contextual. Priorities are contextual. Laws are contextual. Many things in our world are contextual. A law which is valid in a country might be totally invalid in another country. There are values which are valid in some countries and invalid in the others.

Everything in the world must be agile to succeed, otherwise it will die and fail soon.
e.g driving must be agile; you must have the ability to respond quickly and effectively to the changes which are happening in the road.

How to be agile in business? A business which is not agile will fail soon or late.

What are the principles/metrics of becoming agile?

I think the first step is to determine in which context we want to define agility, then to find principles for that context. Contexts like:

  1. Driving

  2. Software Development

  3. Consultancy

  4. Business

  5. Family

  6. Society

  7. Computer

Have a look at David Anderson presentation.

Agile Software Development - Principles/Best Practices

There are some methodologies and approaches that are Agile like AUP, SCRUM, XP and here I would like to share with you some best practices:

1) Develop quickly and deliver more often. In this way, the development will have more control over the changes of business environments. Business must be aware of this change and educated wherever required. Business must get involved consistently not just for gathering the requirements but also to provide feedback on the releases of the application.

2) Define iterations, each which for a period of 2-3 weeks. Plan for each iteration, when to start, what should be achieved at the end of the iteration (milestone), when the end of iteration is and who should work on this iteration.

3) Have daily standup meeting to review the progress of each iteration and tackle issues as soon as possible with prioritizing based on the importance to the business. Having consistent and proper communication is vital to the success of the project.

4) Reuse the existing code/components wherever possible and improve them whenever possible.

5) Use automated testing tools, so that you can test more code in less time e.g. write your tests using NUnit, then automate the tests to run using CruiseControl.NET. Automated testing improves productivity.

6) Test during the lifecycle of the development. Do not leave testing to the end. use Test Driven Development.

7) Use Web-Oriented Architecture, which means we should develop applications to be distributable over the web. SaaS (Software as a service)

8) Plan and schedule the security at the early stage of the software development. The later it's left, the harder it becomes to integrate it in the system.

Visual Studio 2010 and .NET 4.0

Visual Studio 2010, codenamed "Hawaii", is under development. Though the full feature set has not been finalized, some features that the teams are considering have been made public.

"Microsoft announced the .NET Framework 4.0 on September 29, 2008. While full details about its feature set have yet to be released, some general information regarding the company's plans have been made public. One focus of this release is to improve support for parallel computing, which target multi-core or distributed systems. To this end, they plan to include technologies like PLINQ (Parallel LINQ), a parallel implementation of the LINQ engine, and Task Parallel Library, which exposes parallel constructs via method calls. Microsoft has also stated that they plan to support a subset of the .NET Framework and ASP.NET with the "Server Core" variant of Windows Server 2008's successor."

Download Visual Studio 2010 and .NET 4.0 from here.

The product blog can be found here.

Learn more:


Professional Developers Conference, the latest and roadmap of Microsoft development technologies are always declared here:

Cloud Computing

"Cloud" is a metaphor for the Internet and is an abstraction for the complex infrastructure it conceals. "Computing" refers to computer technology.

Cloud Computing refers to internet-based development that uses computer technology to provide software as a service (SaaS).

According to the IEEE Computer Society, "It is a paradigm in which information is permanently stored in servers on the Internet and cached temporarily on clients that include desktops, entertainment centers, table computers, notebooks, wall computers, handhelds, etc."

My comment is although there are some differences but I think this technology existed years ago but now they have just renamed it and packaged it in a more standard way e.g. UDDI existed years ago to provide web services globally to client applications.

For instance, Google few years ago introduced Google Docs and some other cloud tools, but it's good that Microsoft finally decided to invest on this.


Up-to-date with Technology

I'd recommend spending about few hours a week on these sites to keep up-to-date:


Software development:


SQL Server:


Windows Cloud

Windows Cloud is the next generation of Windows, which is an operating system for internet!

See this article discussing what Ballmer has discussed:

Tuesday, 7 October 2008

Domain Specific Languages

After understanding its definition, I realized the fact that I created a DSL tool in 2007 myself. This tool was to map table fields to Flex page fields using a new interface and kind of language to define and manage the mappings:

Table Field -> Field Data -> Page Field

IT and Business;jsessionid=36299A91CF0A6240558C74417E3DABF4

I found this very interesting and the reason was I could associate what are said here with my works e.g. at Game Group Ltd.

Important notes:

  • There is a large gap between IT and Business which is the main reason of many project failures and it must be shortened by having proper and consistent communication
  • Almost every IT company wishes and plans to attract talented IT people and there is a war in the market to do so.
  • The whole team, including business members, Tester, Developer & Manager, must be responsible for the quality of the software.
  • Collaboration benefits: Higher responsiveness, higher quality, richer communication, more organized development
  • Motivation is highly important to improve productivity. How do you motivate your people?
  • Developing a software is an art more than a science. You're a Software Craftsman not a Software Developer!
  • Design is the pure principle of a Software Development. There are always tools to build the software but design is what is highly important.
  • Bring the user experience to your iterative development life cycle.
  • Domain-Driven Design
  • Domain Specific Language
  • Ruby

Saturday, 20 September 2008

Refactoring Techniques - High Performance Code

This blog will hold the collection of refactoring and performance techniques.

What is Refactoring?

Refactoring is a process to improve upon the design of existing code, while preserving its intended functionality.

Bad Code Smells:
Refactoring Techniques:
Here, you can find an excellent list of refactoring techniques with examples. In below, I am going to duplicate some:


List items = new List();

Bad: items.Count
Good: items.Length

Length property is faster than Count performance-wise.



int[] items = new int[2];

List items = new List();

1. Using Generic list gives you more power and control over the list
2. You do not have to specify the length of the array at the time of its creation

3) Extract Constant

public static double CalcCircumference(double diameter)
{ return 3.14 * diameter; }

public const double PI = 3.14;
public static double CalcCircumference (double diameter)
{ return PI * diameter; }

1. If we need to change PI value, we only need to change it in one place
2. Increased readibility

4) Extract Method

5) Decompose IF Conditional

6) Extract Variable

7) Encapsulate Field:

8) Extract Interface:

9) Reorder Method Parameters

10) Rename (type, method, class, namespace, variable)

11) Promote Local Variable to Parameter

1) To inject dependency (object, type, etc)

12) Use StringBuilder instead of String

For another list of refactoring techniques, please see

Refactoring Tools:

Learn More:

Thursday, 11 September 2008

Unit Testing - deleting test data

Imagine a unit test in which you need to insert test data into database so that the test can run.

After running the test, you need to delete your inserted test data otherwise you will have so much junk in database.

One way, that we used for some time, is that in the the teardown method of the current test fixture, you run a stored procedure to delete all your test data from all the tables.

The problems with this way are:
  • Cuncurrency issues when 2 test cases are run at the same time
  • Performance issues:
  • Unnecessary connection to database tables in order to delete the test data
  • Unnecessary use of transaction logs which lead to have larger .ldf file (all the DML scripts affect transaction logs)
  • Unnecessary change of indexes (all the DML scripts affect indexes)
The best way is to use transaction in each test case so that only those tables and data affected by the test are involved. In addition, because the changes will be rolled back at the end of the test case, so we won't have concurrency issue and database will remain in a consistent state.

I will write a sample code here later.