Patterns

To repeat or not to repeat yourself?

Posted on by osmirnov Posted in .NET, Patterns, Visual Studio | 1 Comment

What do modern developers if they are forced to write repeated code? Of course, they follow DRY principle and try to write generic code that covers as much as possible cases and can easily be extended to the rest. But sometimes such a change is complex, inefficient, or simply impossible. Here template engines come into play that allow the developer to set the rules and get your service code. I propose to try to take the advantages of both these approaches.
Read more

DynamicObject: AOP for the poor

Posted on by osmirnov Posted in .NET, DLR, Patterns | 4 Comments

Use of AOP without help of third-party frameworks is difficult and often all of their functionality is not needed. In this post I want to share an interesting example of how I replaced AOP in its typical problem for a dynamic type.
Read more

Procrustean repository

Posted on by osmirnov Posted in .NET, Patterns, SharePoint | Leave a comment

We have already examined the Repository pattern. For example, here and here. Today, let’s see how many examples of this pattern force a developer thinks that any repository must include concrete methods and nothing more. Often it is correct and you have pure DDD application. But what if your data source differs from database and has specific methods to modify data?

Read more

Lazy developer

Posted on by osmirnov Posted in .NET, ORMs, Patterns | 1 Comment

If I ask about Lazy Loading pattern, 99 out of 100 developers know what it is and what it eats. But if I ask where they use it most often, then more than half will answer – for implementation of Singleton pattern (sometimes I think that 110 of 100 developers know about it). We won’t blame them for such illnesses as singletonism (singletonitis is who very love singletons), but the fact remains when developers take for ORM the Lazy Loading are interested them in the least. Let’s find out why.
Read more

A repository at the Linq epoch (Part VI): Repository implementation

Posted on by osmirnov Posted in .NET, ORMs, Patterns | 2 Comments

Now that we have an idea of building dynamic queries, we can describe the repository to work with them. Its task is to free the developer from having to compile queries and facilitate their creation. In this way we are going to do in this final part of the series of posts.

Read more

A repository at the Linq epoch (Part V): Dynamic queries

Posted on by osmirnov Posted in .NET, ORMs, Patterns | 1 Comment

Very often queries to a database are not known at the time of application development. A typical example – using a complex grid to display data. Such grid can include all the features that we talked about, namely pagging, sorting and filtering (grouping, we consider separately). In fact, the number of possible queries is so large that you can easily lose control of them. The situation gets worse is that sometimes you have to build queries dynamically. Are you familiar with it?
Read more