Saturday, February 10, 2007

SDLC (System Development Life Cycle)

SDLC is overall process of developing information systems through multi-step process systems from investigation of initial requirements through analysis, design, implementation and maintenance. The days are gone when one COBOL programmer used to analyze, test and implement software systems. Systems have become complex, huge team members are involved, architects, analyst, programmers, testers, users etc. To manage this number of SDLC models have been created.

Following are popular models which are listed:-

  • Waterfall Model.

  • Spiral Model.

  • Build and Fix model.

  • Rapid prototyping Model.

  • Incremental Model.

Water Fall Model

This is the oldest model. It has sequence of stages; output of one stage becomes input of other.

Following are stages in Waterfall model:-

  • System Requirement: This initial stage of the project where end user requirements are gathered and documented.

  • System Design: In this stage detail requirements, screen layout, business rules, process diagram, pseudo code and other documentations are prepared. This is first step in technical phase.

  • Implementation: Depending on the design document actual code is written here.

  • Integration and Testing: All pieces are brought together and tested. Bugs are removed in this phase.

  • Acceptance, Installation and Deployment: This is final stage where software is put in production and runs actual business.

  • Maintenance: This is least glamorous phase which runs forever. There is detail introduction about how to put maintenance quotation later in this book. Changes, correction, addition etc are done in this phase.

Waterfall is suited for low risk in areas of User Interface and performance requirements, but high risk in budget and schedule predictability and control. Waterfall assumes that all requirements can be specified in advance. But unfortunately requirement grows and changes through various stages, so it needs feedback from one stage to other.

Spiral Model

Spiral Model removes the drawback of waterfall model, by providing emphasis to go back and reiterate earlier stages a number of times as project progresses. On broader level it’s a series of short waterfall cycles, each producing an early prototype representing a part of entire project. It also helps demonstrate a Proof of Concept at early software life cycle.

Build and Fix Model

This is the most way freelancers work Write some code and keep modifying it until the customer is happy. This approach can be quite dangerous and risky.

Rapid Prototyping Model

This model is also called as Rapid Application Development. The initial emphasis is on creating prototype that looks and acts like the desired product. Prototype can be created by using tools which is different from those used for final product. Once the prototype is approved, its discarded and real software development is started from scratch. The problem with this model is that sometimes the prototype moves ahead to become the final live product which can be bad from design point of view. It’s a effective model but can have higher costing than other models as you require programmers during the initial phase of the software cycle.

Incremental Model

In this model we divide products in to builds, where section of product are created and tested separately. Here errors are found in requirement phase itself, user feedback is taken for each stage and code is tested after it’s written.

The main intention of introducing this section is because quotations are heavily affected by which software life cycle you follow. Because deliverables change according to SLDC model the project manager chooses for the project. Example for waterfall model we will have Requirement documents, Design documents, Source code and testing plans. But for prototyping models in addition to the documents above we will also need to deliver the rough prototype. For build and fix model we will not deliver any of the documents and the only document delivered will be source code. So according to SDLC model deliverables change and hence the quotation. This book will mainly concentrate on waterfall model and spiral model deliverables. We will divide the estimation across requirement, design, implementation (coding) and testing .In what way the estimation has to divide across all deliverables is all up to the project manager and his plans.

Adding controls to ASP.NET page at runtime

Adding controls to ASP.NET WebForm at runtime is a simple task:

private void Page_Load(object sender, System.EventArgs e)
{
Button newButton = new Button();
newButton.Text = "New Button";
newButton.ID = "newButton";
newButton.Click += new System.EventHandler(this.newButton_Click);

WebUserControl1 newUserControl = (WebUserControl1)LoadControl("WebUserControl1.ascx");
newUserControl.ID = "newUserControl";

this.PlaceHolder.Add(newUserControl);
this.PlaceHolder.Add(newButton);
}

Problem

Now let's raise a bet little. What if we want to add new control as a result of some user action (button click for example)? We are moving the same code from Page_Load to Button_Click event and… Here troubles begin. Our controls will show as expected, but only first time. Any postback will reset page to its original state. Dynamically created controls will be unable to fire any event. What is happening here? The answer is simple. Page class is stateless. It is destroyed after rendering. Page recreates child controls collection, based on tags in aspx file, then postback data can be handled and event handlers attached (in OnInit event). Controls we just created dynamically do not exist in aspx file; page has no knowledge about them.

Solution

Solution is also simple. We have to recreate controls on load stage of page lifecycle. After it's done, each control can handle his postback data, retrieve saved viewstate, raise events etc.

Now code skeleton will look like this:

private void Page_Load(object sender, System.EventArgs e)
{
RecreatePersistedControls();
}
private void Button_Click(object sender, System.EventArgs e)
{
CreateControl("newControl");
PersistControl("newControl");
}
private void RecreatePersistedControls()
{
// Call CreateControl for each persisted control
}
private void CreateControl(string id)
{
// Create controll with specified id,
// add it to controls collection, attach event handlers
}
private void PersistControl(string id)
{
// Persist specified id (in session for example)
}