Friday, 20 March 2015

Using the ROLLUP, CUBE, and GROUPING SETS Operators

What do the ROLLUP, CUBE, and GROUPING SETS operators do?  They allow you to create subtotals and grand totals a number of different ways.
The ROLLUP operator is used with the GROUP BY clause.  It is used to create subtotals and grand totals for a set of columns.  The summarized amounts are created based on the columns passed to the ROLLUP operator.
The CUBE operators, like the ROLLUP operator produces subtotals and grand totals as well.  But unlike the ROLLUP operator it produces subtotals and grand totals for every permutation of the columns provided to the CUBE operator.
Lastly the GROUPING SETS operator allows you to group your data a number of different ways in a single SELECT statement.  To better understand these three different grouping operators let’s review some examples of how they can be used.

Sample Data for Examples

Before I can show you how to use these different GROUP BY operators I first need to generate some test data that can be used for my examples.  The code below will create a sample table that I will be using for all of my examples.
SET NOCOUNT ON;
USE tempdb;
GO
CREATE TABLE PurchaseItem (
      PurchaseID smallint identity, 
      Supplier varchar(50),
      PurchaseType varchar(20), 
      PurchaseAmt money, 
      PurchaseDate date);
INSERT INTO PurchaseItem VALUES
    ('McLendon''s','Hardware',2121.09,'2014-01-12'),
      ('Bond','Electrical',12347.87,'2014-01-18'),
      ('Craftsman','Hardware',999.99,'2014-01-22'),
      ('Stanley','Hardware',6532.09,'2014-01-31'),
      ('RubberMaid','Kitchenware',3421.10,'2014-02-03'),
      ('RubberMaid','KitchenWare',1290.90,'2014-02-07'),
      ('Glidden','Paint',12987.01,'2014-02-10'),
      ('Dunn''s','Lumber',43235.67,'2014-02-21'),
      ('Maytag','Appliances',89320.19,'2014-03-10'),
      ('Amana','Appliances',53821.19,'2014-03-12'),
      ('Lumber Surplus','Lumber',3245.59,'2014-03-14'),
      ('Global Source','Outdoor',3331.59,'2014-03-19'),
      ('Scott''s','Garden',2321.01,'2014-03-21'),
      ('Platt','Electrical',3456.01,'2014-04-03'),
      ('Platt','Electrical',1253.87,'2014-04-21'),
      ('RubberMaid','Kitchenware',3332.89,'2014-04-20'),
      ('Cresent','Lighting',345.11,'2014-04-22'),
      ('Snap-on','Hardware',2347.09,'2014-05-03'),
      ('Dunn''s','Lumber',1243.78,'2014-05-08'),
      ('Maytag','Appliances',89876.90,'2014-05-10'),
      ('Parker','Paint',1231.22,'2014-05-10'),
      ('Scotts''s','Garden',3246.98,'2014-05-12'),
      ('Jasper','Outdoor',2325.98,'2014-05-14'),
      ('Global Source','Outdoor',8786.99,'2014-05-21'),
      ('Craftsman','Hardware',12341.09,'2014-05-22');
     
     
You can create this table if you want to follow along with my examples.

ROLLUP Examples

The ROLLUP operator allows SQL Server to create subtotals and grand totals, while it groups data using the GROUP BY clause.  For my first example let me use the ROLLUP operator to generator a grand total by PurchaseType by running this code:
USE tempdb;
GO
SELECT coalesce (PurchaseType,'GrandTotal') AS PurchaseType
     , Sum(PurchaseAmt) as SummorizedPurchaseAmt
FROM PurchaseItem
GROUP BY ROLLUP(PurchaseType);
When I run this code I get this output:
PurchaseType         SummorizedPurchaseAmt
-------------------- ---------------------
Appliances           233018.28
Electrical           17057.75
Garden               5567.99
Hardware             24341.35
Kitchenware          8044.89
Lighting             345.11
Lumber               47725.04
Outdoor              14444.56
Paint                14218.23
GrandTotal           364763.20
By reviewing the output above you can see that this code created subtotals for all the different PurchaseTypes and then at the end produced a GrandTotal for all the PurchaseTypes combined.   If you look at the code above, I got the PurchaseType of “Grand Total” to display by using the coalesce clause.  Without the coalesce clause the PurchaceType column value would have been “Null’ for the grand total row.
Suppose I wanted to calculate the subtotals of ProductTypes by month, with a monthly total amount for all the products sold in the month.  I could do that by running the following code:
USE tempdb;
GO
SELECT month(PurchaseDate) PurchaseMonth
     , CASE WHEN month(PurchaseDate) is null then 'Grand Total' 
                   ELSE coalesce (PurchaseType,'Monthly Total') end AS PurchaseType
     , Sum(PurchaseAmt) as SummorizedPurchaseAmt
FROM PurchaseItem
GROUP BY ROLLUP(month(PurchaseDate), PurchaseType);
 
When I run this code I get this output:
 
PurchaseMonth PurchaseType         SummorizedPurchaseAmt
------------- -------------------- ---------------------
1             Electrical           12347.87
1             Hardware             9653.17
1             Monthly Total        22001.04
2             Kitchenware          4712.00
2             Lumber               43235.67
2             Paint                12987.01
2             Monthly Total        60934.68
3             Appliances           143141.38
3             Garden               2321.01
3             Lumber               3245.59
3             Outdoor              3331.59
3             Monthly Total        152039.57
4             Electrical           4709.88
4             Kitchenware          3332.89
4             Lighting             345.11
4             Monthly Total        8387.88
5             Appliances           89876.90
5             Garden               3246.98
5             Hardware             14688.18
5             Lumber               1243.78
5             Outdoor              11112.97
5             Paint                1231.22
5             Monthly Total        121400.03
NULL          Grand Total          364763.20
 
 
Here I have included two columns in the ROLLUP clause.  The first column was the month of the purchase, and the second column is PurchaseType.  This allowed me to create the subtotals by ProductType by month, as well as Monthly Total amount at the end of every month.  Additionally this code creates a Grant Total amount of all product sales at the end.

CUBE Example

The CUBE operator allows you to summarize your data similar to the ROLLUP operator.  The only difference is the CUBE operator will summarize your data based on every permutation of the columns passed to the CUBE operator.  To demonstrate this I will run the code below:
USE tempdb;
GO
SELECT month(PurchaseDate) PurchaseMonth
     , CASE WHEN month(PurchaseDate) is null 
                  THEN coalesce ('Grand Total for ' + PurchaseType,'Grand Total')  
                ELSE coalesce (PurchaseType,'Monthly SubTotal') end AS PurchaseType
     , Sum(PurchaseAmt) as SummorizedPurchaseAmt
FROM PurchaseItem
GROUP BY CUBE(month(PurchaseDate), PurchaseType);
 
When I run this code it will generates summarized amounts for every permutation of the columns passed to the CUBE operator.  In my example I had two values pass to the CUBE operator: “month(PurchaseDate)” and “PurchaseType”.  Therefore the different permutations of summarized amounts are “PurchaseType”, “PurchaseType and month(PurchaseDate)”, and then lastly “month(PurchaseDate)”.   You can see these different summarized amounts in the output below:
PurchaseMonth PurchaseType                         SummorizedPurchaseAmt
------------- ------------------------------------ ---------------------
3             Appliances                           143141.38
5             Appliances                           89876.90
NULL          Grand Total for Appliances           233018.28
1             Electrical                           12347.87
4             Electrical                           4709.88
NULL          Grand Total for Electrical           17057.75
3             Garden                               2321.01
5             Garden                               3246.98
NULL          Grand Total for Garden               5567.99
1             Hardware                             9653.17
5             Hardware                             14688.18
NULL          Grand Total for Hardware             24341.35
2             Kitchenware                          4712.00
4             Kitchenware                          3332.89
NULL          Grand Total for Kitchenware          8044.89
4             Lighting                             345.11
NULL          Grand Total for Lighting             345.11
2             Lumber                               43235.67
3             Lumber                               3245.59
5             Lumber                               1243.78
NULL          Grand Total for Lumber               47725.04
3             Outdoor                              3331.59
5             Outdoor                              11112.97
NULL          Grand Total for Outdoor              14444.56
2             Paint                                12987.01
5             Paint                                1231.22
NULL          Grand Total for Paint                14218.23
NULL          Grand Total                          364763.20
1             Monthly SubTotal                     22001.04
2             Monthly SubTotal                     60934.68
3             Monthly SubTotal                     152039.57
4             Monthly SubTotal                     8387.88
5             Monthly SubTotal                     121400.03
 
The results above first generated the subtotals for each PurchaseType by month, followed by the Grand Total for each PurchaseType.  Once each PurchaseType is displayed by month with their Grand Total amounts this code then produces a “Grand Total” amount for all purchases.   Lastly it produces the monthly subtotals. 

GROUPING SETS Example

Sometimes you want to group your data multiple different ways.  The GROUPING SETS operator allows you to do this with a single SELECT statement, instead of multiple SELECT statements with different GROUP BY clauses union-ed together.  To demonstrate, review the code in below:
USE tempdb;
GO
SELECT month(PurchaseDate) PurchaseMonth
     , PurchaseType AS PurchaseType
     , Sum(PurchaseAmt) as SummorizedPurchaseAmt
FROM PurchaseItem
GROUP BY GROUPING SETS (month(PurchaseDate), PurchaseType);
 
When run the code above I get the following output:
PurchaseMonth PurchaseType         SummorizedPurchaseAmt
------------- -------------------- ---------------------
NULL          Appliances           233018.28
NULL          Electrical           17057.75
NULL          Garden               5567.99
NULL          Hardware             24341.35
NULL          Kitchenware          8044.89
NULL          Lighting             345.11
NULL          Lumber               47725.04
NULL          Outdoor              14444.56
NULL          Paint                14218.23
1             NULL                 22001.04
2             NULL                 60934.68
3             NULL                 152039.57
4             NULL                 8387.88
5             NULL                 121400.03
 
 
Here you can see SQL Server first groups my sample data based on the PurchaseType, then it groups the data based on purchase month.  This code is equivalent to the code below that uses two SELECT statements with the output of both statement joined using a UNION ALL clause:
USE tempdb;
GO
SELECT NULL as PurchaseMonth
     , PurchaseType
     , Sum(PurchaseAmt) as SummorizedPurchaseAmt
FROM PurchaseItem
GROUP BY PurchaseType
UNION ALL
SELECT month(PurchaseDate) AS PurchaseMonth
     , NULL as PurchaseType
     , Sum(PurchaseAmt) as SummorizedPurchaseAmt
FROM PurchaseItem
GROUP BY month(PurchaseDate)
If you run the code above you will see that that it produces the same results as the single SELECT statement with a GROUPING SETS clause.

Summary

As you can see using the ROLLUP, CUBE or GROUPING SETS clauses allow you many different ways to produce subtotal and grand total values for a set of records.  Having these different methods to create subtotals and grand totals allows you more options for how you can summarize your data with a single SELECT statement.  The next time you want to produce multiple summarized record sets try using ROLLUP, CUBE, or GROUPING SETS to obtain your summarized data.

Reset All Field using JQUERY in asp.net

  1. Take a reference of latest jQuery in your source. I am using jquery-1.10.2.js in my example.
  2. In the form tag of your Web form add your controls which you would like to use in the page.
  3. Simply Copy and Paste the below code in the script tag :

 <script type="text/javascript">
        function resetFields(form) {
            $(':input', form).each(function() {
                var type = this.type;
                var tag = this.tagName.toLowerCase(); // normalize case
                // to reset the value attr of text inputs,
                // password inputs, fileUpload and textareas
                if (type == 'text' || type == 'password' || tag == 'textarea' || type=='file')
                    this.value = "";
                // checkboxes and radios need to have their checked state cleared                
                else if (type == 'checkbox' || type == 'radio')
                    this.checked = false;
                // select elements need to have their 'selectedIndex' property set to -1
                // (this works for both single and multiple select elements)
                else if (tag == 'select')
                    this.selectedIndex = 0;
            });
        }

    </script> 

Monday, 16 March 2015

Bind Tree View in asp.net

   <asp:TreeView ID="SqlTree" OnSelectedNodeChanged="SqlTreeSelectedNodeChanged" CssClass="example2"
                                                                                Style="font-weight: bold; text-align: left;" ShowLines="true" ShowExpandCollapse="true"
                                                                                runat="server" >
                                                                                <NodeStyle Height="28px"  Width="250px"/>
                                                                            </asp:TreeView>




IN CS file


protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!Page.IsPostBack)
            {
             
                SqlTree.CollapseAll();
                FillTreeView();
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

   public void FillTreeView()
    {
        DataTable Modules = new DataTable();
        Modules = GetModuleDetails();
        SqlTree.Nodes.Clear();
        PopulateTreeNode(Modules, null, 0);
    }
    private void PopulateTreeNode(DataTable ModuleList, TreeNode parent, int parentID)
    {
        TreeNodeCollection baseNodes;
        TreeNode node;
        if (parent == null)
        {
            baseNodes = SqlTree.Nodes;
        }
        else
            baseNodes = parent.ChildNodes;
        foreach (DataRow dtRow in ModuleList.Rows)
        {
            if (int.Parse(dtRow["ChildID"].ToString()) == parentID)
            {
                node = new TreeNode();
                node.Text = dtRow["Description"].ToString();
                node.Value = dtRow["ID"].ToString();
                node.SelectAction = TreeNodeSelectAction.Select;
                baseNodes.Add(node);
                PopulateTreeNode(ModuleList, node, int.Parse(dtRow["ID"].ToString()));
            }
        }
        SqlTree.ExpandAll();
    }
 protected void SqlTreeSelectedNodeChanged(object sender, EventArgs e)
    {
        string a = SqlTree.SelectedNode.Text;
        if (a == "HPI")
      {
//Do Something
}

   
    }


 public DataTable GetModuleDetails()
    {
        DataTable dt = new DataTable();
        dt = ObjComplaint.ReadCommentTreeAll(Convert.ToInt32(DepID));
        return dt;
    }

Thursday, 19 February 2015

Crop and Upload Image with Thumbnail using jQuery and HTML5 in ASP.Net

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="http://cdn.rawgit.com/tapmodo/Jcrop/master/js/jquery.Jcrop.min.js"></script>
<script type="text/javascript">
    $(function () {
        $('#FileUpload1').change(function () {
            $('#Image1').hide();
            var reader = new FileReader();
            reader.onload = function (e) {
                $('#Image1').show();
                $('#Image1').attr("src", e.target.result);
                $('#Image1').Jcrop({
                    onChange: SetCoordinates,
                    onSelect: SetCoordinates
                });
            }
            reader.readAsDataURL($(this)[0].files[0]);
        });

        $('#btnCrop').click(function () {
            var x1 = $('#imgX1').val();
            var y1 = $('#imgY1').val();
            var width = $('#imgWidth').val();
            var height = $('#imgHeight').val();
            var canvas = $("#canvas")[0];
            var context = canvas.getContext('2d');
            var img = new Image();
            img.onload = function () {
                canvas.height = height;
                canvas.width = width;
                context.drawImage(img, x1, y1, width, height, 0, 0, width, height);
                $('#imgCropped').val(canvas.toDataURL());
                $('[id*=btnUpload]').show();
            };
            img.src = $('#Image1').attr("src");
        });
    });
    function SetCoordinates(c) {
        $('#imgX1').val(c.x);
        $('#imgY1').val(c.y);
        $('#imgWidth').val(c.w);
        $('#imgHeight').val(c.h);
        $('#btnCrop').show();
    };
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <input type="file" id="FileUpload1" accept=".jpg,.png,.gif" />
<br />
<br />
<table border="0" cellpadding="0" cellspacing="5">
    <tr>
        <td>
            <img id="Image1" src="" alt="" style="display: none" />
        </td>
        <td>
            <canvas id="canvas" height="5" width="5"></canvas>
        </td>
    </tr>
</table>
<br />
<input type="button" id="btnCrop" value="Crop" style="display: none" />
<asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="Upload" Style="display: none" />
<input type="hidden" name="imgX1" id="imgX1" />
<input type="hidden" name="imgY1" id="imgY1" />
<input type="hidden" name="imgWidth" id="imgWidth" />
<input type="hidden" name="imgHeight" id="imgHeight" />
<input type="hidden" name="imgCropped" id="imgCropped" />
    </div>
    </form>
</body>
</html>



ADD NAME SPACE

using System.IO;



 protected void Upload(object sender, EventArgs e)
    {
        string base64 = Request.Form["imgCropped"];
        byte[] bytes = Convert.FromBase64String(base64.Split(',')[1]);
        using (FileStream stream = new FileStream(Server.MapPath("~/Images/Cropped.png"), FileMode.Create))
        {
            stream.Write(bytes, 0, bytes.Length);
            stream.Flush();
        }
    }

Software/System Development Life Cycle

SDLC: System Development Life Cycle is the process of developing, implementing, and retiring information systems through a multistep process from initiation, analysis, design, implementation, and maintenance to disposal. It helps in establishing a system project plan, because it gives an overall list of processes and sub-processes required for developing a system, which means that it is a combination of various activities. In the System Analysis
and Design terminology, the system development life cycle also means software development life cycle.

OR

We can say that it is the conceptual model that describes the stages involved in an information system development project in project management.

Why SDLC is necessary?

Software Development Life Cycle (SDLC) is recognized by different website and software developers all over the world. However there's always a question of the need to implement this type of planning. We all know that SDLC could help us answer specific needs of different users. That is a given. But could that problem be answered when you are already familiar with that specific difficulty? In-house developers could even create the software on their own without consultation to users since they are also a part of the user group and has a clear understanding of what is needed. Clearly, SDLC is not needed to create software in this environment.

Various SDLC methodologies have been developed to guide the processes involved including the waterfall model (the original SDLC method), rapid application development (RAD), joint application development (JAD), the fountain model and the spiral model. 

Various System Development Life Cycle models are:
  1. Waterfall Software Development Life Cycle Model
  2. Prototyping Software Development Life Cycle Model
  3. Iterative Enhancement Model
  4. The Spiral Model
  5. Object Oriented Methodology
  6. V- Model Methodology
  7. Joint application development (JAD)
  8. Rapid application development (RAD)

From the above models first the SDLC method that describes the various phases involved in the development is the classic Waterfall model methodology which is shown below:

SDLC1.gif




SDLC2.gif





SDLC3.gif


SDLC4.gif



SDLC5.gif
SYSTEM DEVELOPMENT LIFE CYCLE:
SDLC6.gif 


Now let's discuss System Development Life Cycle with its different Phases in detail:
SDLC7.gif 


Phases:
  1. SYSTEM STUDY

    a) Preliminary System Study
    b) Feasibility Study
    c) Detailed System Study
    d) System Analysis
    e) System Design
     
    • Preliminary or General Design
    • Structured or Detailed Design
  2. CODING
  3. TESTING

    ̢ۢ Program Test
    ̢ۢ System Test
     
  4. IMPLEMENTATION
  5. MAINTAINANCE

SYSTEM STUDY:
1. Preliminary System Study: As the name says it is the first stage of a system development life cycle, a brief investigation of the system under consideration and gives a clear picture of what actually the physical system is? It involves the preparation of a 'System Proposal' which lists the Problem Definition, Objectives of the Study, Terms of reference for Study, Constraints, Expected benefits of the new system, etc. A System Analyst will prepare the proposal and cycle proceeds to the next stage. It depends on the management to accept it; they also reject it or request some modifications in the proposal. Actually a system study phase passes through the following steps:
  • Problem identification and project initiation
  • Background analysis
  • Inference or findings (system proposal)

2. Feasibility Study: If the proposal is accepted by the management then the next phase is to examine the feasibility of the system. In this phase the software analysts and strategy makers establish a descriptive view of the intended project and determine its goals & objectives. If the project is to proceed, the feasibility study will produce a project plan and budget estimates for the future stages of development. The main goal of feasibility study is not to solve the problem but to achieve the scope. In the process of feasibility study, the cost and benefits are estimated with greater accuracy to find the Return on Investment (ROI).

3. Detailed System Study: In accordance with the objectives of the proposed system the detailed investigation of the system is carried out. Various operations performed by a system and their relationships within and outside the system. In this process data are collected on the available files, decision points and transactions handled by the present system. It becomes easy to draw the exact boundary of the new system under consideration by following the steps below:
  • Keeping in view the problems and new requirements
  • Workout the pros and cons including new areas of the system

There should be proper documentation of all the data and the findings in the form of
detailed data flow diagrams (DFDs), data dictionary, logical data structures and miniature specification. The important points that should be discussed in this stage are:
  • Specification of what the new system is to accomplish based on the user requirements.
  • Functional hierarchy showing the functions to be performed by the new system and their relationship with each other.
  • Functional network, which are similar to function hierarchy but they highlight the functions which are common to more than one procedure.
  • List of attributes of the entities – these are the data items which need to be held about each entity (record).

4. System Analysis: In this phase there is a main role of system analyst, he is the one who should analyze the end-user information needs and prepare a solid plan. Analysis gathers the requirements for the system. This stage includes a detailed study of the business needs of the organization. Options for changing the business process may be considered. In other words it is a process of collecting factual data, understand the processes involved, identifying problems and recommending feasible suggestions for improving the system functioning. It also includes subdividing of complex process involving the entire system, identification of data store and manual processes. The major objectives of systems analysis are to find answers for each business process: What is being done? How is it being done? Who is doing it? When is he doing it? Why is it being done? and How can it be improved? It is more of a thinking process and involves the creative skills of the System Analyst.

5. System Design: System Design is the most crucial phase in the development of System Software. After the detailed analysis of the existing system and requirement of the user, the new system must be designed, that's why the name of this phase is "System Design". The logical system design arrived at as a result of systems analysis is converted into physical system design. Normally, the design proceeds in two stages:
  • Preliminary or General Design
  • Structured or Detailed Design

a. Preliminary or General Design: The specification of the features of the new system and the cost estimation in implementing these features of the system are estimated in this stage. And if the project is still considered to be feasible, we move to the detailed design stage.

b. Structured or Detailed Design: The design of the system becomes more structured at this stage. Structured design is a blueprint of a computer system solution to a given problem having the same components and inter-relationships among the same components as the original problem. Input, output, databases, forms, codification schemes and processing specifications are drawn up in detail.
In the design stage, the programming language and the hardware and software platform in which the new system will run are also decided.

The various tools and techniques used to describe the system design are:
  • Flowchart
  • Data flow diagram (DFD)
  • Data dictionary
  • Structured English
  • Decision table
  • Decision tree

The System design involves the following steps:
  1. Defining precisely the required system output
  2. Determining the data requirement for producing the output
  3. Determining the medium and format of files and databases
  4. Devising processing methods and use of software to produce output
  5. Determine the methods of data capture and data input
  6. Designing Input forms
  7. Designing Codification Schemes
  8. Detailed manual procedures
  9. Documenting the Design

CODING

The system design needs to be implemented to make it a workable system which means that once the design is complete, this demands the coding of design into computer understandable language i.e. programming language, that's why this phase is also known as a programming phase. The goal of the coding phase is to translate the design of the system into code in a given programming language. For a given design, the aim of this phase is to implement the design in the best possible manner. The coding phase affects both testing and maintenance profoundly. A well written code reduces the testing and maintenance effort. As the cost of testing and maintenance is much higher than the coding cost, the goal of coding should be to reduce the testing and maintenance effort. Hence, during coding the focus should be on developing programs that are easy to write. Simplicity and clarity should be strived for, during the coding phase. It is an important stage where the defined procedures are transformed into control specifications by the help of a computer language. It is generally felt that the programs must be modular in nature. This helps in fast development, maintenance and future changes, if required.

TESTING

The main thrust of the approach is to intensively test the front end in the first two releases, thus raising approximately 80% of errors in this period. Software testing is a process of verifying and validating that a software application or program meets the business and technical requirements that guided its design and development, and works as expected.

Formal review points in testing:

SDLC8.gif

The diagram above outlines the Test Approach. Boxes 1 - 6 show the major review stages prior to Test execution. Boxes 7 - 10 show the phases planned for & after test execution.

It is an important phase of a successful system. After codifying the whole programs of the system, a test plan should be developed and run on a given set of test data. The output of the test run should match the expected results. Using the test data following test run are carried out:
  • Program Test
  • System Test

Program Test: In program test the programs must be individually tested with the prepared test data at the time of coding, compiling and brought to working conditions. Any undesirable happening must be noted and debugged (error corrections).

System Test: After the program test for each program of the system, and also the errors are removed then its turn for System test. In this the test is done on actual data. The complete system is executed on the actual data. At each stage of the execution, the results or output of the system is analyzed. At the time of result analysis, it may be found that the outputs are not matching the expected output of the system. In such case, the errors in the particular programs are identified and are fixed and further tested for the expected output.

IMPLEMENTATION

After having the user acceptance of the new system developed, the Implementation Phase begins. In the implementation phase, the organization configures and enables system security features, tests the functionality of these features, installs or implements the system, and obtains a formal authorization to operate the system. Design reviews and system tests should be performed before placing the system into operation to ensure that it meets all required security specifications. In addition, if new controls are added to the application or the support system, additional acceptance tests of those new controls must be performed. This approach ensures that new controls meet security specifications and do not conflict with or invalidate existing controls. The results of the design reviews and system tests should be fully documented, updated as new reviews or tests are performed, and maintained in the organization's official records.

The major steps involved in this phase are:
  • Acquisition and Installation of Hardware and Software
  • Conversion
  • User Training
  • Documentation

During this phase, all the programs of the system are loaded onto the user's computer. After loading the system, training of the user starts. Main topics of such type of training are:
  • How to execute the package
  • How to enter the data
  • How to process the data (processing details)
  • How to take out the reports

After the users are trained about the computerized system, working has to shift from manual to computerized working. The process is called 'Changeover'. The following strategies are followed for changeover of the system:
  • Direct Changeover
  • Parallel Run
  • Pilot Run

MAINTENANCE

It is the least glamorous and perhaps most important step of all, goes forever during whole system life. Inevitably the system will need maintenance. Software will definitely undergo change once it is delivered to the customer. There are many reasons for the change. Change could happen because of some unexpected input values into the system. In addition, the changes in the system could directly affect the software operations. The software should be developed to accommodate changes that could happen during the post implementation period. Maintenance is necessary to eliminate errors in the system during its working life and to tune the system to any variations in its working environments. It has been seen that there are always some errors found in the systems that must be noted and corrected. It also means the review of the system from time to time. The review of the system is done for:
  • Knowing the full capabilities of the system
  • Knowing the required changes or the additional requirements
  • Studying the performance.

If a major change to a system is needed, a new project may have to be set up to carry out the change. The new project will then proceed through all the above life cycle phases.

Tuesday, 17 February 2015

Interview Phase

Last week I attended an interview with Infosys, Chennai. When I entered the compound, there were very many candidates. The atmosphere and culture in Infosys was very nice.
Please find the original article here :

Background
I have attended many interviews in my life. But the interview with Infosys was something different. I thought to share that experience with you all.

Points to be remember (There are some mistakes I made in the interview. I don't want you to do the same :) )
  1. Please ensure that you are maintaining eye contact with the interviewer.
  2. Be confident of what you say. Don't change your answer if the interviewer tries to make you do so.
  3. Please avoid the unwanted examples.
  4. Please never use any other technical terms that may provoke the interviewer into asking questions about.
  5. If you don't know the answer, please say "I don't know". It is always better to say so instead of going with the wrong answer.


Questions asked and answers 

(Here I am giving the answers that I answered .)

1. Tell me about yourself?

A. You can find many answers to this question in the internet. Please see the following link:


2. What is your role in your project? What is the team size?

A. I said "My main role is coding, unit testing, big fixing and maintenance. My team size is 7".

3. What is the hierarchy of your team?

A. First I was confused by this question. Then I answered "Project Manager, Team Leader, Software Engineers, Trainees".

4. Describe the projects that you have worked on?

A. I described them. Please include the technologies you used in your projects and what kind of architecture (for example: 3-tire, n- tier) you used.

5. What is the employee size in your company? You don't need to be accurate. You can provide the approximate value.

A. I said "150 to 200".

Then he moved to the programming section.

6. Write an algorithm and program to determine whether or not a word is a palindrome.

We can do it in either of the following two ways:

a) Using a built-in function as in the following:
  1. string strRev,strReal = null;  
  2. Console.WriteLine("Enter the string..");  
  3. strReal = Console.ReadLine();  
  4. char[] tmpChar = strReal.ToCharArray();  
  5. Array.Reverse(tmpChar);  
  6. strRev=new string(tmpChar);  
  7. if(strReal.Equals(strRev, StringComparison.OrdinalIgnoreCase))  
  8. {  
  9.     Console.WriteLine("The string is pallindrome");  
  10. }  
  11. else  
  12. {  
  13.     Console.WriteLine("The string is not pallindrome");  
  14. }  
  15.     Console.ReadLine();  


b) Without using a built-in function.

When I wrote the first program, the interviewer asked me to write the same without using a built-in function.
  1. private static bool chkPallindrome(string strVal)  
  2.        {  
  3.            try  
  4.            {  
  5.                int min = 0;  
  6.                int max = strVal.Length - 1;  
  7.                while (true)  
  8.                {  
  9.                    if (min > max)  
  10.                        return true;  
  11.                    char minChar = strVal[min];  
  12.                    char maxChar = strVal[max];  
  13.                    if (char.ToLower(minChar) != char.ToLower(maxChar))  
  14.                    {  
  15.                        return false;  
  16.                    }  
  17.                    min++;  
  18.                    max--;  
  19.                }  
  20.            }  
  21.            catch (Exception)  
  22.            {  
  23.                  
  24.                throw;  
  25.            }  
  26.        }  
7. Write a program to determine the count of a specific character in a string.

A.
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Text;  
  5.   
  6. namespace FindCountCharOccurance  
  7. {  
  8.     class Program  
  9.     {  
  10.         static void Main(string[] args)  
  11.         {  
  12.             string strOccur,strChar = null;  
  13.             Console.WriteLine("Enter the string in which you need to find the count of a char occurance");  
  14.             strOccur = Console.ReadLine();  
  15.               
  16.             Console.WriteLine("Enter the char to be searched..");  
  17.             strChar = Console.ReadLine();  
  18.             int intCnt =strOccur.Length- strOccur.Replace(strChar, string.Empty).Length;  
  19.             Console.WriteLine("Count of occurance is "+intCnt);  
  20.             Console.ReadLine();  
  21.         }  
  22.     }  
  23. }  

8. Next he gave me a program like the following and asked me what the output of this will be.
  1. public class A  
  2.     {  
  3.         public int A()  
  4.         {  
  5.             Console.WriteLine("Hi you are in class A");  
  6.         }  
  7.     }  
A. I said "Here we have a constructor A; a constructor should not have a return type. So the code above will throw a compilation error."

9. What may be the output of the following program?
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Text;  
  5.   
  6. namespace RefClass  
  7. {  
  8.     class Program  
  9.     {  
  10.         static void Main(string[] args)  
  11.         {  
  12.             B bObj= new B();  
  13.             Console.ReadLine();  
  14.   
  15.         }  
  16.     }  
  17.     public class A  
  18.     {  
  19.         public  A()  
  20.         {  
  21.             Console.WriteLine("Hi you are in class A");  
  22.         }  
  23.     }  
  24.   
  25.     public class B:A  
  26.     {  
  27.         public B()  
  28.         {  
  29.             Console.WriteLine("Hi you are in class B");  
  30.         }  
  31.     }  
  32. }  
A. I said the output will be:

Hi you are in class A

Hi you are in class B

Even though you are creating an object of the derived class, it will invoke the base class first.

10. Write the output of the following program.
  1. class Program  
  2.     {  
  3.         static void Main(string[] args)  
  4.         {  
  5.             B bObj= new B(2);  
  6.             Console.ReadLine();  
  7.   
  8.         }  
  9.     }  
  10.     public class A  
  11.     {  
  12.         public  A()  
  13.         {  
  14.             Console.WriteLine("Hi you are in class A");  
  15.         }  
  16.   
  17.         public A(int x)  
  18.         {  
  19.               
  20.         }  
  21.     }  
  22.   
  23.     public class B:A  
  24.     {  
  25.         public B()  
  26.         {  
  27.             Console.WriteLine("Hi you are in class B");  
  28.         }  
  29.     }  
A. It will throw a compilation error.

B does not contain a constructor that takes 1 argument. If you want to make this program run, you must create a parameterized constructor for class B also.

11. Abstract and interface real time examples

B.Please read it here: Real time example of interface

12. Describe authentication, types, differences?

A. Forms, Windows, Passport. Please read more here: ASP.NET authentication and authorization
13. Why DBMS? Why don't we save data in separate files?

A. I didn't know what exactly he meant, I got stuck there for a while. Finally I came up with the answer that "Normalization" is the main advantage of a DBMS.

Read more here: Why use a DBMS?

14. What is the differences between a Primary key and a Unique key?

A. Primary key doesn't allow NULL, a unique key does.

15. What exactly is happening when we make a field a primary key?

A. A clustered index will be created for that specific field.

16. How may clustered index we can create in table?

A. Basically we can create only one clustered index, but there is a way to have more. Please read here: Only one clustered index can be created on table <Tablename>. (Visual Database Tools)

17. What is the difference between a clustered and a non-clustered index?

A. I explained, please read here: Clustered and Non-Clustered Index in SQL 2005

18. What is a Distributed System?

A. A collection of autonomous computers.
19. What will be the output for the below mentioned lines in JQuery?
     
  1. alert('5' + 5 + 5);  
  2. alert(5 + 5 + '5');  
  3. alert(5 + '5' + '5');  
  4. alert(5 + '5' );  
That was little tricky at that time. For a while I thought, and I just wrote the question to a paper, and replied.       
  1. alert('5' + 5 + 5);    Output= 555  
  2. alert(5 + 5 + '5');    Output=105  
  3. alert(5 + '5' + '5');  Output=555  
  4. alert(5 + '5' );       Output=55  
Hmmm finally he said "You are selected for the next round" :)

Next was the direct HR round. That was a simple round. He just asked me to fill in some forms.