Wednesday, August 10, 2011

Agile Software Development Methodology

Agile is software development methodology. It is very effective where Client frequently changes his
requirement.Since it has more iteration so you can assure a solution that meets clients requirement.
More than one build deployment for a project.It involves more client interaction and testing effort.

There are two methods by which this methodology can be implemented:-

1) Scrum: Each iteration would called a scrum which can be a 1-2 Months.In Scrum Client prioritize
his requirements what he want first. If developer did not meets all the requirement which was being fixed for a particular scrum than rest of the development part would be transferred to the next scrum (would be delivered in the next build),  means developer can't increase time decided for a scrum.

2) Extreme Programming (XP): here iteration period would be less then in scrum , which is being 2-4
weeks.Here developer prioritize what to do first on the basis of client requirement. This duration which
was being fixed for a iteration, can be increase if the some development part is still pending. The build would deployed with having all the client needs.Thus iteration period is not fixed here it can be increase.but iteration should meets all the client's requirement in this build.More attention is required for testing in XP.

It is a methodology to satisfy the customer through early and continuous delivery of valuable software. This is useful when we don't have a clear idea of the client's requirements.The development activities can be carried out using the iterative actions.

The following table enumerates the reasons for choosing Agile methodology over the Waterfall method.
 
1) Once a stage is completed in the Waterfall method, there is no going back, since most software designed and implemented under the waterfall method is hard to change according to time and user needs.  The problem can only be fixed by going back and designing an entirely new system, a very costly and inefficient method. Whereas, Agile methods adapt to change, as at the end of each stage, the logical program, designed to cope and adapt to new ideas from the outset, allows changes to be made easily.  With Agile, changes can be made if necessary without getting the entire program rewritten.  This approach not only reduces overheads, it also helps in the upgrading of programmes.

2) Another Agile method advantage is one has a launch-able product at the end of each tested stage.  This ensures bugs are caught and eliminated in the development cycle, and the product is double tested again after the first bug elimination.  This is not possible for the Waterfall method, since the product is tested only at the very end, which means any bugs found results in the entire programme having to be re-written.
 
3) Agile’s modular nature means employing better suited object-oriented designs and programs, which means one always has a working model for timely release even when it does not always entirely match customer specifications.  Whereas, there is only one main release in the waterfall method and any problems or delays mean highly dissatisfied customers.    
 
4) Agile methods allow for specification changes as per end-user’s requirements, spelling customer satisfaction.  As already mentioned, this is not possible when the waterfall method is employed, since any changes to be made means the project has to be started all over again.   
 
5) However, both methods do allow for a sort of departmentalization e.g. in waterfall departmentalization is done at each stage.  As for Agile, each coding module can be delegated to separate groups.  This allows for several parts of the project to be done at the same time, though departmentalization is more effectively used in Agile methodologies.

NUnit - A Unit Testing Framework for .Net Applications

What is NUnit 

NUnit is an open-source unit-testing tool built for .NET, which follows in a long line of similar xUnit testing tools built for other platforms. It provides an easy-to-use framework for writing and running unit tests for your .NET applications. NUnit is an automated unit testing framework for .NET. NUnit is free to use with your .NET projects. NUnit is ported from another product called JUnit, which is a unit testing framework for Java applications. NUnit provides a class library which includes some classes and methods to help you write test scripts. NUnit provides graphical user interface application to execute all the test scripts and show the result as a success/failure report (instead of message boxes from the test script). NUnit is the most popular unit testing framework for .net applications. NUnit does not create any test scripts by itself. You have to write test scripts by yourself, but NUnit allows you to use it's tools and classes to make the unit testing easier.

Test Driven Development

Improved Productivity

A key principle of TDD is that developers are most productive when they are in the process of fixing a bug in an application (note: not looking for the bug). This is one of the few times during development that measurable progress is being made on the project. While developers spend time on other things, like finding bugs, they aren't able to spend as much time writing code to correct defects (for example, fixing bugs). A key benefit of test driven development (TDD) is to maximize the time developers spend in bug-fix mode, thus maximizing their productivity.

Improved Quality

In TDD, all non-trivial features of an application are tested. These tests are written before the actual code is written, and they are run all the time. Whenever a test fails, the developer immediately corrects the failure. So, when the time comes to add new functionality, the developer assumes the functionality exists and writes a test. He then runs the tests (which often won't even compile if they rely on as-yet-undefined classes and methods), and when they fail, he enters bug-fix mode and begins adding code to the application until he can get all tests to pass once more. Often, the process of writing the test for the functionality will provide the developer with a better understanding of how the production code should be designed, resulting in improved final code quality.
TDD also makes code easier to maintain, upgrade, and redesign, and has other benefits which the reader is encouraged to research.


NUnit: A Test Framework for .NET

NUnit provides a simple way for developers to write unit tests of the .NET classes, and comes with a small, sample application that demonstrates its use. The current version is written in C# and relies on attributes rather than inheritance and/or naming conventions to define tests and test suites. The main attributes involved are TestFixture, which applies to a class containing tests, SetUp and TearDown, which are run before and after each test, and Test.

NUnit also provides a simple graphical user interface that lets you select which assembly you want to test and which set of tests within that assembly you want to run. It then runs all of the tests in the assembly (or namespace or class) selected, displaying a green bar if everything passes and a red bar if any tests failed. Details of each failed test are also displayed, making it very easy to locate the cause of the failure.

Aa479010.aspnet-testwithnunit-01(en-us,MSDN.10).gif

Figure 1. NUnit's GUI tool provides instant feedback that everything is running as it should be, according to the tests defined so far.

Aa479010.aspnet-testwithnunit-02(en-us,MSDN.10).gif

Figure 2. NUnit shows the details of a failure caused by an invalid connection string.

There are other testing tools coming to market for .NET, but today NUnit has the largest support base, and is both free and open source, making it something you may want to try first.

Related Tools

NUnit Visual Studio .NET Addin

This addin, which requires NUnit, allows you to run your tests without leaving the Visual Studio .NET IDE. Simply right-click on a project or solution in the Solution Explorer to run all tests within that project or solution. The results are displayed in the Output window. Unfortunately, there are no pretty green or red bars, but if having one less program open is important to you, this can be a useful tool.

Aa479010.aspnet-testwithnunit-03(en-us,MSDN.10).gif

Figure 3. Run tests in Visual Studio .NET with a simple right-click.

Aa479010.aspnet-testwithnunit-04(en-us,MSDN.10).gif

Figure 4. Output from NUnit tests run within Visual Studio .NET

NUnitASP

NUnitASP allows TDD to be extended to the user interface in ASP.NET, by providing a means of testing Web controls. Its usage is beyond the scope of this article, but you may learn more about it from the NUnitASP Web site.

A Simple Application

To demonstrate TDD, I've used it to help me redevelop a multi-tier sample application for ASP.NET. The application demonstrates how to register a user for an application, how to grant them access to secure web pages, and how to allow them to sign in and sign out. The data access layer for this application is concerned with adding users to the database, retrieving user information, and verifying that user logins are correct. I’ve used this sample for a couple of years now and built it with TDD several times, learning new things with each iteration.

Windows Workflow Foundation?

What is Windows Workflow Foundation?

WWF is a programming model for building workflow-enabled applications on windows. System. Workflow namespace has all the necessary modules to develop any type of workflow.

What is a Workflow?

A Workflow is a set of activities, which is stored as model and they depict a process. Below figure depicts clearly the difference between Workflow and Activity. Every task is an activity and group of activity depicts a complete workflow. Workflow is run by the Workflow runtime engine.

What are different types of Workflow in Windows Workflow foundation?

There are two basics type of workflow Sequential Workflow and State machines workflow.
A sequential workflow has clear start and finish boundaries. Workflow controls execution in Sequential workflow. In sequential execution, one task is executed after other. Sequential workflow is more rigid in format and execution path has a deterministic nature.

A State machine workflow is more dynamic in nature. Workflow has states and the state waits for events to help it move to next state. In State machine execution path is undeterministic nature.
Below figure shows visual conceptualization of fundamentals. You can see in Sequential workflow the execution path is very determent. Shiv performs the entire task sequentially and these tasks are very determent. Now have a look at the second workflow. Every state goes to other state when it receives some external events. For instance when Shiv is seeing star trek there is an event of flashing news which triggers him to see the flashing new.

Monday, August 1, 2011

Ajax Minifier reduces the size of javascript and css files

Ajax Minifier is a Microsoft program which mifys js and css files. Minification is the process of reducing the size of a CSS or JS file by removing whitespaces, comments and other optimization. This is a free tool and it can be used in command line or MSBuild tasks.

The idea behind this tool is to improve the load time whenever the site is requested. Most of the times, about 70-90% of time spent waiting for a page on the average web site is actually due to the number of HTTP requests for images, JS and CSS files. To improve this, we can use this tool and it minify's the css, js files so that the download time will be considerably lesser than the actual file.

So whenever you trigger a new build from visual studio its going to execute a build and before moving that build to deployment server its going to execute this build task to minify and combine the css and javascript files in your site as mentioned by you in the target folder. After combining, its going to creat a single javascript and a single css file for entire site and name it with this version of build.

When the user requests for your site on the next time the name of previous js file and this js file is going to be different because of this version number change and the browser is going to download it to local cahe, so for subsequent requests it will use it from the cache. This is how it makes the site very faster.

Ranking Functions in Sql Server 2008

There are four ranking functions in sql server. They are Row_Number(), Rank(), Dense_Rank(), Ntile().

Row_Number()

Row_Number function gives the sequential order of numbers starting from 1 for the specified row. This function is used to split the table based on this row number.


 
select *, ROW_NUMBER() over(partition by part order by value) AS Partition
from Ranker

Rank()

Rank() function consider the repeating values in the column. If two values are same in the column means both values are given the same rank and the next value gets the respected rank.

Dense_Rank()

Dense_Rank() is as same as rank function the only difference is the next value to the repeating value should take the rank in sequence order.

Ntile()

Ntile() function is different from others. It splits the table based on the given range and rank the number for the partitions.



create table Ranker(value int)

Insert into Ranker values(8),(1),(6),(2),(3),(6),(4),(5),(8),(9),(3),(7)

select *,
	ROW_NUMBER() over(order by value) AS Row_No,
	RANK() over(order by value) AS Rank ,
	DENSE_RANK() over(order by value) AS Dense_Rank,
	NTILE(4) over(order by value) AS Ntile
from Ranker  
 
 
Value	Row_No	Rank	D_Rank	Ntile
1	1	1	1	1
2	2	2	2	1
3	3	3	3	1
3	4	3	3	2
4	5	5	4	2
5	6	6	5	2
6	7	7	6	3
6	8	7	6	3
7	9	9	7	3
8	10	10	8	4
8	11	10	8	4
9	12	12	9	4


Sunday, March 20, 2011

Configure Secure Socket Layer (SSL) in IIS 7 or IIS 7.5 in Windows 7

HTTPS is a secure communications channel that is used to exchange sensitive information like User Credentials, Credit Card details etc. between a client computer and a server. It uses SSL which encrypts communication over a network like the internet.

In this article, we will see how to configure Secure Socket Layer (SSL) in IIS 7.x in a Windows 7 machine. To enable SSL in IIS, you must first obtain a certificate that is used to encrypt and decrypt the information transferred over a network.

I assume you have configured IIS 7 on your Windows 7 box and have ASP.NET registered on your IIS server. If you have not yet configured IIS on your Windows 7 box, I strongly suggest you to read these two posts before continuing further

Install IIS 7 on Windows 7

Resolving ASP.NET 4.0 has not been Registered on the Web Server Error

Assuming you are all set, go to Start > All Programs > Accessories > Run. Type Inetmgr and hit enter. This opens up the IIS Manager. In the IIS Manager > Select the root node > Double click ‘Server Certificates’

IIS Server Certificates

If you have a list of Server Certificates installed on your server, you will be able to view them now. But it happens that I do not have any on my server. In that I can either ‘Create Certificate Request’ or use a ‘Self-Signed Certificate’ for testing purpose.

Self Signed Certificate

Note: If you choose the ‘Create Certificate Request’ option, IIS creates a Base64 encoded request. You can then submit this request to a Certificate Authority (like Verisign) and receive a SSL certificate which can be registered on your web server using the ‘Complete Certificate Request’ that you see in the screenshot above.

However if you choose the ‘Create Self-Signed certificate option, then IIS creates a self-signed certificate for your own server. It is an easy option if you plan to use HTTPS for local testing purpose. Remember that you can access this certificate only from your machine.

We will go ahead with creating a Self-Signed certificate for testing purpose. Click the ‘Create Self-Signed certificate’ link > Enter a friendly name for the certificate request and hit OK.

Self Signed Certificate Name

As you can see in the screenshot below, we have a self-signed certificate that we can use for testing purpose.

Sample Cert

The last step is to set the protocol for SSL for your website. To do so, select your website in the IIS Manager > In the Action pane, select Bindings > Add Site Binding

Https Site Binding

Select the Type https and ‘SampleCert’ as SSL certificate and click OK

AddIis Site Binding

Your Website is now SSL enabled. To test, type https://localhost/YourSiteName and you should be able to see the default page.

I hope you liked the article and I thank you for viewing it.

Friday, March 4, 2011

Difference between WPF and WCF in .Net

Window presentation foundation (WPF)is to help developers create attractive and effective user interfaces. The WPF is included in version 3.0 of the Microsoft .NET Framework, allows building interfaces that incorporate documents, media, two- and three-dimensional graphics, animations, Web-like characteristics, and much more.

Wherein,Windows Communication Foundation (WCF) is a framework for distributed programming. The WCF is designed to offer a manageable approach to distributed computing, broad interoperability, and direct support for service orientation. It includes serialization facilities that enable loose coupling and versioning, and it provides integration and interoperability with existing .NET Framework distributed systems technologies such as Message Queuing (MSMQ), COM+, ASP.NET Web services, Web Services Enhancements (WSE), and a number of other functions.

Convert Time in Different TimeZones in ASP.NET

In this article, we will see how to convert time from one time zone to another, in an ASP.NET application.
Step 1: Fire up Visual Studio > File > New Website. Drag and drop a DropDownList and two Label controls to the page and add a ‘SelectedIndexChanged’ event to the DropDownList (we will code this event later). The DropDownList will display the different Timezones and the Label controls will display the Local time as well as the Converted time. Here’s how the markup would look like.
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="ddlTimeZone" runat="server" AutoPostBack="True"
onselectedindexchanged="ddlTimeZone_SelectedIndexChanged"
AppendDataBoundItems="true" >
<asp:ListItem Text="Select a TimeZone" Value="Default value" />
asp:DropDownList>
<br /><br />
Local Time: <asp:Label ID="lblLocalTime" runat="server" Text="">asp:Label>
<br /><br />
Converted Time: <asp:Label ID="lblTimeZone" runat="server" Text="">asp:Label>
div>
form>
Step 2: We will now populate the DropDownList with the different TimeZones available. A simple way to do that is to use the TimeZoneInfo.GetSystemTimeZones method. This method returns a generic ReadOnlyCollection(Of T) collection of TimeZoneInfo objects.
Write the following code in the Page_Load method
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
lblLocalTime.Text = DateTime.Now.ToString();
ReadOnlyCollection<TimeZoneInfo> tzi;
tzi = TimeZoneInfo.GetSystemTimeZones();
foreach (TimeZoneInfo timeZone in tzi)
{
ddlTimeZone.Items.Add(new ListItem(timeZone.DisplayName, timeZone.Id));
}
}
}
VB.NET (Converted Code)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not Page.IsPostBack Then
lblLocalTime.Text = Date.Now.ToString()
Dim tzi As ReadOnlyCollection(Of TimeZoneInfo)
tzi = TimeZoneInfo.GetSystemTimeZones()
For Each timeZone As TimeZoneInfo In tzi
ddlTimeZone.Items.Add(New ListItem(timeZone.DisplayName, timeZone.Id))
Next timeZone
End If
End Sub
As you can see, we first extract the different TimeZones available on the machine using TimeZoneInfo.GetSystemTimeZones and then loop through the collection and add the name and value to the DropDownList. The TimeZoneInfo.DisplayName is the Name and the TimeZoneInfo.Id is the value added to the DropDownList.
image_2
Step 3: The last step is to convert the local time into the TimeZone selected by the user in the DropDownList. We will do the conversion using the TimeZoneInfo.ConvertTimeBySystemTimeZoneId. This method converts a time from one time zone to another based on the ‘time zone identifier’ without the need to know whether the converted time is standard or daylight saving time. Remember we used the TimeZoneInfo.Id that formed the ‘value’ of the DropDownList in Step 2. We will use that value here as shown below:
C#
protected void ddlTimeZone_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlTimeZone.SelectedIndex > 0)
{
DateTime dt = DateTime.Now;
lblTimeZone.Text = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(dt,
TimeZoneInfo.Local.Id, ddlTimeZone.SelectedValue).ToString();
}
}
VB.NET (Converted Code)
Protected Sub ddlTimeZone_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
If ddlTimeZone.SelectedIndex > 0 Then
Dim dt As Date = Date.Now
lblTimeZone.Text = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(dt, TimeZoneInfo.Local.Id, ddlTimeZone.SelectedValue).ToString()
End If
End Sub
That’s it. Run the application and convert the local time into the desired TimeZone as shown below
image_1

Tuesday, February 8, 2011

SQL DISTINCT on Multiple Columns

The DISTINCT clause works in combination with SELECT and gives you unique date from a database table or tables. The syntax for DISTINCT is show below

SELECT DISTINCT "column_name"
FROM "table_name"

If you want a DISTINCT combination of more than one column then the syntax is

SELECT DISTINCT column1, column2
FROM "table_name"

Let's look at some examples to understand the usage of the DISTINCT keyword. First, let's create a table for our illustration and insert some data.

CREATE TABLE DuplicateTest(
Firstname
nvarchar (30) NOT NULL,
Lastname
nvarchar(30) NOT NULL,
PostalCode
nvarchar(15) NOT NULL,
City
nvarchar(30) NOT NULL
)
insert into DuplicateTest
(Firstname,Lastname,PostalCode,City)
values
('Param', 'Singh', 'B283SP', 'Birmingham'),
('Steve', 'White', 'EC224HQ', 'London'),
('Mark', 'Smith', 'L324JK', 'Liverpool'),
('Claire', 'whitehood', 'M236DM', 'Manchester'),
('Param', 'Singh', 'B283SP', 'Birmingham')

select * from DistinctTutorial
DuplicateTest
Firstname Lastname PostalCode City
Sarvesh Singh B263SP Birmingham
Steve White EC224HQ London
Mark Smith L324JK Liverpool
Claire whitehood M236DM Manchester
Param Singh B283SP Birmingham

In the result set above there are repetitions in the City Column. Let's get a list of all cities without repeating them using DISTINCT.

select DISTINCT City from DuplicateTest
City
Birmingham
Liverpool
London

Manchester


You can see 'Birmingham' is just returned once in this result, even though it appears more than once in the table. You can get the same result using GROUP BY as shown below.

select city from DuplicateTest
group by city

Let's now use DISTINCT with more than one column. We will add the Lastname column in as well.

select DISTINCT City,Lastname from DuplicateTest
Distinct City and lastname
City Lastname
Birmingham Singh
Liverpool Smith
London White
Manchester whitehood

We get a list of results that have multiple rows, none of which are duplicated.

Again, you can get the same result by using GROUP BY as shown below:

select city,lastname from DuplicateTest
group by city, lastname

If you look at the original data, there are two users with same Lastname (Singh) who live in the same city (Birmingham). With the DISTICT keyword you get one unique row. Let's now add another column to our SELECT query.

select DISTINCT City,Lastname,Postalcode from DuplicateTest

This returns:

City Lastname PostalCode
Birmingham Singh B263SP
Birmingham Singh B283SP
Liverpool Smith L324JK
London White EC224HQ
Manchester whitehood M236DM

You will notice now that you are seeing two rows with the same lastname of Singh. This is because their 'Postalcode' is different, and the addition of that column makes the rows unique.

Again you will get the same result using GROUP BY as shown below:


select city, lastname, postalcode
from DuplicateTest
group by city, lastname, postalcode

Let's look at another example where you can use DISTINCT on multiple columns to find duplicate addreses. I've taken this example from the post. Please refer to this post for more detail.

SELECT PostCode, COUNT(Postcode)
FROM
(
SELECT DISTINCT Address1, Address2, City, Postcode
FROM AddressTable
) AS Sub
GROUP BY Postcode
HAVING COUNT(Postcode) > 1

Or you can use GROUP BY as follows:

SELECT Address1,Address2,City,PostCode,Count(PostCode)
FROM AddressTable
GROUP BY Address1,Address2,City,PostCode
HAVING Count(PostCode) > 1

In both of these cases, we are using DISTINCT to find those rows that are duplicates, based on the columns we include in the queries.

DISTINCT can also be used to get unique column values with an aggregate function. In the example below, the query gets the unique values of reorderpoint and then does a SUM.

USE AdventureWorks
GO
SELECT SUM(DISTINCT ReorderPoint) as DistinctSum
FROM Production.Product
GO

Result: 1848 rows

In the example below query is doing a SUM of ReorderPoint including the duplicates.

SELECT SUM(ReorderPoint) as WithoutDistinct
FROM Production.Product
GO

Result: 202287 rows

As you can see from the above two examples the importance of DISTINCT with an aggregate function. The user could end up un-knowingly using completely incorrect SUM had he used the result from the second query if the requirement was to get the SUM of unique values of ReorderPoint.

The purpose of the article was to show a user simple usage of DISTINCT. I hope you would find this article useful.