Saturday, May 9, 2015

Using Case Statement in Where clause

Recently I faced a situation where I need to decide by where clause value based on certain condition

so situation was some thing like this: To select some records for a userid and if userid passed is 0 then also we need to get records so my query was something like this:

select * from [user]
Where userId = @userId

Not if @userId is passed as 0 still I want the above query to get executed one way was to put if condition like

if @userId > 0 then
                 select * from [user]
                  select * from [user]
                 Where userId = @userId

But I found a more smarter way ( which I think it is)

select * from [user]
Where userId = ( Case When @userId != 0 Then

:) isnt't it cool :)

Wednesday, May 6, 2015

Javascript's indexOF is case oriented

Our own little javascript's little cute indexOf function is case sensitive and I am surprised why???

so var s = 'hello world';

s.indexOf('hello') returns 1 and s.indexOf('HELLO') returns -1

Aaaarrrrrrrggggggghhhhh...... Lets enjoy this :)

Solution I forgot (Bad habit to rush to you tube for new songs hehe he he.....)

 s..toLowerCase().indexOf('HELLO') is good to go   ;)

Saturday, May 2, 2015

MSDn sayings :)

  • The operations are primarily CPU operations instead of operations that involve extensive disk or network overhead. Using asynchronous action methods on CPU-bound operations provides no benefits and results in more overhead.
This means that async action methods should not be used in the above scenario means CPU bound operations are those which just need CPU power for example a long runing loop doing lots of calculations.

Async action methods to be used only which are disk or network overhead which are those??? Those are result of big query which involves reading to or writing to disk.

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:
// Used on: