Sunday, January 25, 2015

Different Items in software delivery

I am working in software industry with more then 10 years now and have worked in capacity of developer and team lead too.

From perspective of team lead estimates provided by the team for the tasks to be completed are something which any TL doubts.

You can have confidence on estimates only when you have detailed understanding about changes to be done at what level.

Once who is working with a system for a long can give a real detailed estimates

1. What would be the change in Database level like stored proc or tables?
2. Changes at Business logic classes
3. Changes in Business entities
4, Changes in front end controller
5, Change in Models and Views.
6. Unit testing
7. Executing test cases written by test team.

All this constitutes estimate of a task

1. Create a traceability matrix for requirements, Clearly mention requirement number and mention the comment in the code mentioning the requirement detail so that it is easier for the person who reads the code.

2. Database document is very important to create which clearly shows which table stores what and that knowledge helps to understand application.

Beware of the test team some times test team goes overboard in the way that they might want to get features done in their way which they think is correct so one needs to be cautious for the bugs which they mention whether they are saying some thing inscope of the project or out of scope.


Sunday, August 10, 2014

Mobile Events

Recently I got opportunity to solve some issues on a webapplication which was supposed to run on desktop browsers and smartphone broswers both.

Since it was designed to work with mobile browsers also javascript was written to handle events which occurrs on mobile browsers.

So in this post I will share my experience of the same.

First problem assigned to me was that there was a dropdown which had different options like "Upcoming. Monthly, Past Week" So user has to select one option and based on that option filtered result list will be populated on screen.

So problem here was when ever user was trying to select any option from this dropdown in mobile website browser dropdown does use to open and close again so user was not able to select any option from that dropdown.

After looking into the code I found there one mobile browser event "touchstart" wired up and handler on this event code was written to just close this dropdown if its opened and this event was handled on document level or would say at top level like  $('html').on("touchstart", function () { // code to hide dropdown });

Also when I looked at dropdown code its onclick was properly wired up to handle click and selection of item but in case of mobile browsers this click event doenst use to fire instead touchstart use to fire before and its handler as defined above use to execute.

Also one point which learned was that in browsers click event is fired after 300ms delay since user touched the screen and touchstart has been fired. This delay has been kept just to check if user is actually going to click or just tap or do touchstart.

Then what I thought is that if I define a handler of touchstart at dropdown level then event will bubble up. And guess what it worked!!

I simply handled ontouchstart like onclick and copied handler in onlcik to ontouchstart now when user use to touch dropdown first touchstart of body used to fire defined at top level and then touchstart handler of dropdown fired which read the selection and filtered the list.

It was amazing learning for me since it was first time I was handling any mobile browser related issue.

Then I cam to know that there are plethora of mobile browser event like touchstart, touchmove, touchened and swip and etc. which one can handle to show desired results in mobile browsers.

Keeeeep listening!!

Friday, August 8, 2014

Best Practices UI:

1. Include the name of plugin at the top of page whether aspx or ascx. Like if I am using TouchSwipe jquery plugin it should be in comment at the top of the page so that any one who works on that page can look at that page and section to know plugins used in that.

// Plugin Used: TouchSwipe
// Plugin URL: http://labs.rampinteractive.co.uk/touchSwipe/demos/
// Used on:

Monday, July 21, 2014

Anonymous types were introduced in c#3.0 mainly to support LINQ. But it has find its good use in other places also like in HTMLHelper classes available in MVC.

Anonymous types are classed which do not have any name assigned to them. They only have properties defined and initialized then and there only.

Anonymous types are not public.

Friday, July 18, 2014

Extension Methods in c#


If one wants to extend a property of a class without modifying the existing code of class and compile it again one can use Extension methods concept which has been introduced in .Net 3.5 and C#3.0.

Previously if one wants to extend any particular class one had to inherit that class and create a new class and then give its implementation but using extension methods one can easily extend functionality of an existing class.

To explain the concept better I will take example. Lets say I have a following class BookMyShow which provided different methods to provide booking of different shows. On top of that this class is sealed which means this class cant be inherited further which means in future if I want to extend the functionality of this class I need to have either access to the source code of this class and then change the source code and compile it and then re-distribute the same..........ufffffffffffffffff.... lot of things to do.

namespace BookingPlaza
{
    class BookMyShow
    {
        public bool Book(string[] strppl)
        {
            /// ;;.......
            return true;
        }

        public int CancelBooking(string[] strArrBook)
        {
            return 0;
        }

        public DateTime GetShowBooking(string strWhen)
        {
            DateTime dtm = new DateTime();
            switch (strWhen)
            {
                case "AM":
                    {
                        DateTime.TryParse("10:00 AM",out  dtm);
                        break;
                    }
                case "PM":
                    {
                        DateTime.TryParse("10:00 PM", out dtm);
                        break;
                    }
                default:
                    DateTime.TryParse("03:00 PM", out dtm);
                    break;

            }

            return dtm;
        }
    }
}


Here comes the extension method to rescue.

Using extension method one can extend the functionality without source code access of the type to be extended

namespace ExtensionOfBMS
{
    static class ExtendBookMyShow
    {
        public static bool AdvanceBooking(this BookMyShow objBMS, DateTime timings)
        {
            return true;
        }

    }
}

As you can see above we extended the BookMYShow class but you might be wondering how this happened as I was so whole magic lies in the first parameter of the static method.

So first I will explain some syntax:

1. You need to create a static class having static method which will have extended functionality of the type to be extended.
2. Here comes the magic ;) . First parameter of the function should be type to be extended with this modified specified. As in this case it was BookMyShow.
3. Now where ever you want to use it you just need to put using directive. Like using ExtensionOfBMS.; and then you can access the extended method just like a instance method. As you can see in the screen shot AdvanceBooking is available as the extension method.




I would say amazing thing in this extension method implementation is that a static method is just available as instance method of the class when IL code is generated its actually static class call to static methods.

One more thing to point here is binding. If you create a same method as extension method which is already defined in the class and when you call this extension method it will always going to call the type implementation instead of the extended one. So for example I try to create one more extension method having same signature as already existing method compiler will always pick base class implementation.

Extension methods cant access the private methods or variables of the type or class which they are extending hence encapsulation is still intact in the design.

Keep extending!!!!!!!!!!!!!!!!!!!!!!!

Thursday, July 17, 2014

Impersonation - A holistic approach


What is impersonation?
When you try to execute current request in a different user's context instead of default one so that means you are impersonating.

Any windows process runs under a windows identity assigned to that process or a user account under which a process executes.So all permissions applicable to that identity as per that only process can execute.
 In Asp.Net the process runs under its ASPNET account. It has limited privileges. So if sometimes if we want to access resources which are not allowed to be accessed by default windows identity account under which that process is running we might have to use windows account credentials which have access to the resource to be accessed. So running the process under user provided authenticated account instead of default account is called impersonation.

Impersonation can significantly affect performance and scaling. It is generally more expensive to impersonate a client on a call than to make the call directly.

One can set impersonation through IIS at application or page level using Authentication feature.
There are scenarios where you dont want to set impersonation at application level and dont want to share your credentials with the site administrator for security reasons. In that case developer have option where he can change the windows account context which is be default Network Service or ASPNET account to user users domain account.

Following blog entry explains very clearly how to impersonate programatically. In this author has nicely explain the caveats also. http://weblog.west-wind.com/posts/2005/Feb/24/Using-programmatic-Impersonation-from-an-ASPNET-Page

As shown in this link one has to use interop to call Win32 LogonUser and CloseHandle functions. We have to use interop because .NET doesn’t provide the equivalent methods.

So.... IMPERSONATE!! ...but only when required :)!!

Wednesday, July 16, 2014

Awesome sayings

Scott Gu's BOss says:

"Guy walks into support, sez he needs a bigger mobile phone antenna. Doe he need a bigger antenna or does he really want better reception? Don't let your users dictate your solution with their statement of the problem."