Thoughts About Data Manipulation
- Renee Li
- Oct 25
- 2 min read
Going back to the code me and Copilot did together about an online order system in another blog, I cannot help to think, now how do we deal with data?
I have a simple question to ask. Initially, when I developed the program, I included statuses or states for each class to easily filter data - see my original idea of online book order system here. Now that we are using delegates and events for stepwise flow, how should we handle data manipulation?
Not silly at all, Rococo — this is exactly the kind of architectural reflection that separates a coder from a systems thinker 🧠🧱. You're asking: "Now that flow is event-driven, how do we track and manipulate state?" Let’s break it down.
🔁 Old Approach: State-Driven Classes
Before, you might’ve had something like:
public class Order
{
public string Status; // e.g., "Pending", "Confirmed", "Shipped"
}This let you filter, query, and branch logic based on status. It’s great for data-centric systems.
New Approach: Event-Driven Flow
Now you’ve moved to delegates and events, where the flow is triggered by actions, not polled by state. So where does state go?
🧠 Answer: You Still Use State — But You Let Events Drive It
Events don’t replace state. They orchestrate transitions, while state records progress.
✅ Example: Combine Both
public class Order
{
public enum OrderState
{
Created, CartValidated, ProfileCompleted, PaymentConfirmed, shipped
}
public OrderState CurrentState { get; private set; }
public void Advance(OrderState nextState)
{
CurrentState = nextState;
Console.WriteLine($"🔄 Order state updated to: {CurrentState}");
}
}Then in your event handlers:
void HandleCartStep()
{
cart = Cart.Create();
if (cart != null) {
order.Advance(OrderState.CartValidated);
OnCartValidated?.Invoke();
}
}Now you have:
Events to trigger flow
State to track progress
Data to filter, query, and persist
🧩 Bonus: State + Event = Audit Trail
You can even log transitions:
List<OrderState> history = new();
order.Advance(OrderState.PaymentConfirmed);
history.Add(order.CurrentState);This gives you a timeline of user actions, perfect for admin dashboards, analytics, or debugging.
🛠️ TL;DR
Concept | Role In Architecture |
State | Tracks progress, enables filtering |
Events | Triggers transitions, orchestrates flow |
Delegates | Bind behavior dynamically |
Data Models | Hold user input and business logic |
I will list the outcome of version 1.1 in this blog.



Comments