Recent Updates Toggle Comment Threads | Keyboard Shortcuts

  • aftab 4:01 am on June 5, 2009 Permalink | Reply
    Tags: planix, planning poker, , software estimation, tagets   

    An Interesting Discussion on Software Estimation 

    Scott Hanselman has an interesting discussion on the ever elusive mirage of accurate software esitmation here.

    It also points to a number of software estimation techniques like Wideband Delphi, Proxy etc along with softwares that can help you with the estimation, like Planix, planningpoker, Steve McConnel’s Construx Estimate and SpreadsheetGear.

    The post is very accurately titled as Software Estimation: Remember that Targets are not Estimates.

    I liked the quote from Steve McConnel’s Book, Software Estimation: Demystifying the Black Art:

    Considering that optimism is a near-universal fact of human nature, software estimates are often undermined by what I think of as a Collusion of Optimists. Developers present estimates that are optimistic. Executives like the optimistic estimates because they imply that desirable business targets are achievable. Managers like the estimates because they imply that they can support upper management’s objectives. And so the software project is off and running with no one ever taking a critical look at whether the estimates were well founded in the first place.

    This post is a nice reminder that, Targets are not estimates.

    Happy Programming!

     
  • aftab 11:58 pm on June 4, 2009 Permalink | Reply
    Tags: Agile Development, agile estimation, extreme programming,   

    A very quick guide to Agile Development 

    Here at RocketResearch.com you can find a very quick overview of agile development,

    It has everything to get a quick head start,  like a five minute guide to scrum, getting started with XP, agile estimation etc.

    Happy Programming!

     
  • aftab 5:50 pm on June 2, 2009 Permalink | Reply
    Tags: Ajax, asp.net, callback, clientside, ecmascript, ICallbackEventHandler, javascript   

    Client Callbacks in ASP.Net 

    By Default ASP.Net pages communicate with the server through a mechanism call “PostBack”. Postback is very useful and efficient, except for the cases, where 1) You have a huge page, with a lot of processing required at server, so doing all that processing on every postback is not only waste of resources on the server, but also hurts the user experience. 2) You have client side variable, which will be lost on page refresh(i.e. postback).

    You can avoid both these limitations by introducing Client Callbacks in your application. In a client callback a client side event makes a request to the server, at server the page is initiated, it members are created, however page runs a modified version of its life cycle and only method that is marked for invocation is called; that, then can return a value that can be read using another client side function.

    Through out this process, page is available to the user and results are quick in most of the cases as on a small amount of data is being exchanged between client and the server.

    To implement client callbacks you need to do some work both on server side as well as client side.

    On server side, you need to:

    1. Implement ICallBackEventHandler in the page, that you want to use callbacks in. It have two methods i.e. RaiseCallbackEvent and GetCallbackResults
    2. Provide implementation for RaiseCallBackEvent, this is the method is invoked by the client to perform callbacks. This method accepts string as an argument.
    3. Provide implementation for GetCallbackResults, this method is invoked by the server, to process the request and return the results to the client as a string
    4. Retrieve a reference of a client side function (Using ClientScript.GetCallbackEventReference method), this function will be invoked as the result of server side processing, and it can be used to process any results coming back from server
    5. Register a client side script, using Page.ClientScript.RegisterClientScriptBlock method, that will make a call to the server. 

    On ClientSide, you need to:

    1. Implement the function that you provided as an argument in step 4 above
    2. Call the function you registered in step 5 above, on a client side event.

    Lets look at the code that you will use to implement your client call backs. In our demo project, we have two comboboxes on our asp.net page. One contains a list of departments and other a list of employees in the selected department. What we want to do is, fill employee combobox with the respective department employees, whenever our user changes department in Department combobox, without doing a postback.

    First things First; Implement ICallbackEventHandler interface

    public partial class _Default : System.Web.UI.Page,ICallbackEventHandler

    Implement two methods of ICallbackEventHandler

    #region ICallbackEventHandler Members
        /// <summary>
        /// this method Returns the results of a callback event.
        /// </summary>
        /// <returns></returns>
        public string
    GetCallbackResult()
        {
            //as only strings can be sent back to the client, we are will iterate through the list of
            //employees and convert it into comma delimited string
            string employeelist="";

            foreach (Department dept in departmetList)
            {
                if (dept.Name == deptArg)
                {
                    foreach (Employee emp in dept.Employeelist)
                    {
                        employeelist += emp.Name;
                        employeelist += ",";
                    }
                }
            }

            return employeelist;
        }

        /// <summary>
        /// This method is invoked by the client, this will be used to receive parameter values from the client
        /// </summary>
        /// <param name="eventArgument"></param>
        public void
    RaiseCallbackEvent(string eventArgument)
        {
            //right now all we are doing is to set the class level variable to eventArgument
            //that was sent by the client, recall that it is departments name.
            deptArg = eventArgument;
        }

    In your page_load event handler, first retrieve the reference of client function that will be invoked as the result of call back using ClientScriptManager.GetCallbackEventReference,

    string callbackEventReference = Page.ClientScript.GetCallbackEventReference(this, "arg", "GetResults", "");

    this method has several overloads, the one we have used takes target (in this case “page”), the “argument” that was passed by the client, name of the client side event handler that received the result of callback event and context as arguments. Context is any client script that will be evaluated prior to making a callback request. In this case we have passed an empty string.

    Then you need to build and register a client side script, that will call this CallBackEventReference, this is the script that will make the call to the server.

    string callbackScript;

    callbackScript = "function CallServer(arg){" + callbackEventReference + ";}";

    //register callbackScript with the client using ClientScriptManager.RegisterClientScriptBlock
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CallServer", callbackScript, true);

    So this was all that you need to do in our server side code, and now we will look at the client side code that we need to write to complete our client Callback.

    First we will write the function (using ECMAScript) in script block of our aspx file, GetResults; that we have been referencing in our code above,

        function GetResults(result)
        {
            if(result!="")
            {
            var array=result.split(",");
            for (var i=0;i<array.length;i++) {
            option = new Option(array[i],array[i]);
            var slc_target = document.getElementById("ddlEmployee");
            slc_target.options[i] = option;
            }       

            }
            else
            {
            //do something
            }
        }

    This function is accepting results; which is a string and it is splitting it into an array. Then all it does is, bind “ddlEmployee” a combobox on the page, with this array.

    and finally on a client side event of another combobox, “ddlDept”, we will invoke “CallServer” client side function that we registered using our serverside code and we will pass department as an argument.

    <asp:DropDownList Width="100" ID="ddlDept" runat="server" OnChange="CallServer(ddlDept.value)">

    I have attached the demo VS 2008 sollution here, when you run the project, you can see that, whenever you change any value in the Department Combo box, values in Employees combobox are refereshed without making a postback to the server.

    Download demo project here

    And Happy Programming!

     
    • RRaveen 10:36 am on July 2, 2009 Permalink | Reply

      Dear Friends,

      I hope you are doing well. I have launched a web site http://www.codegain.com and it is basically aimed C#,JAVA,VB.NET,ASP.NET,AJAX,Sql Server,Oracle,WPF,WCF and etc resources, programming help, articles, code snippet, video demonstrations and problems solving support. I would like to invite you as an author and a supporter. Looking forward to hearing from you and hope you will join with us soon.

      Please forward this email to all of your friends who are related IT. Send to us your feed about site also.

      Thank you
      RRaveen
      Founder CodeGain.com

  • aftab 4:47 am on June 2, 2009 Permalink | Reply
    Tags: developer, great, skills,   

    15 Tips to be great software developer 

    I just bumped into a great article by Miguel Angel Carrasco of http://www.realsoftwaredevelopment.com. It put forwards 15 tips, that if followed help you become not just good software developer but Great Software Developer, here is a summary and you can check the whole article here.

    1. Great quality code at lightening speed
    2. “100%” Correct interpretation of problem
    3. Look at the solution(s) from all possible angles before you start coding.
    4. How much confidence your manager has in your code
    5. How much confidence others have in your solution
    6. Always meet users requirements
    7. Staying up to date
    8. Contributions towards the team
    9. Make great meeting minutes
    10. Be teachable and take criticism well
    11. Be always available when needed
    12. Dress professionally everyday
    13. Communication abilities
    14. Goal Settings skills
    15. Organizational skills

    Great list, Good job Miguel Angel Carrasco

     
    • davidlongstreet 7:08 pm on October 1, 2009 Permalink | Reply

      I find it interesting that knowing something about the business problem or business domain did not make it on the top 15 list towards being a great software developer.

      Those software developers who know the business domains are treated as partners towards a business solution instead of just a coder.

      David Longstreet
      http://www.RebootRethink.com
      davidlongstreet.wordpress.com

    • aftab 11:35 am on October 3, 2009 Permalink | Reply

      You have an interesting point and i agree with you, however if we go back to the Carrasco’s list, #2 and #6 are not possible until you have good knowledge of business domain.

  • aftab 2:43 am on May 29, 2009 Permalink | Reply
    Tags: , , , ConfigurationElementCollection, , ,   

    Writing a complex custom configuration section 

    Technorati Tags: ,

    Here i posted another entry, showing implementation of a simple configuration section, now consider following listing

    <customSection>
        <elements>
          <add name=”FirstAssembly.FirstType” assembly=”FirstAssembly” shouldrun=”true”></add>
        <add name=”SecondAssembly.SecondType” assembly=”SecondAssembly” shouldrun=”true”></add>
        </elements>
      </customSection>

    here we have “n” number of elements in the custom configuration section. To handle this kind of scenario, System.Configuration namespace provides you with ConfigurationPropertyCollection class and ConfigurationPropertyCollectionAttribute class. Your can use ConfigurationPropertyCollection to programmatically write you configuration section and ConfigurationPropertyCollectionAttribute  can be used to do the same job declaratively.

    There are following steps involved in creating a custom configuration section handler with multiple entries.

    1. Define a class (say CustomElement) to represent configuration section by inheriting it from ConfigurationElement class
    2. Define a class to represent your configuration collection (say CustomeElementCollection) by inheriting it from ConfigurationElementCollection, this will hold a collection of the type you defined in step 1.
    3. Define a class to represent your custom section (say CustomSection) by inheriting it from ConfigurationSection and Implement a property of type that you defined in step 2.

    Here is the listing for CustomeElement Class

    public class CustomElement : ConfigurationElement
        {
            public CustomElement()
            {

            }

            [ConfigurationProperty(“name”, IsRequired = true)]
            public string Name
            {
                get { return (string)this[“name”]; }
                set { this[“name”] = value; }
            }

            [ConfigurationProperty(“assembly”, IsRequired = true)]
            public string Assembly
            {
                get { return (string)this[“assembly”]; }
                set { this[“assembly”] = value; }
            }

            [ConfigurationProperty(“shouldrun”, IsRequired = true)]
            public bool ShouldRun
            {
                get { return (bool)this[“shouldrun”]; }
                set { this[“shouldrun”] = value; }
            }
        }

    and here is the listing for CustomElementCollection Class, its implementation is similar to any other Collection class,

    public class CustomeElementCollection : ConfigurationElementCollection
        {
            public CustomeElementCollection()
            {
                CustomElement myElement = (CustomElement)CreateNewElement();
                Add(myElement);
            }
            public void Add(CustomElement customElement)
            {
                BaseAdd(customElement);
            }

            protected override void BaseAdd(ConfigurationElement element)
            {
                base.BaseAdd(element, false);
            }

            public override ConfigurationElementCollectionType CollectionType
            {
                get
                {
                    return ConfigurationElementCollectionType.AddRemoveClearMap;
                }
            }

            protected override ConfigurationElement CreateNewElement()
            {
                return new CustomElement();
            }

            protected override object GetElementKey(ConfigurationElement element)
            {
                return ((CustomElement)element).Name;
            }

            public CustomElement this[int Index]
            {
                get
                {
                    return (CustomElement)BaseGet(Index);
                }
                set
                {
                    if (BaseGet(Index) != null)
                    {
                        BaseRemoveAt(Index);
                    }
                    BaseAdd(Index,value);
                }
            }

            new public CustomElement this[string Name]
            {
                get
                {
                    return (CustomElement)BaseGet(Name);
                }
            }

            public int indexof(CustomElement element)
            {
                return BaseIndexOf(element);
            }

            public void Remove(CustomElement url)
            {
                if (BaseIndexOf(url) >= 0)
                    BaseRemove(url.Name);
            }

            public void RemoveAt(int index)
            {
                BaseRemoveAt(index);
            }

            public void Remove(string name)
            {
                BaseRemove(name);
            }

            public void Clear()
            {
                BaseClear();
            }

        }

    and Finally, here is the listing for CustomSection Class,

    class CustomSection:ConfigurationSection
        {
            CustomElement element;
            public CustomSection()
            {
                element = new CustomElement();
            }

            [ConfigurationProperty(“elements”, IsDefaultCollection = false)]
            [ConfigurationCollection(typeof(CustomeElementCollection),AddItemName=”add”,
                ClearItemsName=”clear”,
                RemoveItemName=”remove”)]
            public CustomeElementCollection Elements
            {
                get {
                    return (CustomeElementCollection)base[“elements”]; }
            }
        }

    Next add following settings to your configuration file

    <configSections>
        <section name=”customSection” type=”ConfigurationDemo.CustomSection, ConfigurationDemo” />
      </configSections>

      <customSection>
        <elements>
          <add name=”FirstAssembly.FirstType” assembly=”FirstAssembly” shouldrun=”true”></add>
        <add name=”SecondAssembly.SecondType” assembly=”SecondAssembly” shouldrun=”true”></add>
        </elements>
      </customSection>

    in the end put this custom section to use like this,

    CustomSection myCustomSection = (CustomSection)ConfigurationManager.GetSection(“customSection2”);

                foreach (CustomElement element in mySecondSectionHandler.Elements)
                {
                    if (element.Name != null && element.Name != “”)
                    {
                        string name = element.Name;
                        string assembly = element.Assembly;
                        bool shouldrun = element.ShouldRun;
                    }
                }

     
    • Raza Ali 11:57 am on May 18, 2011 Permalink | Reply

      Thanks! Alhamdulillah! It solved my problem.

    • Michel Abi Raad 12:56 pm on August 29, 2011 Permalink | Reply

      Thanks for this beautiful and easy way of illustration. However, I have one note and one question.

      Note: I guess there is a bug in the “foreach” in the last listing. There is no “mySecondSectionHandler” defined; you should replace this identifier by “myCustomSection”. That is, the second statement in the last listing should be:

      foreach (CustomElement element in myCustomSection.Elements)

      Question: I tried to write to add new elements at runtime to the file, but they do not get saved, even though I used the Configuration.Save method. May you show that please?

      Thanks

  • aftab 10:41 pm on May 28, 2009 Permalink | Reply
    Tags: , , , , ,   

    Writing a Custom Configuration Section 

    Writing your own configuration section involves following steps: –

    1. Define xml structure that will fulfill your configuration needs
    2. Write a class that will represent your custom section by inheriting it from System.Configuration.ConfigurationSection
    3. Add your section, assembly and type representing it, in configSections in your config file.
    4. Add your section anywhere in your config file, within <configuration> root.
    5. Retrieve your custom section using ConfigurationManager.GetSection(“<SectionName”>”)

    Please note that to use ConfigurationSection class you need to add reference to System.Configuration.dll in your project.

    Consider Following xml structure:

    <customSection assembly=”FirstAssembly” type=”FirstAssembly.FirstClass” shouldrun=”true”/>

    Following code snippet defines handler for this configuration structure.

    class CustomSectionHandler:ConfigurationSection
        {
            public CustomSectionHandler()
            {
            }

            [ConfigurationProperty(“assembly”, IsRequired = true)]
            public string Assembly
            {
                get { return (string)this[“assembly”]; }
                set { this[“assembly”] = value; }
            }

            [ConfigurationProperty(“type”,IsRequired=true)]
            public string Type
            {
                get { return (string)this[“type”]; }
                set { this[“type”] = value; }
            }

            [ConfigurationProperty(“shouldrun”,IsRequired=true)]
            public bool ShouldRun
            {
                get {return (bool)this[“shouldrun”];}
                set{this[“shouldrun”]=value;}
            }
        }

    Here you have define a CustomSectionHandler class that is inheriting from Configuration.ConfigurationSection class then you have define three properties (representing three attributes of the custom section) and you have decorated all these properties with ConfigurationProperty Attribute.

    Next add your section in your .config file in the configSections

    <configSections>
        <section name=”customSection” type=”ConfigurationDemo.CustomSectionHandler, ConfigurationDemo”/>
      </configSections>

    where name is; just name of your section using which you can refer to it in your code and your configuration files while type is “<fully qualified name of handler type>,<Assembly that contains it>”.

    SO that was it, your custom section handler is ready, now you can put it to your service like this,

    CustomSectionHandler mySectionHandler = (CustomSectionHandler) ConfigurationManager.GetSection(“customSection”); 

    string assembly = mySectionHandler.Assembly; 
    string type = mySectionHandler.Type; 
    bool shouldRun = mySectionHandler.ShouldRun;

     

    Happy Programming!

     
  • aftab 5:56 pm on April 14, 2009 Permalink | Reply
    Tags: book, reading   

    How to Finish a book? 

    I read a lot books, articles, blogs, everything that i can get my hand (and in good old days shopping bags made out of newspapers) , eyes(which includes people’s shirts) or browser (most notably codeproject.com) on.

    However in case of larger books, it was always rare that i will “finish” a book (with the curious exception of novels).

    I used to wonder why? I am still not sure but probably i will loose interest due to continuous bombardment of information on a certain subject, may be our brain (my brain at least!) is not capable of handling too much information on a certain subject in one go or it doesn’t like information to be continuously presented in only one style. One thing was for sure, after staying with a book for some days, i will start longing for a switch (to another book). So i will keep switching from one book to another book, without finishing most of them.

    One day i somehow bumped into this blog article,

    How To Finish Books Once You Start Them

    and Wow, i was able to finish a decently big (1000+ pages) book lately following this approach.

    Following are the rules of this approach: –

    1. Have five active books.
    2. Keep them in a pile (not stack, you can follow any order to read one of your active book)
    3. After finishing a session with a book, put that book on top of the pile.
    4. You can not read any book, but one of these five active books.
    5. If you want to read a book, which is not in the pile, either wait until you finish one of them, or take out the book at the bottom of the pile and add a new one.

    may be you should try this approach and let me know if it worked for you or not?

     
    • kashif 9:10 pm on April 14, 2009 Permalink | Reply

      Hi Blog,

      I used to do this in the past but sometimes keeping few different books ranging from professional to novels, islamic ones etc. Even newspapers and somehow it worked.

      Best,
      Kashif

    • Tahir Anwar 10:05 am on April 24, 2009 Permalink | Reply

      This is the same problem I think with everyone. Its been a very rare chance that I was able to study one whole book completely. But it might be a good approach, I must give it a try. Lets see.

    • aftab 4:09 pm on May 29, 2009 Permalink | Reply

      Yeah, it has worked for me again, i finished a 1200 pages book using the same technique,
      So i will keep using it and keep reading 🙂

  • aftab 1:52 pm on September 9, 2008 Permalink | Reply
    Tags: Browser war, Chrome, Firefox, Google, IE 8, Mozilla   

    New round of browser war 

    Google, by launching Chrome, has brought the old forgotten browser war back. It will be interesting to see how it changes the evolution of web and web browser in  the future.

    One key difference however, between old and new browser war is, instead of two, this time we have four big players in the field; that is MS IE , Mozilla Firefox, Apple Safari and Google Chrome.

    Microsoft, Mozilla and Google have respectively released IE 8 (beta), FF 3.0 and Chrome (beta) almost simultaneously.  If you ask me who is the winner, my answer would be Chrome is a clear winner at least in this round.

    I first tried IE8 when IE Beta for developer was released but i could not use it any further as it was crashing again and again, whenever i will try to search anything using my Google Toolbar. So i had to uninstall it. I tried it again when IE 8 Beta 2 was released and i had to remove it again, as despite of MS claim that IE wont crash if one tab freezes due to some badly written script, it won’t crash the browser but only one tab,  in reality it was crashing every now and then. Out of frustration i would have to reopen all those sites again (in FF or Chrome).

    Most noticeable aspect in the newest browser on the block, Chrome, is its speed as compared to IE 8 and even Firefox (which takes too long to start up). It was way faster then both of them.

    Second most noticeable feature is its minimalistic design, with Tabs at the Top, a super address bar, which lets you add addresses and search strings in the same box and simple navigation. While using Google chrome, you will feel like being on your desktop with your applications arranged in different tabs. That fits very well in Google’s long term plans, where it wants web as the desktop and center of all kinds of computing.
    Chrome has another advantage; It is based on Web Toolkit, which conforms to W3 standards, so as far as rendering is concerned Chrome will be easier to develop applications against while IE is hardest in that regards due to many proprietary extensions by Microsoft (Even though they have announced that IE 8 is going to be standard conforming).

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel