Wednesday, 28 August 2013

Enumerations


C# provides all the data types that are available in Java, and adds support for unsigned numerals and a new 128-bit high-precision floating-point type.
For each primitive data type in Java, the core class library provides a wrapper class that represents it as a Java object. For example, the Int32 class wraps theint data type, and the Double class wraps the double data type.
On the other hand, all primitive data types in C# are objects in the System namespace. For each data type, a short name, or alias, is provided. For instance,int is the short name for System.Int32 and double is the short form of System.Double.
The list of C# data types and their aliases is provided in the following table. As you can see, the first eight of these correspond to the primitive types available in Java. Note, however, that Java's boolean is called bool in C#.
Short Name
.NET Class
Type
Width
Range (bits)
byte
Unsigned integer
8
0 to 255
sbyte
Signed integer
8
-128 to 127
int
Signed integer
32
-2,147,483,648 to 2,147,483,647
uint
Unsigned integer
32
0 to 4294967295
short
Signed integer
16
-32,768 to 32,767
ushort
Unsigned integer
16
0 to 65535
long
Signed integer
64
-9223372036854775808 to 9223372036854775807
ulong
Unsigned integer
64
0 to 18446744073709551615
float
Single-precision floating point type
32
-3.402823e38 to 3.402823e38
double
Double-precision floating point type
64
-1.79769313486232e308 to 1.79769313486232e308
char
A single Unicode character
16
Unicode symbols used in text
bool
Logical Boolean type
8
True or false
object
Base type of all other types
string
A sequence of characters
decimal
Precise fractional or integral type that can represent decimal numbers with 29 significant digits
128
±1.0 × 10e−28 to ±7.9 × 10e28
Because C# represents all primitive data types as objects, it is possible to call an object method on a primitive data type. For example:
static void Main()
{
    int i = 10;
    object o = i;
    System.Console.WriteLine(o.ToString());
}    
This is achieved with the help of automatic boxing and unboxing. For more information, see Boxing and Unboxing (C# Programming Guide).
Both Java and C# provide the ability to declare a variable whose value is specified at compile time and cannot be changed at runtime. Java uses the final field modifier to declare such a variable, while C# uses the const keyword. In addition to const, C# provides the readonly keyword to declare variables that can be assigned a value once at runtime--either in the declaration statement or else in the constructor. After initialization, the value of a readonly variable cannot change. One scenario in which readonly variables are useful is when modules that have been compiled separately need to share data such as a version number. If module A is updated and recompiled with a new version number, module B can be initialized with that new constant value without having to be recompiled.
Enumerations, or enums, are used to group named constants similar to how they are used in C and C++; they are available in Java beginning in Version 1.5. In C#, enums are value types, and enum constants must be integral numeric values. The ToString method can be used to print out string representations of the named constants. The following example defines a simple Color enumeration in C#.
public enum Color
{
    Green,   //defaults to 0
    Orange,  //defaults to 1
    Red,     //defaults to 2
    Blue     //defaults to 3
}  
Integral values can also be assigned to enumerations as shown in the following enum declaration:
public enum Color2
{
    Green = 10,
    Orange = 20,
    Red = 30,
    Blue = 40
}
The following code example calls the GetNames method of the Enum type to display the available constants for an enumeration. It then assigns a value to an enumeration and displays the value.
class TestEnums
{
    static void Main()
    {
        System.Console.WriteLine("Possible color choices: ");

        //Enum.GetNames returns a string array of named constants for the enum. 
        foreach(string s in System.Enum.GetNames(typeof(Color)))
        {
            System.Console.WriteLine(s);
        }

        Color favorite = Color.Blue;

        System.Console.WriteLine("Favorite Color is {0}", favorite);
        System.Console.WriteLine("Favorite Color value is {0}", (int) favorite);
    }
}
Beginning in C# 3.0, enumerations can be extended with user-defined extension methods. For more information, see How to: Create a New Method for an Enumeration (C# Programming Guide).
Possible color choices:
Green
Orange
Red
Blue
Favorite Color is Blue
Favorite Color value is 3

Agile Methodology

Introduction

Waterfall model follows application development in phases with checkpoint and deliverable documents in each checkpoint. It advocates rigours project management, strategy and processes to track the status. The main drawback is that it requires more than 80% project understanding before kicking off the project which is impossible in major cases. Cause of volatile requirements and understanding business feels, 80% of software projects using this methodologyfail to meet their objectives.

Typical Waterfall Model

Waterfall model

Agile Methodology

Agile mythology has small box iterations rather than phases. The output of each iteration will be production release deliverable and could be evaluated and get early feedback.
Agile was a significant departure from the heavyweight document-driven software development methodologies—such as waterfall—in general use at the time.
Agile refers to more collaboration and interaction between different departments at enterprise level and delivers the successful product with individual contribution.
Agile methodologies embrace iterations. Small teams work together with stakeholders to define quick prototypes, proof of concepts, or other visual means to describe the problem to be solved. The team defines the requirements for the iteration, develops the code, and defines and runs integrated test scripts, and the users verify the results. Verification occurs much earlier in the development process than it would with waterfall, allowing stakeholders to fine-tune requirements while they’re still relatively easy to change.
It promotes adaptive planning, evolutionary development & delivery, a time-boxed iterative approach, and encourages rapid and flexible response to change.
Agile Model

XP (Extreme Programming)

It advocates frequent “release” in short development cycles, each release follows with several iterations. When the product release has enough features to satisfy the user, the team terminates iteration cycle and releases the software.
Other elements of Extreme Programming include: programming in pairs, continuous integration, add only needed features for a particular release.
Users write a story which helps the team to estimate the time to build the release and to define acceptance testing. A user is a part of XP team and adds the detail requirement as the software is being built. This allows requirements to evolve as both users and developers define what the product will look like.
  • Continuous Integration: Integrate often at least once a day using automated continuous integration tool
  • Pair Programming: Pair programing to extensively code review while coding
  • Project velocity: Velocity is a measure of how much work is getting done on the project. This important metric drives release planning and schedule updates.

Scrum

Scrum is a way for teams to work together to develop a product wherein requirement changes rapidly during development. Product development, using Scrum, occurs in small pieces, with each piece building upon previously created pieces. Building products one small piece at a time encourages creativity and enables teams to respond to feedback and change, to build exactly and only what is needed. Unlike XP, Scrum methodology includes both managerial and development processes.
  • Sprints: Short development process
  • Stand up meeting: Daily 10 minutes meeting status of the work to be done that day, progress from the day before, and any blocks that must be cleared
  • Scrum Master: The ScrumMaster is the person responsible for managing the Scrum project
  • Sprint backlog: Sprint backlog is the list of backlog items assigned to a sprint, but not yet completed.
  • Burndown chart: This chart, updated every day, shows the work remaining within the sprint. The burn down chart is used both to track sprint progress and to decide when items must be removed from the sprint backlog and deferred to the next sprint.
  • Product backlog: Product backlog is the complete list of requirements

References