Thứ Tư, 5 tháng 6, 2013

What is the exact definition of "Software Specification"?


A software requirements specification (SRS) is a comprehensive description of the intended purpose and environment for software under development. The SRS fully describes what the software will do and how it will be expected to perform.

- A specification describes WHAT a program does, a design describes HOW the program does it, and documentation describes WHY it does it
- A specification is a document which forms a contract between the customer and the designer.
- A specification is a document by which we can judge the correctness of an implementation.


An SRS minimizes the time and effort required by developers to achieve desired goals and also minimizes the development cost. A good SRS defines how an application will interact with system hardware, other programs and human users in a wide variety of real-world situations. Parameters such as operating speed, response time, availability, portability, maintainability, footprint, security and speed of recovery from adverse events are evaluated. Methods of defining an SRS are described by the IEEE (Institute of Electrical and Electronics Engineers) specification 830-1998.


A specification is a precise, unambiguous and complete statement of the requirements of a system (or program or process), written in such a way that it can be used to predict how the system will behave.

Thứ Hai, 18 tháng 3, 2013

What is the difference between GetPostBackEventReference and GetPostBackClientHyperlink?

GetPostBackEventReference is used to raise postback from a control which has OnClick event associated with it. Meanwhile, GetPostBackClientHyperlink is used to raise post back from a  control without OnClick event associated with it, such as HyperLink...

The following code example demonstrates the difference between GetPostBackEventReference and  GetPostBackClientHyperlink method.

<%@ Page Language="C#"  %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  public class MyControl : Label, IPostBackEventHandler
  {

    // Use the constructor to defined default label text.
    public MyControl()
    {
      base.Text = "No postback raised.";
    }

    // Implement the RaisePostBackEvent method from the
    // IPostBackEventHandler interface. 
    public void RaisePostBackEvent(string eventArgument)
    {
      base.Text = "Postback handled by " + this.ID.ToString() + ". <br/>" +
                  "Postback caused by " + eventArgument.ToString() + ".";

    }
  }

  protected void Page_Load(object sender, EventArgs e)
  {
    // Get a ClientScriptManager reference from the Page class.
    ClientScriptManager cs = Page.ClientScript;

    // Create an instance of the custom label control and 
    // add it to the page.
    MyControl mycontrol = new MyControl();
    mycontrol.ID = "mycontrol1";
    PlaceHolder1.Controls.Add(mycontrol);
    PlaceHolder1.Controls.Add(new LiteralControl("<br/>"));

    // Create a button element with its onClick attribute defined
    // to create a postback event reference to the custom label control.
    HtmlInputButton b = new HtmlInputButton();
    b.ID = "mybutton1";
    b.Value = "Click";
    b.Attributes.Add("onclick", cs.GetPostBackEventReference(mycontrol, b.ID.ToString()));
    PlaceHolder1.Controls.Add(b);
    PlaceHolder1.Controls.Add(new LiteralControl("<br/>"));

    // Create a link element with its href attribute defined
    // to create a postback event reference to the custom label control.
    HtmlAnchor a = new HtmlAnchor();
    a.ID = "myanchor1";
    a.InnerText = "link";
    a.HRef = cs.GetPostBackClientHyperlink(mycontrol, a.ID.ToString());
    PlaceHolder1.Controls.Add(a);
  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ClientScriptManager Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:PlaceHolder id="PlaceHolder1" 
                       runat="server">
      </asp:PlaceHolder>
    </div>
    </form>
</body>
</html>

Thứ Hai, 11 tháng 3, 2013

Resolve problem of SimpleModal not being displayed when adding ScriptManager on the page

I came across the plug-in called "SimpleModal" that was developed by plasm in Mootools. You can read more and run the demo on http://simplemodal.plasm.it



This modal works great. However, SimpleModal doesn't work if there is ScriptManager on the page. I'm disappointed a bit because most of ASP.NET pages need ScriptManager to handle the Postback. After searching around for solutions but getting no luck. There seems to be no answers on Internet. I decided to investigate what the cause might be. Accidentally, I found a workaround. It's quite simple. I tried to do something with ScriptManager by going through all of its attributes. And here is the idea:

Workaround: Assign a value to ScriptPath. It could be any value, as long as it's not empty. See the highlighted section below:
<asp:ScriptManager ID="ScriptManager1" runat="server" ScriptPath="MyCustomScriptPath">
</asp:ScriptManager>

Now please compare the source view before and after adding ScriptPath. Use the online tool (http://www.diffnow.com/) to see the difference.

In below screen (click to room in), the left half represents the source that causes SimpleModal problem and the right half represents the changes (ScriptPath):


Now. It works pretty good. At least, I can use SimpleModal for many ASP.NET pages in my projects. For complicated pages, I'm not sure if there are any other conflicts :-) Then, I'll go about resolving it once I encounter these.

You can download the modified demo code at: SimpleModal

That's it. I'm so relieved!
Please share with me on my blogs if you have any finding with this plug-in.


Thứ Ba, 27 tháng 11, 2012

How to show/hide Grid columns on the fly?

The solution is simple, but quite elaborate to make it work. Here's the complete example using JQuery. You can customize your own way.

First, reference JQuery and create the dynamic list of column names. Then design a checkbox accordingly and hook up onclick event for each:
  
   <script type="text/javascript" src="JS/jquery-1.3.js"></script>  
   <script type="text/javascript" language="javascript">
    $(document).ready(function() {
        $("#tblExample th").each(function() {
            var iIndex = $(this).closest("th").prevAll("th").length;
            var colName = $(this).html();
           
            $("#divColumns")
                .append(
                    $(document.createElement("input")).attr({
                         id:    iIndex
                        ,name:    iIndex
                        ,value:    colName
                        ,type:    'checkbox'
                        ,checked:true
                    })
                    .click( function( event )
                    {
                        var cbox = $(this)[0];
                        ShowHideColumn(cbox.id, !cbox.checked);
                    } )
                )
                .append(
                    $(document.createElement('label')).attr({
                        'for':    iIndex
                    })
                    .text( colName )
                ).
                append("&nbsp;&nbsp;&nbsp;");
        });

        $("#tblExample th").click(function() {
           var iIndex = $(this).closest("th").prevAll("th").length;
           ShowHideColumn(iIndex, true);
        });
       
        function ShowHideColumn(iIndex, isHide)
        {
           try{
               var display = "table-cell";
               if(isHide == true) display = "none";
              
               $("#tblExample").find("tr").each(function() {
                  $(this).find("td:eq(" + iIndex + ")").css("display", display);
                  $(this).find("th:eq(" + iIndex + ")").css("display", display);
               });
           }
           catch(e) { alert(e);}
        }
       
        $("#tblExample th").mouseover(function() {
            $(this).css('cursor','pointer');
        });
    });
    </script>

And here is the implementation of HTML markups in body section:
        <div id="divColumns">
        Put a yes/no check on each column name below to show/hide column correspondingly:<br />
        </div>
        <br />
        Or you can click on header to hide the column at once:<br />
        <table id="tblExample" cellpadding="0" cellspacing="0" border="1" style="border:solid 1px gray;">
            <thead>
                <tr style="background-color:Gray;">
                    <th>ID</th>
                    <th>Name</th>
                    <th>Age</th>
                </tr>
            </thead>
            <tbody>
                <tr><td>0001</td><td>Henry</td><td>35</td></tr>
                <tr><td>0002</td><td>Lucky Luke</td><td>33</td></tr>
                <tr><td>0003</td><td>Winly</td><td>30</td></tr>
            </tbody>
        </table>

RESULTS:

 Try to uncheck the "Age" checkbox and see how it works. Here's the result:









Happy coding,

Thứ Tư, 21 tháng 11, 2012

6 Key Points for a good IT management job

I've been working with IT management jobs for more than 5 years. I wanna share with you 6 key points which will make your job more fruitful. That is: Job Description, Diversity, Inspiration/Motivation, Rational Schedule, End-to-end Approach and Pecking Order.


1)   Job Description: Clearly-defined Job Description is the key. Develop well-defined standards and clear evaluation criteria in the first place, or as early as possible so employees can gauge their success and we don’t have to remedy the situation at some point in the future.

2)    Diversity: Value diversity in the team. Someone might not smart but work hard, then it has compensations. Think about giving detailed tasks to people who are big-picture oriented or assigned jobs that required toughness to people who are essentially very harmonious in nature. Either way doesn't work. So build on strengths, and to compensate for weaknesses. It’s a trade-off in the team. Remember: “The whole is greater than the sum of its parts”.

3)    Inspiration/Motivation: Inspire team members to grow their skills and develop on the team. Annually, each team member is forced to learn something new and share with others (seminar, forum...). Lack of training kills productivity in the long run.

4)    Rational Schedule: Ensure appropriate schedule for different teams and persons. Tightening schedule kills the creativity and quality in the long run. But loosen schedule causes diminishing focus. Has a balanced development process; are not too gentle or too hasty in software making process. In short, keep in minds 2 important laws:
  • Parkinson's Law: Work expands so as to fill the time available for its completion. (Công việc lúc nào cũng phình ra để lấp đầy thời gian cho phép)
  • Pareto law 80 20 principle.
5)    End-to-end Approach: The work speed, productivity is pretty much same no matter it is just the right begining of project life cycle or going down to the wire (không có giới hạn khoảng cách giữa các điểm khác nhau. Tốc độ làm việc, hiệu quả đều giống nhau cho dù đó là thời điểm bắt đầu hay cuối dự án). The key thing in this approach is "Bring development processes closer to the customers". Have the customer actively participate in the design and offer feedback throughout the development process. This allows both the team and customer to better align their expectations and needs.

6)    Pecking Order: Exercising authority in the team is a indispensable measure to minimize negative conflict and make sure that “running scared” is a good thing to steer the team on the right track.

Thứ Năm, 1 tháng 11, 2012

What is the difference between decodeURIComponent and decodeURI?

Sometimes, we post the request (search for instance) with the value of parameter ("keyword" for instance) passing on the URI, like below:

var uri="http://www.myweb.com/search.asp?keyword=lập trình C++&includecomment=true";
If keyword parameter contains the special characters like , / ? : @ & = + $ #..., the URI will be parsed incorrectly. So we have to encode the parameter.

Examples:
alert(encodeURI('lập trình C++')); ==> Return: l%E1%BA%ADp%20tr%C3%ACnh%20C++

alert(encodeURIComponent('lập trình C++')); ==> Return:l%E1%BA%ADp%20tr%C3%ACnh%20C%2B%2B 

alert(encodeURI('http://www.myweb.com/search.asp?keyword=lập trình C++&includecomment=true')); ==> Return: http://www.myweb.com/search.asp?keyword=l%E1%BA%ADp%20tr%C3%ACnh%20C++&includecomment=true

alert(encodeURIComponent('http://www.myweb.com/search.asp?keyword=lập trình C++&includecomment=true')); ==> Return: http%3A%2F%2Fwww.myweb.com%2Fsearch.asp%3Fkeyword%3Dl%E1%BA%ADp%20tr%C3%ACnh%20C%2B%2B%26includecomment%3Dtrue

From MSDN JScript Reference:
The encodeURI method returns an encoded URI. If you pass the result to decodeURI, the original string is returned. The encodeURI method does not encode the following characters: ":", "/", ";", and "?". Use encodeURIComponent to encode these characters.

EncodeURI
, sometimes called fixBrokenURI or produces a "safe" URI by encoding invalid characters such as spaces and some other (e.g. nonprintable), and turns it into a real URI. It has a valid use in fixing up invalid URIs from user input, and it can also be used to turn an IRI (URI with bare Unicode characters in) into a plain URI (using %-escaped UTF-8 to encode the non-ASCII).

EncodeURIComponent
encodes the colon and slash and plus characters, and is meant to be used in query strings. The encoding of + and ? and & is of particular importance here, as these are special chars in query strings.

Now you know the real difference between EncodeURI() and EncodeURIComponent().
Converserly, DecodeURI() and DecodeURIComponent() is provided to be an inverse of EncodeURI and EncodeURIComponent.

And here the real Web example:

<input type="text" name="keyword" id="keyword" value="<%=Server.HtmlEncode(Request.QueryString["keyword"]) %>" onkeypress="if(event.keyCode==13) SearchPage()" />
document.write(encodeURIComponent(uri));
  

Happy Coding, 

Thứ Tư, 24 tháng 10, 2012

What is a Fact table?

A fact table is the central table in a star schema that contains “facts”. A fact table stores quantitative information for analysis and is often denormalized.

A fact table works with dimension tables. Thus, the fact table consists of two types of columns. The foreign keys column allows joins with dimension tables, and the measures columns contain the data that is being analyzed. The primary key of a fact table is usually a composite key that is made up of all of its foreign keys.

A fact table might contain either detail level facts or facts that have been aggregated (fact tables that contain aggregated facts are often instead called summary tables). A fact table usually contains facts with the same level of aggregation



Types of fact tables:
There are basically three fundamental measurement events, which characterizes all fact tables.[2]
  1. TransactionalA transactional table is the most basic and fundamental. The grain associated with a transactional fact table is usually specified as "one row per line in a transaction", e.g., every line on a receipt. Typically a transactional fact table holds data of the most detailed level, causing it to have a great number of dimensions associated with it.
  2. Periodic snapshots
    The periodic snapshot, as the name implies, takes a "picture of the moment", where the moment could be any defined period of time, e.g. a performance summary of a salesman over the previous month. A periodic snapshot table is dependent on the transactional table, as it needs the detailed data held in the transactional fact table in order to deliver the chosen performance output. 
  3. Accumulating snapshots
    This type of fact table is used to show the activity of a process that has a well-defined beginning and end, e.g., the processing of an order. An order moves through specific steps until it is fully processed. As steps towards fulfilling the order are completed, the associated row in the fact table is updated. An accumulating snapshot table often has multiple date columns, each representing a milestone in the process. Therefore, it's important to have an entry in the associated date dimension that represents an unknown date, as many of the milestone dates are unknown at the time of the creation of the row.

The following diagrams provide an overview of the fact tables in the Team System data warehouse and the dimensions tables they have in common: