By design, a program is usually based on a layered architecture to allow reusability and facilitate teamwork and testing. We may employ the following layered models:
- PLD: Presentation, logic(business logic, services), data
- MVVM: Model, View, and View Model
- What programming language constructs can be used to implement program-layered architecture?
- What is the relationship between MVVM and PLD programming patterns?

Mariusz PostolPosted Jun 12, 2024, 2:16 PM
@Chetan Sanghani many thanks for the answer. I appreciate. Unfortunately, I have some doubts concerning this answer.
1. Instantiating classes create objects. It is the run-time stage of the program life cycle so it cannot contribute to the program architecture at design time. Some languages contain Objects as a reference type, but this is not the case as far as I understand.
2. Why only classes and interfaces? My point is that the other custom types can also contribute to the program architecture.
3. Inheritance and Polymorphism are paradigms of the object-oriented programming concept and as a result cannot directly contribute to the program architecture.
4. "Dependency Injection (DI)" and "Event-driven Programming" are independent programming patterns, so we can use them to solve dedicated problems, for example, layers communications but not the layered architecture itself.
You said that "MVVM (Model-View-ViewModel) and PLD (Presentation-Logic-Data) are both layered architecture patterns commonly used ..." If they are commonly used there must be a relationship between them. What about recognizing MVVM as sublayers of the Presentation layer?
For me, the question remains open.
Chetan SanghaniPosted Jun 11, 2024, 5:02 PM
To implement a program with a layered architecture, various programming language constructs can be used. Here are some common constructs along with their roles in implementing layered architectures:
Classes and Objects: Object-oriented programming languages like C#, Java, and Python allow you to define classes and objects. You can use classes to represent the different layers of your application (e.g., presentation layer, business logic layer, data access layer) and define their behavior and interactions.
Interfaces: Interfaces define contracts for behavior, allowing you to decouple different layers of your application. By defining interfaces for each layer, you can ensure loose coupling and easily swap out implementations. This facilitates testing and enables different teams to work independently on each layer.
Inheritance and Polymorphism: Inheritance allows you to create specialized classes that inherit behavior from more general classes. Polymorphism enables you to treat objects of different classes uniformly, which is useful for designing extensible and maintainable systems. These features are essential for implementing variations of layered architectures, such as MVVM and PLD.
Dependency Injection (DI): Dependency Injection is a design pattern that allows you to inject dependencies into a class rather than creating them internally. DI promotes loose coupling and facilitates testing and reuse. You can use DI frameworks or implement DI manually using language constructs like constructor injection, method injection, or property injection.
Event-driven Programming: Events and delegates (as mentioned earlier) are language constructs commonly used in event-driven programming models. They facilitate communication between different components of your application, enabling loosely coupled interactions. Event-driven programming is especially relevant for implementing user interface interactions in layered architectures.
Regarding the relationship between MVVM and PLD programming patterns:
MVVM (Model-View-ViewModel) and PLD (Presentation-Logic-Data) are both layered architecture patterns commonly used in software development. While they have similar goals of promoting reusability, facilitating teamwork, and improving testability, they have different focuses and implementations.
MVVM: MVVM is a design pattern specifically tailored for user interface development. It separates the user interface into three components: Model, View, and ViewModel. The Model represents the data and business logic, the View represents the user interface, and the ViewModel serves as an intermediary between the Model and the View. MVVM is commonly used in frameworks like WPF (Windows Presentation Foundation) and AngularJS.
PLD: PLD, on the other hand, is a more general layered architecture pattern that can be applied to various types of applications, not just user interfaces. It divides the application into three layers: Presentation, Logic (Business Logic or Services), and Data. The Presentation layer is responsible for user interaction, the Logic layer contains the business logic and application services, and the Data layer handles data access and storage. PLD can be implemented using various programming paradigms and frameworks.
While MVVM is focused on separating concerns in user interface development, PLD provides a broader framework for structuring applications in a modular and maintainable way. The two patterns can complement each other, with MVVM being used within the Presentation layer of a PLD architecture to handle user interface concerns.