2. Final Report Tasniflagich
Single responsibility implementation
Download 3.88 Mb. Pdf ko'rish
|
2.Final Report Tasniflagich
- Bu sahifa navigatsiya:
- 3.5.3 Implementation
3.5.2.1 Single responsibility implementation
The single responsibility principle provides another substantial benefit. Classes, software components and microservices that have only one responsibility are much easier to explain, understand and implement than the ones that provide a solution for everything. This reduces the number of bugs, improves your development speed, and makes your life as a software developer a lot easier. Tasniflagich does not delete records from the database in order to keep history of code of product (service, goods), it changes status to Passive. In order to implement this feature, I used the Single Responsibility Pattern. Each model Category, Product, Field and FieldValue has the method “ makeInactive ”. Figure 22 represents implementation of methods in different classes. We can mention that in Category and Product classes realization of functions are recursive and may call dynamic sql queries. In order to decrease response latency there should be static sql queries. TTPU 27 2022 Figure 21. Helper function TTPU 28 2022 Figure 22. Single responsibility 3.5.3 Implementation In order to standardize all request data, we should use the Laravel validation feature. Laravel has a ready solution to validate and set policy to rest api requests by FormRequest class. To create FormRequest class we should use artisan in the console. Figure 23 represents how to run commands in the console. In the result in the app/Http/Requests folder will be created CategoryStoreRequest.php. In this file we can define rules mapped with request parameters with special commands such as “required”, “string”, “integer”, “max”, “exists”. Figure 24 shows the completed FormRequest to store action of CategoryController. We can see the messages method, which makes a more user friendly response if validation fails. TTPU 29 2022 Figure 23. FormRequest create command Figure 24. FormRequest filled We have ready acquire and delete functions. Most of our controllers will have similar functions and different request loads. Figure 25 represents the structure of all 4 controllers that have index, show, store, update, delete methods and use”CommonFunc::acquireAction function”. TTPU 30 2022 Figure 25. CategoryController as a sample to all controllers TTPU 31 2022 Results As a result we got a fully functional backend service, which stores data about goods (works, service), that can be integrated to the government procurement ecosystem via AMQP protocol. That has role management in the admin panel. Also this service can be easily integrated to other systems via REST API. The developers or organization can review backend API through OpenAPI document at http://api.adm.tasniflagich.mf.uz/api/documentation . TTPU 32 2022 |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling