concept pattern in category .net

appears as: patterns, patterns, pattern, The pattern, pattern, The patterns, A pattern
Concurrency in .NET

This is an excerpt from Manning's book Concurrency in .NET.

In this chapter we’ll look in more detail at the main FP principles that help in our quest to write high-quality concurrent applications. You’ll learn what the principles are, how they work in both C# (as far as possible) and in F#, and how they fit into the patterns for parallel programming.

Listing 3.13  Representation of a list in F# using discriminated unions
type FList<'a> =
 | Empty   #1  
 | Cons of head:'a * tail:FList<'a>   #2  

let rec map f (list:FList<'a>) =   #3  
    match list with
    | Empty -> Empty
    | Cons(hd,tl) -> Cons(f hd, map f tl)

let rec filter p (list:FList<'a>) =
    match list with
    | Empty -> Empty
    | Cons(hd,tl) when p hd = true -> Cons(hd, filter p tl)
    | Cons(hd,tl) -> filter p tl

#1   Empty case
#2   Cons case has the head element and the tail
#3   Recursive function that traverses a list using pattern matching to deconstruct and performs a transformation on each item

The purpose of task parallelism is to tackle these scenarios, providing you, the developer, with a toolkit of practices, patterns, and, in the case of programming, the .NET Framework, a rich library that simplifies task-based parallel programming. In addition, FP eases the compositional aspect of tasks by controlling side effects and managing their dependencies in a declarative programming style.

Figure 13.18 The pipeline processing pattern is useful when you want to process data in multiple steps. The idea behind the pattern is that inputs are sent to the first agent in the pipeline. The main benefit of the pipeline processing pattern is that it provides a simple way to balance the tradeoff between overly sequential processing (which may reduce performance) and overly parallel processing (which may have a large overhead).

c13-18.png
Dependency Injection in .NET

This is an excerpt from Manning's book Dependency Injection in .NET.

Dependency Injection is a set of software design principles and patterns that enable us to develop loosely coupled code.

In contrast to the hardwired hair dryer, plugs and sockets define a loosely coupled model for connecting electrical appliances. As long as the plug fits into the socket, we can combine appliances in a variety of ways. What’s particularly interesting is that many of these common combinations can be compared to well-known software design principles and patterns.

NHibernate in Action

This is an excerpt from Manning's book NHibernate in Action.

In this section, we walk through some features indispensable to implementing a successful application. First, we give some examples illustrating the fundamental differences between objects and relational database. You’ll also learn how NHibernate helps create a bridge between these representations. Then, we turn to the persistence layer to discover how NHibernate deals with complex and numerous entities. You’ll learn the patterns and features it provides to achieve the best performance. Finally, we cover complex queries; you’ll see that you can use NHibernate to write a powerful search engine.

Before we go any further, an introduction to patterns, DDD, and TDD is required.

If you haven’t studied patterns before, here’s the general idea. Many problems, although different in their formulation, are solved in similar ways. Thus it’s possible to formulate a general solution that applies to many similar problems. In software, many professionals have documented the most useful patterns they’ve observed in the field, allowing them to communicate and share their knowledge with others. Hundreds of software-design patterns have been documented over the years, and throughout this section we give references to books and articles we consider important.