Tag Archives: C++Builder

Using Model-View-ViewModel (MVVM) in Delphi FireMonkey

Description: How to use Model-View-ViewModel (MVVM) in Delphi (Separating Logic from UI) for maintainability, testability and dependability.
Objective:  Making your application more maintainable, unit-testable, and multi-device capable.
Presenter:  Malcolm Groves from Embarcadero, Jeffrey Lefebvre – Skyline Aviation Software.
Software Versions Supported:  All versions.
Event: CodeRage 7 & 8
Level: Intermediate

Code re-usability and faster product delivery time are two of the many benefits of Rapid Application Development (RAD) IDEs such as RAD Studio and Appmethod.  However on the down side, RAD methodology which allows for minimal planning in favor of rapid prototyping can compromise best coding practises. Poor or no project planning for scalability can compromise software quality, especially in areas of maintainability, testability and dependability.

Code re-usability can be applied at various levels.  There are re-usable visual controls and components at the User Interface (UI) level.  FireMonkey controls, not only allow for reuse in multiple projects on the same platform, but across multiple platforms (Android, iOS, Mac OS and Windows).  As software projects expands (like they normally do), a well designed project should account for scaling and loosely coupled libraries that can be reused and easily tested. This reusing of libraries is at the model and business logic level.

One of the design patterns that accomplishes reusability and testability by separating logic from UI is the Model–view–controller (MVC).   MVC  designs software application into three interconnected parts:  the model (application data, business rules, logic and functions), the view (output representation — User Interface) and  controller which connects the model to the view by accepting input and converting them to commands for the model or view.


In the following video, Malcolm Groves from Embarcadero discusses how to use Model-View-ViewModel (MVVM) in Delphi.  The MVVM architectural pattern originated from Microsoft  and is largely based on the model–view–controller (MVC) pattern.  MVVM is a specific implementation targeted at UI development platforms with event-driven programming such as Windows Presentation Foundation (WPF) and FireMonkey.


Jeffrey Lefebvre from Skyline Aviation Software also did a great session on maintainable code – Separating Logic from UI. He discusses techniques for creating new applications with logic separated from UI and tips on transplanting logic from UI into its own units.