background preloader

Patterns

Facebook Twitter

C# - Multiple Configuration Sources for Enterprise Library 4.1. Microsoft Enterprise Library for .NET 2.0: Configuration. Microsoft Enterprise Library for .NET 2.0: Configuration The long awaited successor of the Enterprise Library for .NET 2.0 has been released by Microsoft at MSDN. From the configuration perspective the main changes are: Configuration Application Block was replaced by the .NET 2.0 System.Configuration classes.Usage of ConfigurationSection and ConfigurationElement for ser/deserialization.Only the Logging Application Block registers to receive file change notifications.Object Builder from the CAB (Composite UI Application Block) is used for Configuration Factories.Instrumentation can now be configured and is turned off by default. Configuration of Enterprise Library Application Blocks Possible configuration scenarios are: All configuration data is in App.config (default).App.config references another config file which contains all configuration data.No App.config but another config file which is located by other means.No config file at all.

FilePath="c:\Shared.config" /> “Connection String“, Patterns & practices – Enterprise Library. Patterns & practices – Enterprise Library - Download: Enterprise Library 5.0 - SQL Configuration Source. Microsoft Enterprise Library: Data Access Application Block | Radical Development. For those of you who have been using the Enterprise Library from Microsoft then I tip my hat to you. I admit that I have not used this library for a number of years and in most cases the reason is because I have honestly not been in a position to do so. It is a long story so don’t ask. There are a number of reason why you should seriously consider the use of the Enterprise Library and I cannot think of any better reason than those provided directly from Microsoft. The goals of Enterprise Library are the following: Consistency.

All Enterprise Library application blocks feature consistent design patterns and implementation approaches.Extensibility. Now that the groundwork has been laid let us get started. Introduction to the Data Access Library The Data Access Application Block includes a small number of methods that simplify the most common techniques for accessing a database. As with anything good there is always its counterpart. The Database Connection Inline SQL Statement Example.

REST - Can You do More than Spell It? Part 1. Thousands of years ago when we first started building web pages, things were very simple. You’d put some text on the page, maybe even an image, and that was pretty much it. But today it’s a whole different ball game. Instead of static pages there’s the dynamic applications we’ve come to depend on. And so, how these applications are designed to communicate becomes very important. What is REST? REST is a set of principles that define how a server and client can communicate with each other (and external resources) in a simple, straightforward, and robust manner. In many references you will see REST and SOAP both mentioned as competitors. The ideas behind REST have been around for a while, first appearing in the doctoral dissertation of Roy Fielding, one of the developers of the HTTP protocol. REST stands for REpresentational State Transfer, and while this meant nothing to me the first time I saw it, Fielding had very definite ideas about its meaning.

Principles of REST PUT vs. Summary. Entity Framework Repository Pattern. Non-Recursive Post Order Depth First Traversal in C# - RemLog. I was looking around for a non-recursive post-order traversal algorithm and it turned out to be more complex than I thought which surprised me. I mean a recursive post order depth first traversal is so simple. static void recursivePostOrder(Node node) { foreach (var n in node.Children) { recursivePostOrder(n); } // Do action Console.WriteLine(node.Id); } static void preOrder(Node root) { Stack<Node> s = new Stack<Node>(); s.Push(root); while (s.Count > 0) { var n = s.Pop(); // Do Action Console.Write(n.Id); foreach (var child in n.Children.ToArray().Reverse()) { s.Push(child); } } } private static void nonRecursivePostOrder(Node root) { var toVisit = new Stack<Node>(); var visitedAncestors = new Stack<Node>(); toVisit.Push(root); while (toVisit.Count > 0) { var node = toVisit.Peek(); if (node.Children.Count > 0) { // PeekOrDefault is an extension helper, see full program below if (visitedAncestors.PeekOrDefault() !

There are multiple algorithms out there to accomplish this. We Are Not Doing DDD – Part Two - CQS - Jak Charlton - Insane World. From the beginning of my current project we have been working under some horrible constraints, many imposed by legacy systems, many by late decisions that would have speeded things immensely if made earlier, and many imposed by decisions that are outside of my control. This lead us early on to make decisions on architecture that eliminated any possibility of using DDD heavily, and as I mentioned in my original post about this project it is also essentially a glorified CRUD system - we read data from databases, we modify it a bit, and we put it back again.

What We Are Doing – Command Query Separation The first architectural choice that I made, and in hindsight got accepted with relative ease, was to employ CQS to simplify the system. Earlier projects had suffered quite badly from being abstractions of legacy systems with new functionality bolted on. As CQS is a pretty simple concept. Querying The Query side deals largely in DataTables, DataSets and a very very limited number of DTOs. Command.

Nhibernate - How is Command Query Separation (CQS) implemented when using an ORM. Strengthening your domain: Avoiding setters. Previous posts in this series: As we start to move our domain model from an anemic existence towards one with richer behavior, we start to see the aggregate root boundary become very well defined. Instead of throwing a bunch of data at an entity, we start interacting with it, issuing commands through closed, well-defined operations. The surface of our domain model becomes shaped by the actual operations available in our application, instead of exposing a dumb data object that lets anyone do anything, and consistency and validity are a pipe dream. With more and more of a behavioral model in place, something begins to look out of place. We locked down behavioral entry points into our domain model, yet left open back doors that would render all of our effort completely moot.

We forgot to address that last vestige of domain anemia in our model: property setters. Encapsulation Violated (Again) If we zoom out a bit on our Fee object, we can see that we’ve encapsulated the Payments collection: QCon San Francisco 2008 – Unleash Your Domain. The talk "Unshackle Your Domain" given by Greg Young was the highlight of QCon for me. An architectural approach that is relatively easy to understand, incredibly scalable, and supports a rich domain model. At his presentation, Greg quickly pointed out some of the problems with traditional enterprise application architecture, such as JEE. This architecture usually consists of an "object-oriented" domain model encapsulated inside a procedural service layer, persisted in a relational database, flattened out on a data entry screen by the UI layer, and crunched daily into management reports by some reporting tool. With so many masters, it's no wonder that the domain model becomes anemic and the application is hard to scale.

Greg needed something better. His key insight is that the application should explicitly model state transition commands as classes and strictly split these commands from queries on the application interface level. Command Query Separation | Dude, where is my Kaizen? Does this sound familiar to you? From time to time someone delivers you answers to questions that have been on your mind for quite a while. You didn’t find an answer on your own and most of the people you talked with either didn’t care or hadn’t satisfying answers for you.

When you finally hear the answers you were searching for, you’re … stunned how simple the actual solution is,wondering why you weren’t able to solve that on your own,nevertheless happy and thankful to finally see the missing piece in your puzzle. Today I had the luck to be able to talk with Gregory Young about (Distributed) Domain Driven Design in general and in particular some about questions regarding bidirectional mapping from domain object to DataTransferObject, and how messaging or eventing integrates with DDD. This is what I took from that discussion … At first there was the problem … It’s widely accepted and adopted that domain objects should not be used for displaying data in the UI. . … and then came the solution: The repository pattern explained and implemented | Lowendahl's Shout. The pattern documented and named “Repository” is one of the most misunderstood and misused.

In this post we’ll implement the pattern in C# to achieve this simple line of code: var customers = customers.Matching(new PremiumCustomersFilter()) as well as discuss the origins of the pattern and the original definitions to clear out some of the misrepresentations. The formal description My first contact with the repository pattern was through the study of Domain Driven Design. In his book[DDD] (p. 147), Eric Evans simply states that; Associations allow us to find an object based on it’s relationships to another. My interpretation of the section on repositories is simple, the Domain do not care about where the objects are stored in the middle of it’s life cycle but we still need a place in our code to get (and often store) them. In Patterns of Enterprise Application Architecture[PoEAA] (p. 322), repositories is described as: With these principles and descriptions this simple rule emerges: Or:

Employing the Domain Model Pattern. Domain Models Employing the Domain Model Pattern Udi Dahan In this article, we’ll go through the reasons to (and not to) employ the domain model pattern, the benefits it brings, as well as provide some practical tips on keeping the overall solution as simple as possible. If you had come to me a few years ago and asked me if I ever used the domain model pattern, I would have responded with an absolute "yes. " But, I would have been completely wrong. My understanding has evolved over the years, and I've gained an appreciation for how an application can benefit from aligning itself with those same domain-driven principles. In this article, we'll go through why we'd even want to consider employing the domain model pattern (as well as why not), the benefits it is supposed to bring, how it interacts with other parts of an application, and the features we'd want to be provided by supporting technologies, and discuss some practical tips on keeping the overall solution as simple as possible.

A response to Validation in a DDD world. Jimmy Bogard presented a well written argument for always keeping validation out of entities in a domain driven design except in "the absolute worst case. " But, IMO, there is simply no black and white verdict on where validation must live in a DDD application and must be carefully considered at the beginning of any project, taking into consideration the motivations behind validation, the scope of the project, the maturity of the development team, and the balance between philosophical purity and practical maintainability. There are two clear project scenarios which come to mind when I try to answer where validation should live. The first is wherein a DTO layer is used to transfer information between the view and domain layers.

For example, you may have a Customer object in your domain layer and an associated Customer DTO in another layer to which you map the Customer information, to then give to the view for presenting Customer information to the user. Billy McCafferty.