.Net

Method Chaining Design Pattern in C# and JavaScript

One of the most commonly used and useful design pattern in programming language is Method Chaining. As the name suggests, it allows you to chain / call multiple functions on the same object consecutively, without any need to specify object name during each method call. This pattern is heavily used in JavaScript libraries like jQuery, AngularJS and in Language Integrated Query [LINQ] feature of C#. In the first part of this article, we will cover how this pattern is implemented in jQuery and C# LINQ. The code snippet presented in the article will help you to understand how this pattern…

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…

Microsoft Intermediate Language [MSIL] Tools

I have been a .Net developer since long time and I have developed fairly complex and large scale applications using different .Net framework technologies like C#, ASP.Net, Windows Forms, WCF etc. I have conducted numerous training sessions on these technologies for my team members and colleagues as well. Most of the time my focus was on to explain the language features like ‘Abstract classes’, ‘Interfaces’, ‘Virtual methods’, ‘LINQ’ etc. However I did not pay much attention on the compiler side. That is, how C# compiler compiles source code, how Intermediate Language [IL] looks like, how can I disassemble the code…

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…

3 of 4
1234