Posts

Showing posts from September, 2024

Introducing Materialize and Dematerialize Operators in C# Observable

  If you've been working with Reactive Extensions (Rx) in C for a while, you’re probably comfortable using operators like `Select`, `Where`, and `Subscribe`. But did you know that two lesser-known but incredibly useful operators give you deeper control over observables? Today, we're going to explore Materialize and Dematerialize. Don’t worry if they sound a bit scary—by the end of this post, you’ll see how these operators can make your life easy by debugging and handling errors much easier. Terms like Observable, Observer, and Subject are from the  Observer Design Pattern .   So, What Do Materialize and Dematerialize Even Do? Let’s start with Materialize. Normally, when you’re working with an observable, it emits data, completes, or throws an error. What Materialize does is convert all those events (values, errors, completions) into a `Notification<T>` object. It’s like converting each event into a form that you can inspect and manipulate.   On the othe...

Practical Example To Visualize Entities In Live Application Using MSAGL

Image
Finding it difficult to understand the complex relationship between the different objects which are part of an application? Think of Visualizing the objects and their state when the application is running, Seems exciting right?  Yes, It's possible with the little help from MSAGL(Microsoft Automatic Graph Layout) and some boilerplate code to do that. I have created a sample application demonstrating how it can be done, including the state of these objects in a live manner. I would recommend you to go through MSAGL Basics Check out the video here: Check out the code here: using Microsoft.Msagl.Drawing; using System; using System.Collections.Generic; using System.Linq; using System.Threading; namespace MSAGL_Demo { public interface INodeRepository { void AddNode(Node node); void OnActiveNodeChanged(string obj); } public class NodeRepository : INodeRepository { private IList<Node> nodes = new List<Node>(); private Graph g = null; public NodeReposito...

Understanding the Curiously Recurring Template Pattern (CRTP) in C++: Interesting Comparison with Virtual Functions

Introduction In the world of C++ programming, there are certain patterns that stands out because of their performance efficiency and their peculiar solution. A common technique (or pattern) is the Curiously Recurring Template Pattern (CRTP). If you want to become an expert on the most advanced techniques as a C++ developer, CRTP is something you need to know. This post digs into what CRTP is, why you need it and what it allows you to do vs more typical virtual function implementations. When you're finished, you'll understand how CRTP functions and why you might want to use it in your projects. Table Of Contents 1. Curiously Recurring Template Pattern (CRTP) 2. Why is CRTP Needed? 3. How CRTP Works From the Inside 4. Here we have a detailed comparison of how CRTP does versus virtual member functions. 5. Benefits of Using CRTP 7. Pitfalls and Considerations When Using CRTP 8. Conclusion 9. FAQs     1. What is The Curiously Recurring Template Pattern (CRTP) Curiously Re...