11# Techsenger MVVM4FX
22
3- Techsenger MVVM4FX is a tiny framework for developing JavaFX applications using the MVVM pattern. It provides all
4- the necessary interfaces and base class implementations for creating components, which serve as the units of the MVVM
5- pattern. Examples of components include tabs, dialog windows, toolbars, image viewers, help pages, and more.
3+ Techsenger MVVM4FX is a compact, practical framework for building JavaFX applications with the MVVM pattern.
4+ It provides practical solutions to the most challenging problems of MVVM, including dynamic component composition,
5+ lifecycle management, and component state ownership. The framework supplies all necessary interfaces and base class
6+ implementations for creating components, which serve as the fundamental units of the MVVM pattern. Examples of
7+ components include tabs, dialog windows, toolbars, image viewers, help pages, and more.
68
79As a real example of using this framework, see [ TabShell] ( https://github.com/techsenger/tabshell ) project.
810
@@ -29,15 +31,20 @@ As a real example of using this framework, see [TabShell](https://github.com/tec
2931
3032## Overview <a name =" overview " ></a >
3133
32- MVVM4FX reimagines the ` Model ` –` View ` –` ViewModel ` pattern for JavaFX as a component-based, extensible platform designed
33- around clarity, modularity, and the KISS principle. Each ` Component ` exists as a self-contained unit composed of a
34- ` View ` , ` ViewModel ` , ` Mediator ` optionally extended with ` History ` .
35-
36- The framework enforces a strict separation between presentation, logic, and identity. The ` View ` defines the visual
37- structure and behavior; the ` ViewModel ` encapsulates logic and state; the ` Component ` is responsible for initialization
38- and deinitialization, managing child components, and their composition, operating at the component level. The
39- ` ComponentMediator ` is the interface through which the ` ViewModel ` interacts with the ` Component ` , and the ` History `
40- preserves continuity across sessions.
34+ MVVM4FX reimagines the Model–View–ViewModel pattern as a component-based framework designed around clarity, modularity,
35+ and the KISS principle for building complex, dynamic JavaFX applications. It addresses the most fundamental limitation
36+ of classical MVVM — dynamic component composition and lifecycle management — by introducing an explicit, imperative
37+ component layer responsible for the creation, ownership, and lifetime of components. Each ` Component ` exists as a
38+ self-contained architectural unit composed of a ` ComponentView ` , ` ComponentViewModel ` , and ` ComponentMediator ` ,
39+ optionally augmented with ` ComponentHistory ` .
40+
41+ The framework enforces a strict separation of responsibilities:
42+ - ` Component ` defines the identity and manages lifecycle, initialization/deinitialization, and composition of child
43+ components;
44+ - ` ComponentView ` defines the visual structure and behavior;
45+ - ` ComponentViewModel ` encapsulates logic and state;
46+ - ` ComponentMediator ` provides a controlled interaction channel between the ` ComponentViewModel ` and the ` Component ` ;
47+ - ` ComponentHistory ` preserves continuity across sessions.
4148
4249At its core, MVVM4FX follows the KISS principle – every class, method, and abstraction exists only for a clear reason,
4350avoiding unnecessary complexity or dependencies. This simplicity is deliberate: it keeps the architecture transparent,
@@ -135,6 +142,14 @@ The `ComponentView` and `ComponentViewModel` classes correspond to the `View` an
135142are relatively straightforward. The ` Component ` and ` ComponentMediator ` classes, on the other hand, address the
136143aspects that MVVM does not cover and are therefore more complex, which is why they are explained in detail below.
137144
145+ The ` Component ` forms a very thin, structural layer of a higher order than the ` View ` , which allows it to add child
146+ components to its ` View ` . A ` Component ` always operates strictly at the component level and deliberately does not take
147+ initiative. Its sole responsibility is to perform operations requested by its clients—either directly or via the
148+ ` Mediator ` . For example, it can create a child component and place it in its ` View ` , but only when the ` ViewModel `
149+ commands it to do so through the ` Mediator ` . Since the ` Component ` has the greatest capabilities, it is important to
150+ remember that its responsibilities are very limited, to prevent the ` Component ` from turning into a God object and
151+ violating MVVM responsibility principles.
152+
138153The ` Component ` is responsible for:
139154
1401551 . Initializing and deinitializing the component.
@@ -145,17 +160,11 @@ The `Component` is responsible for:
145160 - Lifecycle data (component state);
146161 - Metadata (component ID, type, version, etc.).
1471623 . Creating, initializing, adding to the component tree, removing from the component tree, and deinitializing
148- child components (those that reside directly inside this component).
163+ child components (those that reside directly inside this component). It can also add or remove child components in
164+ its ` View ` .
1491654 . Creating, initializing, and passing derived components to other components for further management
150166 (e.g., dialogs, tabs, system notifications).
151167
152- Thus, a ` Component ` always operates strictly at the component level and is intentionally non-initiative. A ` Component `
153- does not make decisions and does not trigger application behavior. Its sole responsibility is to execute operations
154- requested by its client or by the ` View ` or ` ViewModel ` through the ` Mediator ` . In other words the ` Component ` and
155- ` Mediator ` form a very thin layer that performs what the ` ViewModel ` cannot do and what is not the responsibility of
156- the ` View ` . It is important to keep this in mind to prevent the ` Component ` from turning into a God object and
157- violating MVVM responsibility principles.
158-
159168The ` ComponentMediator ` is the interface that the ` ViewModel ` uses to interact with the ` Component ` . This interface
160169is needed for two reasons: first, it allows the ` ViewModel ` to be tested independently; second, it allows the
161170` ViewModel ` to use the ` Component ` without knowing the View, since the Component has knowledge of the View.
0 commit comments