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
BEGIN
                 select * from [user]
END
ELSE
                  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
                                         @userId
                              Else
                                        userId
                              End)

:) 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.