Rule-Based Architectural Design Pattern Recognition with GPT Models
Abstract
:1. Introduction
- a classification of MVW design patterns for Angular application development with formal definitions and examples;
- a rule-based approach for detecting MVW design patterns in Angular applications using GPT models;
- the results of the accuracy attained in design pattern detection with GPT models;
- the distribution of MVW design patterns in Angular development.
2. Related Work
3. Materials and Methods
3.1. MVW Taxonomy for Frontend Frameworks
3.1.1. Smalltalk-80 MVC
- If View does not require additional attributes, the entire logic can be governed by domain data.
- If change detections can be managed using component-implemented functions rather than the Angular engine.
- Model: in a form of a service and an interface or class describing the entity’s properties and methods.
- View: UI that is visible to the user and display domain data.
- Controller: responsible for receiving the user input and manipulating domain data.
- User input is transmitted to the Controller, which manipulates the Model based on the input.
- The Domain model modifies and alters View-displayed properties.
- View displays domain data.
- A straightforward implementation consisting of the required properties and methods.
- The source code is easy to understand and the applications can be thoroughly tested.
3.1.2. HMVC
- Model: a service and interface or class that describes an entity’s properties and methods.
- View: UI that is visible to the user and displays domain data.
- Controller: responsible for receiving user input and manipulating domain data. Controllers at a lower level in the hierarchy receive input data and propagate output data. Higher-level controllers that implement entire pages send data to lower-level controllers that implement only a portion of the page and may manipulate a portion of the domain data. The highest-level controller receives data segments and merges them.
- User input is sent to the Controller, which evaluates it and modifies the Model based on the input.
- Domain model changes and modifies properties that are propagated to sub-controllers and returned to higher-level controllers.
- View displays a portion of the domain data.
3.1.3. MVA
- Model: in the form of a service and interface or class that describes the entity and its properties and methods. It modifies the domain entity properties and inferred properties within the Adapter.
- View: the UI component that displays the domain data and the adapter’s properties.
- Adapter: receiving user input and processing domain data.
- User input is transmitted to the Adapter, which manipulates the Model based on the input.
- The Domain model modifies and alters displayed properties.
- Properties of an adapter are inferred from domain data.
- View displays the domain data and the Adapter’s properties.
- Variables and properties are managed by multiple components, resulting in a more complicated implementation.
- Multiple UI module attributes are maintained in a centralized location.
3.1.4. MGM
- Model: a service and interface or class describing the entity’s properties and methods. It modifies the Adapter’s domain entity properties and inferred properties.
- GUI: UI that is visible to the user and presents widget components collectively. It is responsible for notifying the Mediator and transmitting user input.
- Mediator: It manages a specific complex GUI and its content via a Model that is only a portion of the entire domain entity and does not include other UI widgets.
- User input is transmitted to the Mediator, which manipulates Model based on the input.
- The Domain model modifies and alters View-displayed properties.
- Properties of an adapter are inferred from domain data.
- View displays the domain data and Mediator’s properties.
- Complex UI widgets are simpler to comprehend and maintain.
- Component is reusable in other sections of the project.
- Ionic framework popup implementations.
- Angular Material mat-table implementation.
3.1.5. Application Model
- With data binding, data can be sent to the controller and returned to the view without the need for additional function implementations.
- There are distinct View objects created in the business logic that are served by the domain model. These objects are Application Model properties. Additionally, the domain model can be retained and utilized. It has a loose structure overall.
- Model: a service and interface or class describing the entity’s properties and methods. It updates the Application Model’s domain entity properties and objects.
- View: UI that is visible to the user and displays elements containing data.
- Application Model: objects created for the View and supplied data from the domain. It only affects the behavior of UI elements.
- Controller: This component manages user input and receives model updates. It is only applicable to the domain model.
- User input is transmitted to the Controller, which manipulates the Model based on the input.
- Domain model modifications and updates are returned to the Controller, and the Application Model is also updated.
- Application Model properties are behavioral properties of UI widgets that are inferred from domain data.
- View displays the domain data and Application Model properties.
- Separate logic for the displayed data.
- Difficulty in maintaining domain model and view consistency.
3.1.6. Microsoft MVVM
- With data binding, data can be sent to the ViewModel and returned to the view without the need for additional function implementations.
- Additional properties required by the view are not maintained in separate objects; rather, the developer is provided with an unstructured and expanded structure.
- Model: a service and interface or class defining the entity’s properties and methods. It synchronizes the ViewModel.
- View: UI that is visible to the user and displays elements containing data.
- ViewModel: a replica of the domain model with view-specific properties added.
- Data binding transfers user input to the ViewModel. ViewModel processes it and manipulates Model.
- Domain model modifications are communicated back to the ViewModel.
- ViewModel duplicates the domain entity and extends or transforms the data so that they are suitable for the View. It refreshes the View.
3.1.7. Dolphin Smalltalk MVP
- User input must be validated prior to Model modification, and the result must be presented to the user.
- View serves only for presentation purposes; intricate logic is left to the Presenter.
- Model: a service and interface or class specifying the entity’s properties and methods.
- View: UI that is visible to the user and displays elements containing data.
- Presenter: receives user input, validates it, and alters the Model if the input is legitimate; the View also displays this result.
- Data binding is used to transmit user input to the Presenter. Presenter processes it and manipulates Model if data are valid.
- Domain model modifications are transmitted back to the Presenter.
- View only displays data and validation results from user input.
3.1.8. Supervising Controller
- Domain data may need to be extended with UI behavior that is not dynamically derived from the domain entity’s values.
- Application development if review procedures are time-consuming.
- Model: a service and interface or class that describes the entity, its properties and methods, and potentially the behavioral properties of the UI elements.
- View: User interface that is visible to the user and displays elements containing data.
- Presenter: receives user input, validates it, and alters the Model if the input is valid; the View also displays this result.
- User input is forwarded to the Presenter by data binding. Presenter processes it and manipulates Model if data are valid.
- Domain model changes occur and updates are sent back to the Presenter. If there are properties in domain data that refer to other properties, they can be updated immediately.
- View presents data and behavioural properties based on the stored data and the results of the user input validation.
3.1.9. Passive View
- Model: a service and interface or class describing the entity’s properties and methods.
- View: UI widget references that must be visible to the user.
- Presenter: receives user input, validates it, and updates Model if input is valid; has complete control over the states and controls of UI widgets.
- Data binding is used to transmit user input to the Presenter. If data are valid, Presenter processes it and manipulates Model. Moreover, Presenter entirely controls the View elements.
- Domain model modifications are transmitted back to the Presenter.
- View has no control and only a reference to the visible UI element.
- Easy to make spaghetti code.
- Provide increased implementation flexibility for the UI.
3.2. Rule-Based Design Pattern Identification in Angular Projects
- Q1: What functions do the interconnected files serve?
- Q2: What responsibilities do the interconnected files have?
- Q3: What are the relationships and orientations of file-to-file communication?
3.3. MVW Dataset and Evaluation with GPT Models
4. Results
4.1. RQ1: MVW Design Pattern Detection in Angular Projects
4.2. RQ2: Most Typical MVW Design Pattern in Angular Application Development
4.3. RQ3: Recommendations for Using MVW Design Patterns in Angular Application Development
4.3.1. Smalltalk-80 MVC
4.3.2. HMVC
4.3.3. MVA
4.3.4. MGM
4.3.5. Application Model
4.3.6. Microsoft MVVM
4.3.7. Dolphin Smalltalk MVP
4.3.8. Supervising Controller
4.3.9. Passive View
4.4. RQ4: Future Potentials Based on the Results
5. Discussion
6. Study Limitations
7. Conclusions
Supplementary Materials
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
Appendix A
Design Patterns | Rules |
---|---|
Smalltalk-80 MVC | R1: View (HTML) presents domain data but data can be modified via events (e.g., methods in the component (implemented in TypeScript)) and not via two-way data binding. |
R2: Component file (TypeScript) works with domain data in its original form, there is no transformation of it, and additional attributes cannot be present in the View (HTML). | |
R3: View (HTML) properties (e.g., color) are not part of the domain model. | |
R4: There are no @Input() and/or @Output() decorators for sending domain data between user-defined components. Also, there are no input and output directives in the View (HTML) as user-defined component selectors. | |
HMVC | R5: Component file (TypeScript) contains @Input() and/or @Output() decorators and domain data are transmitted through component parameters, or in the View (HTML), user-defined component selectors have input and/or output directives. |
R6: Component file (TypeScript) is working with a smaller part of a domain entity; the entire domain entity is not present in the component. Only some properties of the entity are in use. | |
R7: Component file (TypeScript) works with domain data in its original form, there is no transformation of it, and additional attributes cannot be present in the View (HTML). | |
MVA | R8: Domain model data are transformed for a different visualization purpose and the variable containing the transformed value is used in the View (HTML). |
R9: Domain model data transformations are handled in one component that is responsible for an entire page and contains multiple widgets. | |
MGM | R10: Domain model data are transformed for a different visualization purpose and the variable containing the transformed value is used in the View (HTML). |
R11: Domain model data transformation is handled in a component that is responsible only for a given UI widget. |
Design Patterns | Rules |
---|---|
Application Model | R12: UI widget (HTML) attributes are parts of the Application Model declared in the Component file (TypeScript). |
R13: UI widget (HTML) attributes (e.g., CSS class, color, size, etc.) are set based on the values of the domain model attributes. Only UI widget (HTML) attributes that change the behavior of the content are valid here. | |
R14: UI widget (HTML) attributes are not part of the domain model; these properties can be only present in the Component file (TypeScript). | |
R15: There are multiple Application Model attributes (declared in the TypeScript code) that refer to the same domain model attribute (e.g., value and color attributes in the Application Model refer to the value in the domain model). | |
Microsoft MVVM | R16: The Component file (TypeScript) acts as an interface between the domain model and the View (HTML). It should encapsulate any logic needed to convert the domain model data into a form that is suitable for the View (HTML). |
R17: UI widget (HTML) attributes are not part of the domain model; these properties can only be present in the Component file (TypeScript). | |
R18: The changes in the ViewModel (Component) attribute values trigger data retrieval from the Model and the View (HTML) is updated through data binding. |
Design Patterns | Rules |
---|---|
Dolphin Smalltalk MVP | R19: Input fields are checked with validators in the component file (TypeScript code), e.g., FormControl value validations. |
R20: UI widget (HTML) appearance (behavior) depends on the result of a validator (e.g., a button is disabled if a validator fails). | |
R21: View states (behaviors) are handled in the HTML code, not in the component file, so HTML DOM elements are not accessed explicitly from TypeScript code. | |
R22: Model is maintained only for the domain entity and its attributes; UI widget (HTML) attributes (e.g., colors, validity) are not present in the domain model. | |
Supervising Controller | R23: Input fields are checked with validators in the component file (TypeScript code), e.g., FormControl value validation. |
R24: UI widget (HTML) appearance (behavior) depends on the result of a validator (e.g., a button is disabled if a validator fails). | |
R25: Domain model contains the results of the user input validations, so widget appearance (behavior) explicitly depends on domain model attribute values. | |
Passive View | R26: Input fields are checked with validators in the component file (TypeScript code), e.g., FormControl value validation. |
R27: UI widget (HTML) appearance (behavior) depends on the result of a validator (e.g., a button is disabled if a validator fails). | |
R28: Some UI widgets (HTML DOM elements) are created and/or modified in the component file (TypeScript). | |
R29: There are View states (behaviors) that are handled in the component file (TypeScript), so HTML DOM elements may be accessed explicitly from TypeScript code. | |
R30: Model is maintained only for the domain entity and its attributes; UI widget (HTML) attributes (e.g., colors, validity) are not present in the domain model. |
Design Patterns | User Data Sent via Methods Triggered by Change Events | User Data Sent via Data-Binding | Domain Data Shared between Components | View-Specific Attributes Declared within the Component but Not in the Domain Entity | View-Specific Attributes Are Part of the Domain Entity | View-Specific Attributes Refer to the Same Domain Property | View-Specific Attributes Refer to Different Domain Property | Only UI Widget Behavioral Attributes Can Be Declared in the Component | UI Widgets Have Different Controllers | User Input Is Validated and Has an Impact on the Presented Data | View Receives Data from the Component and Is Maintained by It |
---|---|---|---|---|---|---|---|---|---|---|---|
Smalltalk-80 MVC | X | ||||||||||
HMVC | X | X | |||||||||
MVA | X | X | X | ||||||||
MGM | X | X | X | X | |||||||
Application Model | X | X | X | X | |||||||
Microsoft MVVM | X | X | |||||||||
Dolphin Smalltalk MVP | X | X | |||||||||
Supervising Controller | X | X | X | ||||||||
Passive View | X | X | X |
References
- Gamma, E.; Helm, R.; Johnson, R.; Vlissides, J. Design Patterns: Elements of Reusable Object-Oriented Software; Addison-Wesley Professional Computing Series; Pearson Deutschland GmbH: Munchen, Germany, 1998; ISBN 978-0-201-63498-3. [Google Scholar]
- Model View Controller History. Available online: https://wiki.c2.com/?ModelViewControllerHistory (accessed on 11 July 2023).
- Myer, T. Professional CodeIgniter, 1st ed.; Wrox: Birmingham, UK, 2008; pp. 7–9. [Google Scholar]
- Fowler, M. Patterns of Enterprise Application Architecture; Addison-Wesley Professional: Francisco, CA, USA, 2002; pp. 330–332. [Google Scholar]
- Krasner, G.E.; Pope, S.T. A Cookbook for Using the Model-View Controller User Interface Paradigm in Smalltalk-80. JOOP J. Object-Oriented Program. 1988, 1, 26–49. [Google Scholar]
- Potel, M. MVP: Model-View-Presenter the Taligent Programming Model for C++ and Java; Taligent Inc.: Auburn, CA, USA, 1996. [Google Scholar]
- Iordan, A. MVP Architecture and Design Patterns Applied to an Optimal Development of a Soft Used for Shortest Path Problem Study. Res. Highlights Math. Comput. Sci. 2023, 9, 36–54. [Google Scholar]
- Smith, J. Patterns—WPF Apps with the Model-View-ViewModel Design Pattern. MSDN Mag. 2009, 24, 135. [Google Scholar]
- GUI Architectures. Available online: https://martinfowler.com/eaaDev/uiArchs.html#Model-view-presentermvp (accessed on 12 July 2023).
- Syromiatnikov, A.; Weyns, D. A Journey through the Land of Model-View-Design Patterns. In Proceedings of the IEEE/IFIP Conference on Software Architecture, Sydney, NSW, Australia, 7–11 April 2014; pp. 21–30. [Google Scholar]
- Indrawan, D.; Kusumo, D.; Puspitasari, S. Analysis of the Implementation of MVVM Architecture Pattern on Performance of iOS Mobile-based Applications. J. Ilm. Penelit. Dan Pembelajaran Inform. (JIPI) 2023, 8, 59–65. [Google Scholar] [CrossRef]
- Sampayo-Rodriguez, C.J.; González-Ambriz, R.; Gonzálczmartinez, B.A.; Aldana-Herrera, J. Processor and memory performance with design patterns in a native Android application. J. Appl. Comput. 2022, 6, 53–61. [Google Scholar]
- García, R.F. MVVM: Model–View–ViewModel. In iOS Architecture Patterns; Apress: Berkeley, CA, USA, 2023. [Google Scholar]
- Epiloksa, H.A.; Kusumo, D.S.; Adrian, M. Effect Of MVVM Architecture Pattern on Android Based Application Performance. J. Media Inform. Budidarma 2022, 6, 1949–1955. [Google Scholar] [CrossRef]
- Forte, L. Building a Modern Web Application Using an MVC Framework. Bachelor’s Thesis, Oulu University of Applied Sciences, Degree Programme in Business Information Technology, Oulu, Finland, 2016. [Google Scholar]
- Badurowicz, M. MVC architectural pattern in mobile web applications. Actual Probl. Econ. 2011, 6, 305–309. [Google Scholar]
- GPT-4 Technical Report, OpenAI Blog. 2023. Available online: https://cdn.openai.com/papers/gpt-4.pdf (accessed on 12 July 2023).
- Radford, A.; Narasimhan, K.; Salimans, T.; Sutskever, I. Improving Language Understanding by Generative Pre-Training, OpenAI Blog. 2018. Available online: https://s3-us-west-2.amazonaws.com/openai-assets/research-covers/language-unsupervised/language_understanding_paper.pdf (accessed on 12 July 2023).
- Roumeliotis, K.I.; Tselikas, N.D. ChatGPT and Open-AI Models: A Preliminary Review. Future Internet 2023, 15, 192. [Google Scholar] [CrossRef]
- Koirala, S. Comparison of Architecture Patterns MVP(SC), MVP(PV), PM, MVVM and MVC. 2010. Available online: http://www.codeproject.com/Articles/66585/Comparison-of-Architecture-presentation-patterns-M (accessed on 12 July 2023).
- Nazar, N.; Aleti, A.; Zheng, Y. Feature-Based Software Design Pattern Detection. J. Syst. Softw. 2020, 185, 111179. [Google Scholar] [CrossRef]
- Wang, L.; Song, T.; Song, H.-N.; Zhang, S. Research on Design Pattern Detection Method Based on UML Model with Extended Image Information and Deep Learning. Appl. Sci. 2022, 12, 8718. [Google Scholar] [CrossRef]
- Nord, R.; Kurtz, Z. Using Machine Learning to Detect Design Patterns, Carnegie Mellon University, Software Engineering Institute’s Insights (blog). March 2020. Available online: https://insights.sei.cmu.edu/blog/using-machine-learning-to-detect-design-patterns/ (accessed on 11 July 2023).
- Dobrean, D.; Diosan, D. A Hybrid Approach to MVC Architectural Layers Analysis. In Proceedings of the 16th International Conference on Evluation of Novel Approaches to Software Engineering (ENASE 2021), Online, 26–27 April 2021; pp. 36–46. [Google Scholar]
- Komolov, S.; Dlamini, G.; Megha, S.; Mazzara, M. Towards Predicting Architectural Design Patterns: A Machine Learning Approach. Computers 2022, 11, 151. [Google Scholar] [CrossRef]
- Model-View-Controller. Available online: https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/MVC.html (accessed on 11 July 2023).
- Li, Y.; Jing, W. Research on Integrated Management System of Physical Education Course Information based on Spring MVC Framework. In Proceedings of the International Conference on Information System, Computing and Educational Technology (ICISCET), Montreal, QC, Canada, 23–25 May 2022; pp. 121–124. [Google Scholar]
- Model-View-Adapter (MVA, Mediated MVC, Model-Mediator-View). Available online: https://stefanoborini.com/book-modelviewcontroller/02-mvc-variations/05-variations-on-the-triad/01-model-view-adapter.html (accessed on 11 July 2023).
- Bulka, A. Model GUI Mediator. 2001. Available online: https://www.atug.com/andypatterns/AndyBulkaModelGuiMediatorPattern.pdf (accessed on 12 July 2023).
- Hopkins, T.; Horan, B. Smalltalk: An Introduction to Application Development Using VisualWorks; Prentice Hall International (UK) Ltd.: London, UK, 1995. [Google Scholar]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Jánki, Z.R.; Bilicki, V. Rule-Based Architectural Design Pattern Recognition with GPT Models. Electronics 2023, 12, 3364. https://doi.org/10.3390/electronics12153364
Jánki ZR, Bilicki V. Rule-Based Architectural Design Pattern Recognition with GPT Models. Electronics. 2023; 12(15):3364. https://doi.org/10.3390/electronics12153364
Chicago/Turabian StyleJánki, Zoltán Richárd, and Vilmos Bilicki. 2023. "Rule-Based Architectural Design Pattern Recognition with GPT Models" Electronics 12, no. 15: 3364. https://doi.org/10.3390/electronics12153364
APA StyleJánki, Z. R., & Bilicki, V. (2023). Rule-Based Architectural Design Pattern Recognition with GPT Models. Electronics, 12(15), 3364. https://doi.org/10.3390/electronics12153364