0%

Book Description

Explore the world of .NET design patterns and bring the benefits that the right patterns can offer to your toolkit today

About This Book

  • This book is based on the latest version of .NET, .NET Core 1.0.
  • The code is explained piece by piece and the application of the pattern is also showcased.
  • This fast-paced guide shows you how to implement the patterns into your existing applications

Who This Book Is For

This book is for those with familiarity with .NET development who would like to take their skills to the next level and be in the driver's seat when it comes to modern development techniques. Basic object-oriented C# programming experience and an elementary familiarity with the .NET framework library is required.

What You Will Learn

  • Put patterns and pattern catalogs into the right perspective
  • Apply patterns for software development under C#/.NET
  • Use GoF and other patterns in real-life development scenarios
  • Be able to enrich your design vocabulary and well articulate your design thoughts
  • Leverage object/functional programming by mixing OOP and FP
  • Understand the reactive programming model using Rx and RxJs
  • Writing compositional code using C# LINQ constructs
  • Be able to implement concurrent/parallel programming techniques using idioms under .NET
  • Avoiding pitfalls when creating compositional, readable, and maintainable code using imperative, functional, and reactive code.

In Detail

Knowing about design patterns enables developers to improve their code base, promoting code reuse and making their design more robust.

This book focuses on the practical aspects of programming in .NET. You will learn about some of the relevant design patterns (and their application) that are most widely used. We start with classic object-oriented programming (OOP) techniques, evaluate parallel programming and concurrency models, enhance implementations by mixing OOP and functional programming, and finally to the reactive programming model where functional programming and OOP are used in synergy to write better code.

Throughout this book, we'll show you how to deal with architecture/design techniques, GoF patterns, relevant patterns from other catalogs, functional programming, and reactive programming techniques.

After reading this book, you will be able to convincingly leverage these design patterns (factory pattern, builder pattern, prototype pattern, adapter pattern, facade pattern, decorator pattern, observer pattern and so on) for your programs. You will also be able to write fluid functional code in .NET that would leverage concurrency and parallelism!

Style and approach

This tutorial-based book takes a step-by-step approach. It covers the major patterns and explains them in a detailed manned along with code examples.

Table of Contents

  1. .NET Design Patterns
    1. .NET Design Patterns
    2. Credits
    3. Foreword
    4. About the Authors
    5. About the Reviewers
    6. www.PacktPub.com
      1. Why subscribe?
    7. Customer Feedback
    8. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    9. 1. An Introduction to Patterns and Pattern Catalogs
      1. OOP - A short history
      2. Patterns and pattern movement
        1. Key pattern catalogs
          1. GoF patterns
          2. POSA catalog
          3. POEAA catalog
          4. EIP catalog
          5. J2EE design patterns catalog
          6. DDD-based patterns
          7. Arlow/Nuestadt patterns
      3. Should we use all of these?
      4. The C# language and the .NET platform
      5. C# language and the singleton pattern
      6. Summary
    10. 2. Why We Need Design Patterns?
      1. Some principles of software development
      2. Why are patterns required?
      3. A quick foray into the .NET Reflection API
      4. Personal income tax computation - A case study
        1. Archetypes and business archetype patterns
        2. Entity, value, and data transfer objects
        3. A computation engine
        4. The application to engine communication
        5. The plugin system to make system extensible
        6. Factory method pattern and plugins
      5. Finalizing the solution
        1. Design by contract and template method pattern
        2. Using the Facade pattern to expose the computation API
      6. Summary
    11. 3. A Logging Library
      1. Requirements for the library
      2. Solutions approach
      3. Writing content to a media
        1. Template method pattern and content writers
        2. Writing a log entry to a file stream
        3. Writing a log entry to a database
        4. Writing a log entry to a network stream
        5. Logging strategy atop the strategy pattern
      4. The factory method pattern for instantiation
        1. Writing a generic factory method implementation
        2. Factory method, singleton, and prototype pattern for dynamic class loading
        3. Refactoring the code with the generic factory method
      5. A log server for network logging
      6. A simple client program to test the library
      7. Summary
    12. 4. Targeting Multiple Databases
      1. Requirements for the library
      2. Solutions approach
        1. A quick primer on ADO.net
        2. The abstract factory pattern and object instantiation
        3. The SQL server implementation
        4. The SQLite implementation
        5. The Oracle and ODBC implementation
        6. The adapter pattern powered API
        7. The adapter class Implementation
        8. The adapter configuration
        9. The client program
      3. Summary
    13. 5. Producing Tabular Reports
      1. Requirements for the library
      2. Solutions approach
      3. iTextSharp for the PDF output
      4. Composite and visitor pattern - A quick primer
      5. The composite pattern and document composition
      6. Visitor pattern for document traversal
        1. PDFVisitor for PDF generation
        2. HTMLVisitor for HTML generation
      7. The client program
      8. Summary
    14. 6. Plotting Mathematical Expressions
      1. Requirements for the expressions library and app
      2. Solutions approach
      3. The graph plotter application
      4. The observer pattern for UI events
      5. The expression evaluator and interpreter pattern
      6. The abstract syntax tree (AST)
      7. The grammar of expressions
      8. Lexical analysis
      9. The parser module
      10. The builder, facade, and expression APIs
      11. Summary
    15. 7. Patterns in the .NET Base Class Library
      1. Adapter pattern in the .NET BCL
      2. Strategy pattern in the .NET BCL
      3. Builder pattern in the .NET BCL
      4. Decorator pattern in the .NET BCL
      5. Chain of responsibility pattern in ASP.net
      6. Bridge pattern in the .NET RCW
      7. Factory pattern in the .NET BCL
      8. Observer pattern in the WPF
      9. Composite pattern in the .NET Framework
      10. Facade pattern in the .NET BCL
      11. Iterator pattern in the .NET BCL
      12. Summary
    16. 8. Concurrent and Parallel Programming under .NET
      1. Days of Free Lunch
      2. Days of Sponsored Lunch
      3. Concurrent versus parallel
      4. Some common patterns of parallel programming
        1. Embarrassingly or conveniently parallel
          1. Problem statement
          2. Solutions approach
            1. Step 1
            2. Step 2
            3. Step 3
        2. Fork/join or master/worker
      5. Speculative execution
        1. Producer/consumer
      6. Summary
    17. 9. Functional Programming Techniques for Better State Management
      1. Being functional
      2. Referential transparency
      3. First-class and higher-order functions
        1. Function type
      4. Lambda (λ) calculus
        1. Anonymous functions
        2. Closures
        3. Currying and partial application
          1. Currying
          2. Partial application
          3. Applying currying and partial application
        4. Expression trees
      5. Recursion
      6. Sample programs
        1. Spell checker
        2. Subset generation
      7. How does LINQ work?
      8. Summary
    18. 10. Pattern Implementation Using Object/Functional Programming
      1. A strategy pattern implementation using FP/OOP
        1. Using FP constructs to make the code better
      2. A fresh look at the iterator pattern using FP/OOP
      3. MapReduce programming idiom
      4. A new spin on the template method pattern using FP/OOP
        1. Using FP for the template method pattern implementation
        2. A quick note on the observer pattern
        3. Does FP replace GoF patterns?
      5. Summary
    19. 11. What is Reactive Programming?
      1. Being reactive
      2. Electronic spread sheets - A quintessential example
      3. Reactive programming model
      4. Functional reactive programming
        1. Reactive programming principles
      5. Rx from Microsoft
        1. Key data structures of Rx
        2. IEnumberable/IObservable duality
      6. Converting entities to streams (IObservable<T>)
        1. Converting events into stream
        2. Reduction of streams (sequences)
        3. Inspection of streams (sequences)
        4. Aggregation of streams (sequences)
        5. Transformation of streams (sequences)
        6. Combining streams (sequences)
      7. A philosophy for reactive programming
      8. Summary
    20. 12. Reactive Programming Using .NET Rx Extensions
      1. Streams as a way of life
      2. Spell checker using events composition
      3. MVVM on Rx
      4. An asynchronous logger
      5. Near real-time visualizer/dashboard
      6. Summary
    21. 13. Reactive Programming Using RxJS
      1. The JS world
      2. Rx foundations
      3. RxJS formalism
        1. Observables and observers
        2. Observables from arrays
        3. Observables from events
        4. Observables from callbacks
        5. Observable pipeline
        6. Subject et al.
        7. Schedulers
      4. RxJS samples
        1. Real-time file watcher
        2. Change galore
      5. Summary
    22. 14. A Road Ahead
      1. Polyglot programming and design
        1. Polyglot programming with C/C++
        2. The polyglot web programming
          1. The JavaScript evolution
          2. Dynamic/scripting languages
          3. Emergence of functional programming
          4. Mobile revolution
        3. A quick note on polyglot persistence
        4. How to become a polyglot programmer?
      2. Domain-specific languages
      3. Ontology
      4. AntiPatterns
      5. Summary
3.15.168.203