Skip to content

Month: July 2017

Pre/Post Build Events in Visual Studio

Introduction Pre/Post Build Events are useful when we wish to perform some operation before/after a project is build. These operations are nothing but the shell commands being used from the command line. Consider a scenario where we build our library project and its .dll is saved into the Project/bin/Release directory. For some reason we want all our library files in one common directory that we would refer…

Analyzing a Tightly Coupled Application

Dependency injection is a vast topic in itself. However, it is difficult to find everything we should know about it in one place. And so, I thought of creating my own series of learning about topic. In this part of the series we will look into a tightly coupled application and the problems related to it.   Introduction An application is said to be tightly…

Null Object Pattern

Almost every method that we write, irrespective of the programming language, we always have checks like the following one: if (objectVariable == null) return; // do some work with objectVariable We end up adding so many null checks in our methods, that it gets almost hard to figure out what we are supposed to do in our method. This makes our code look ugly and hard…

Anonymous Types in C#

Generally, for an object to encapsulate some properties, the type of the object has to be defined first. On the contrary, anonymous types provide a convenient way for an object to encapsulate readonly properties without explicitly defining the type first. The type of each property is deduced by the compiler.   Creating an Anonymous Type We can create an anonymous type using a new keyword along…

Entity Vs Model Vs ViewModel Vs DataModel

Different people define Entity, Model, ViewModel and DataModel in different ways. However, these terms may sometimes differ from their actual meaning, based upon the context. In this post I would like to share my understanding of these terms.   Entity An entity is the tabular representation of your domain class/object in the database and has an identity. In fact, an entity represents a single instance…

Understanding Relationship Between Objects

Introduction The relationship between objects defines how these objects will interact or collaborate to perform an operation in an application. In any application, objects of user interface classes interact with the business layer objects in order to perform an operation. And in the background, the business layer objects may interact with objects of some repository which in turn talks to some data source object or…

Understanding Assemblies

Code reusability has always been one of the major concerns for software developers. You do not ever want to write a similar code for two business problems. You would rather like to write the solution once and reuse it whenever and wherever required. This requirement of code reusability gave rise to the concept of creating assemblies and using them in different applications by adding a reference…

When to use “var” as a Type

Introduction It has been quite a long time since var was introduced, yet it stands debatable among .net developers. Everyone has a different understanding as and when to use var as a type. A couple of days ago I was also a part of one such discussion, and so I decided to share my understanding. CodeProject   Readability Every developer has all the right to use var as and…