C#

Top 10 JavaScript traps for a C# developer

If you are an experienced C# developer, coming into JavaScript world for application development, you will end up making few common mistakes. However some of the mistakes you would make are due to the basic differences between any strongly typed language [C#, Java etc.] and a dynamically typed language [JavaScript, Python etc]. Although dynamic feature was added to C# version 4.0, its initial design was based on static typing. Note, I am primarily a .Net developer and have experience of developing web applications using JavaScript, and I admit that I made these mistakes when I started learning JavaScript. I spent…

How to avoid race condition in C#?

Classes in System.Threading namespace and Task Parallel Library [TPL]  introduced in .Net framework 4.0 helps application developer write concurrent, multithreaded, parallel and asynchronous program. Yes I know; I have used quite a few heavy words here, which are often confusing and difficult to differentiate.  So let’s understand the difference between these terminologies first and then we will drill into race condition and thread / task synchronization. Concurrent – A concurrent system is a one where computation can make progress without waiting for all other computation to complete [extracted from Wikipedia]. However, it’s a generalized term as it does not specify…

SOLID Principles – Dependency Inversion Principle [DIP]

SOLID stands for Single Responsibility Principle [SRP], Open Closed Principle [OCP], Liskov Substitution Principle [LSP], Interface Segregation Principle [ISP] and Dependency Inversion Principle [DIP]. In this article I will explain Dependency Inversion Principle [DIP]. This principle states that High level modules should not depend on low level modules rather both should depend on abstraction. Abstraction should not depend on details; rather detail should depend on abstraction. Lets understand it through example. The Copy class defined in above class diagram reads user input from KeyboardReader class and sends it to Printer using PrinterWritter class. As the diagram suggests high level component…

SOLID Principles – Interface Segregation Principle [ISP]

SOLID stands for Single Responsibility Principle [SRP], Open Closed Principle [OCP], Liskov Substitution Principle [LSP], Interface Segregation Principle [ISP] and Dependency Inversion Principle [DIP]. In this article I will explain Interface Segregation Principle [ISP]. This pattern states that once an interface becomes too fat, it needs to be split into smaller interfaces so that client of the interface will only know about the methods that pertain to them. In other words, client should not be forced to depend upon interfaces that they do not use. In the code example defined below, I have declared an interface IDoor which is used…

SOLID Principles – Liskov Substitution Principle [LSP]

SOLID stands for Single Responsibility Principle [SRP], Open Closed Principle [OCP], Liskov Substitution Principle [LSP], Interface Segregation Principle [ISP] and Dependency Inversion Principle [DIP]. In this article I will explain Liskov Substitution Principle [LSP]. This pattern states that functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it. In other words you should always be able to use a base class or interface instead of the actual implementation and still get the expected result. If you can’t, you’re breaking LSP. Lets understand it through example. In below code example…

3 of 4
1234