Composite Pattern: Handling child node collections

One problem related to composite pattern is how to implement operations over child collections. Composite classes have children and leaf classes not. There are many ways how to solve the problem of where and how to keep child nodes collection. In this posting I go through different options and analyze those solutions through different code examples.

Read more

IFileClient – Generalizing storage access in ASP.NET web applications

This is one of the examples from my presentation about how to port existing ASP.NET applications to Windows Azure and how to build hybrid applications that work in multiple environments. One of important aspects is file storage that may have multiple implementations for different technical environments. In this posting I will introduce you my idea about generalized file access in web applications.

Read more

Generalizing storage access for Windows Phone and WinRT apps

When building application that works both on WinRT and Window Phone you use Portable Class Libraries (PCL) for shared classes. As there are many application specific things that are not same on different platforms or that are not supported by PCL then you have to make some architectural decisions when creating shared functionalities. In this posting I will focus on persisting data for offline use.

Read more

Composite Pattern

Composite pattern is used in many applications. It helps to build hierarchies of similar objects and handle slices of hierarchy as one. Maybe one of the most popular implementation of this pattern in .NET world is Nodes collection of ASP.NET TreeView control. In this posting I will introduce you composite pattern and provide some implementation tips and samples about it.

Read more

Command Pattern

Command pattern is object behavioral design pattern that helps you handle different activities in application using same interface. I’m Command pattern is object behavioral design pattern that helps you handle different activities in application using same interface. I’m using Command Pattern in some of my systems to handle similar actions together and to split more comples operations to smaller steps by example. In this posting I will give you overview of Command Pattern.

Read more

Transaction Script Pattern

Transaction Script (TS) is the simplest domain logic pattern we can find. It needs less work to implement than other domain logic patterns and therefore it’s perfect fit for smaller applications that doesn’t need big architecture behind them. This posting focuses on TS pattern by illustrating and analysing it. Also some good hints for implementation are provided.

Read more

Design Patterns: Elements of Reusable Object-Oriented Software

Design Patterns is golden classics of software design books written by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides (aka Gang of Four – GoF). When this book was published first it was revolutionary because it contained still undocumented knowledge from software development field that needed some systematic work and organization on it. Today we see these patterns in many programs and developers on different platforms are more and more aware of these first defined design patterns. If you are software developer then this is must-have book for you.

Read more

Adding multiple data importers support to web applications

I’m building web application for customer and there is requirement that users must be able to import data in different formats. Today we will support XLSX and ODF as import formats and some other formats are waiting. I wanted to be able to add new importers on the fly so I don’t have to deploy web application again when I add new importer or change some existing one. In this posting I will show you how to build generic importers support to your web application.

Read more

Using AutoMapper to build base class for mappers between domain classes and models

It is often good idea to isolate our domain model from consuming applications by using service layer and data transfer objects (DTO) or application specific models. Using DTO-s means that we need two-way mapping between domain classes and DTO-s. In this posting I will show you how to use AutoMapper to build generic base class for your mappers.

Read more

Using Lazy and abstract wrapper class to lazy-load complex system parameters

.NET Framework 4.0 introduced new class called Lazy and I wrote blog post about it: .Net Framework 4.0: Using System.Lazy. One thing is annoying for me – we have to keep lazy loaded value and its value loader as separate things. In this posting I will introduce you my Lazy wrapper for complex to get system parameters that uses template method to keep lazy value loader in parameter class.

Read more

Using timer based Unit of Work and Command classes to measure repositories performance

In my last post Find out how long your method runs I introduced how to measure the speed of code using actions. In this posting I will make a step further and give you some ideas about how to create easily measurable code units and how to build measurable scenarios of them. As a foundation I use simplified versions of patterns like Command and Unit of Work.

Read more

Returning paged results from repositories using PagedResult

During my large database experiment I wrote simple solution for paged queries that I can use in my repositories. This far my experiments have shown pretty good results and I think it is time to share some of my code with you. In this posting I will show you how to create paged results using NHibernate and Entity Framework based repositories.

Read more

Patterns of Enterprise Application Architecture

Lately I finished reading the famous patterns book by Martin Fowler – Patterns of Enterprise Application Architecture. This book introduces and describes design patterns you will usually see when building enterprise applications. There are also examples for patterns and although they are simple and primitive they give you the idea how to implement or use specific patterns. If you are working on enterprise applications every day you will find this book very useful and I’m sure you will use it as manual.

Read more

Visual Studio 2010: UML modeling projects

Visual Studio 2010 introduces modeling projects that bring UML diagrams to Visual Studio. Currently it is not possible to generate classes from diagrams automatically but I don’t think it is a problem – good UML diagrams visualize different aspects of system short and clearly and they usually don’t document everything you can find in system. In this posting I will show you how to use modeling projects in Visual Studio 2010.

Read more

Writing cache based repositories for web application prototyping

When I started building in-house demo application I thought about how to solve temporary data layer so I don’t have to use real database and object mappings for it. Playing with new object model and new components I move way faster if I don’t have any additional ballast that I can avoid. So I wrote simple cache based repository mechanism I can use to imitate real repositories that I will write in the future.

Read more

Modeling people and organizations: Party generalization

Classes for people and organizations are often modeled incorrectly in object models. These faults cause heavy implementation problems. In this posting I will analyze some legacy models, introduce class Party as generalization of people and organizations and provide some implementation details. Information here is based on my own experience, like always.

Read more

Agile Principles, Patterns, and Practices in C#

Agile Principles, Patterns, and Practices in C# by Robert C. Martin and Micah Martin describes how to write software using C#. Book covers also most important design patterns and object-oriented development principles. There are very good, close to reality examples for every topic and that makes this book pretty easy to read and understand.

Read more