[X]

Learning C# Design Patterns Series -Why Design Patterns

Design Patterns - The Best Practices

Few years back, design patterns for .net developers were less known though it is widely being used by java developers.

So as .net languages and developers got more matured over the time, people started looking for .net code optimization, performance, best practices, extensibility and maintainability of the code side.

First obvious question about making use of design patters is why? Why we should implement design patterns in our solutions/applications.

Well I will try to read and make notes of why and how of design patterns and share in this series. So let begin.

1. Why design patterns? What benefit I will get?

Productivity: Design pattern helps to build an architecture which can enhance the productivity.

Extensibility: When a software is released and becomes successful and widely accepted it is obvious that it will receive lots of request change and updates. So if while building the application proper design patterns is implented it will be easy to supply those updates and request. Most design patterns promote the idea of coding against interfaces and base classes, which makes it easier to change and enhance your application at a later stage.

Simplicity: Our solution architecture should be simple, well thought out, clean, crisp and easy to understand. This can be acheived by knowing the design pattern in advance.More...

T-SQL - How to get week of the month of given date

Microsoft has lots of in build function in T-SQL for developers. These functions come very handy in day to day t-sql developer requirement.

Today I came across a need of calculating the "Week of Current/Given Date Month". After going through the existing functions of t-sql, I was able to figure out a way to find out the week of given date. Below is the mathematical formula to calculate this:

Week of Current Month = Week of Year - Week of First Day of Current Month + 1

First Date of Current Month = Given Date - Day of Given Date + 1

 

More...

Javascript Exception Handling Try-Catch-Throw - (Learning Javascript Series)

Javascript Exception/Error Handling

Exception handling is one of the difficult and oftenly avoided task by the developer. It is because handling exception requires almost equal amount of time and thinking from developer as given to the main program. In javascript 1.4 exception handling was supported by adding try-catch-throw to the language.

Exceptions are generally categorized in 2 types:

System Error: Caused by browser/code because of unknown reason(s).

Application Error: Caused by a piece of code where the scenario in which an error can occur is not handled by the developer.

More...

Javascript Break, Continue and With Statements - (Learning Javascript Series)

Javascript Break, Continue and With Statement

Break and continue statements are part of almost every programming language. They provides ability to stop/skip the execution in a program flow. These statements are only used inside a loop or switch statement. They are not valid outside of switch/loop statement.

Break statement is most frequently  used inside switch statement and is part of every case block. Whenever a break is encountered after a case, execution is immediately sent out of switch. Similarily when it is used inside a loop, once break is found, execution comes out of loop. Break statement says, "Exit the loop."

More...

Javascript Loop Statements - (Learning Javascript Series)

 

Javascript Looping Statements

Task iteration is one of the most frequently activity that every developer has to perform in most of its projects/applications. Iteration allows to repeat execution of set of statements for some definite time. It enables to avoid writing of same lines of code many times which not only is cumbor some but also waste of time.

Like other languages javascript also provide similar looping statements. Javascript looping statements are more like "C" language as most of the language syntax are derived from there.

So we can now summarise purpose of loop statements:

  • They provide ability to repeat a set of statements for a specific number of times
  • They provide ability to repeat a set of statemens for unknown number of times and/or can be stopped when some criteria is met during program execution

More...

Javascript Conditional Statements - (Learning Javascript Series)

Javascript Conditional Statements

There are two conditional statements in JavaScript: if and switch. The if statement allows the program to choose one of two alternatives, based on some predefined factor.

If statement: It is used to interrupt program flow for some condition.

var num = 10;
                if (num < 20) {
                    alert(num + " is less than 20.");
                }

If - Else: It is used to interupt program flow for some condition but instead of satisfying for one, it will also check for second condition.

var num = 10;
                if (num < 20) {
                    alert(num + " is less than 20.");
                }
                else {
                    alert(num + " is greater than 20.");
                }

More...

Posts By Month