Chapter 4 – Implementing Design Patterns – Basics Part 2

  1. Provide an example to show why using a singleton would not be a good mechanism for limiting access to a shared resource?

A singleton intentionally creates a bottleneck in an application. It is also one of the first patterns developers learn to use and, because of this, it is often used in situations where limiting access to the shared resource is not required.

  1. Is the following statement true? Why or why not? ConcurrentDictionary prevents items in the collection from being updated by more than one thread at a time.

For many C# developers, realizing that ConcurrentDictionary does not prevent items in the collection from being updated by more than one thread at a time is a painful lesson. ConcurrentDictionary protects a shared dictionary from being accessed and modified concurrently.

  1. What is a race condition and why should it be avoided?

A race condition is when the order of processing of multiple threads can culminate in different results.

  1. How does the factory pattern help simplify code?

The factory pattern is an effective way to decouple the creation of objects within an application.

  1. Do .NET Core applications require third-party IoC containers?

.NET Core has a powerful Inversion of Control built into the framework. It can be enhanced when required by other IoC containers, but is not required.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.183.172