Posts

Showing posts from January, 2026

Nugget 16: Mediator Pattern in MVVM

Image
  Problem As this little experiment of mine slowly turns into a tool I use every day, some design issues are starting to show. Nothing dramatic — just the usual growing pains. In this post, I want to talk about a data‑sharing issue between ViewModels and how the Mediator Pattern helped clean things up. The symptom showed up in the Index view, where a grid lists all Job Applications. Earlier, I added date‑range filtering to that view. It works, but it also made the IndexViewModel a bit “fat.” It’s doing too many things now, and that’s something I’ll need to revisit. When the user filters by date, the grid updates correctly. But then you go to the Home page, where the chart lives, and it still loads the entire dataset. It would make much more sense for the chart to reuse the same FromDate and ToDate  and rebuild itself accordingly. That’s where the Mediator Pattern comes in. The Mediator Pattern This pattern is common in MVVM. It lets sibling ViewModels communicate without k...

Nugget 15: Make ChartJs Blazor Bars Display Reliably

Image
 Now that this application passed from a "test toy" to an everyday tool, defects are showing up.  Bug :  Accessing the Chart data after creating a new record does not load any data.  Several problems with this going from the Blazor component lifecycle to how the view model was registered in the DI container . This post works as a "release document" for the changes required.   Config Initialization Config = new BarConfig () created in the constructor and Config.Data.Labels / Config.Data.Datasets cleared. Reason : ChartJs.Blazor exposes Data as a read-only property; ensure Labels/Datasets exist before use to avoid null reference exceptions .  Remove Manual Chat Initialization In The ViewModel The model does not need to initialize the Chart.  This is because the Razor page uses @ ref=ViewModel.Chart , providing the real instance.  The rendered provides the instance when the @ref is used.  If the VM initializes the component, this can cr...

When Life Says 'Reset'

Image
Introduction I am sharing a LinkedIn post I wrote a few days after being laid off. Losing one's source of income is a difficult experience. I wrote this after hearing from colleagues who found themselves in the same position; the objective is simply to let anyone reading this know that they still matter. The Post I was laid off, and I’ve now turned on the “Open to Work” tag. I see others doing the same. The sky, however, has not fallen. My children are still lovely, and coffee still tastes great at all times of the day. What has changed is… a lot. Yes, we need to watch our purse. Readjustments are necessary. Some form of grief will take hold. And yet, we still need to get up early and face the day. So the question remains: what do we do? You and I already know the answer—nature gives us a hint. When a pathogen enters the body, the immune system mobilizes. It’s demanding, energetically expensive, and it leaves us tired. Sometimes we need help. Most importantly, we rest and nourish. ...

Nugget 14: Search By Date with Two Blazor InputDate Components

Image
  This is an enhancement to the same Blazor from previous Nuggets. This post adds two Blazor InputDate components to the Job Bank application.  It does not use an explicit callback mechanism, but property setters in the view model.  What Changed in the View The view contains two InputDate components, each bound to a property in the View Model.  This component exposes Value , ValueChanged , and supports @bind-Value .   @bind-ValueChange could be used for a change binding event, less common for Date, but available if needed.  Using this binding would require updating the ViewModel interface with a handler. How MVVMM Helps We changed the architecture in an earlier Nugget to MVVM, and now it is coming to the rescue!  These are how the controls react to user input and can stay in synch.  This is the recommended approach for dates.  Could the Boolean check boxes be done like this?  Of course! Noteworthy are the control's max/min attribut...