Developer Cookbook: DDD Recipes (Part ? Selective Architecture)
3r33570. 3r3-31.
The introduction of 3r3506. 3r???. 3r33570. 3r? 3516. In previous articles, we identified 3r337. 3r34949 application area. approach and considered 3r3334. The basic methodological principles of Domain Driven Design
. 3r? 3519. 3r???. 3r33570. 3r? 3516. In this article, I would like to identify the main modern approaches to building an enterprise system architecture: Supple, Screaming, Clean and give them their clear interpretation in the form of a complete ready-made solution. 3r? 3519. 3r???. 3r33570. 3r? 3516. 3r? 3519. 3r???. 3r33570. 3r? 3516. In the following, we will look at each design pattern in detail: let's designate the scope, give examples of code, and highlight recommended practices. As a result, we will write a ready microservice. 3r? 3519.
3r3-3549. 3r???. 3r33570.
Flexible architecture
3r???. 3r33570. 3r? 3516. In 3r3334. previous article 3r34949. we stopped at the fact that DDD includes the practice of implementation through the model. The subject area should be described through your code. Let's try to figure out how to do this. 3r? 3519. 3r???. 3r33570. 3r? 3516. In his book, Eric Evans lists a number of design patterns recommended for use, and designates this approach as flexible: 3r3195. 3r???. 3r33570. 3r3187. In the name of architecture flexibility, many unnecessary constructs were piled up in programs. Extra levels of abstraction and indirect references are more likely to interfere than help in this matter. Look at the architecture that really inspires programmers involved in its refinement, and you will see, as a rule, something very simple. But simple does not mean easy to perform. To create such elements that can be assembled into complex systems and it is not difficult to understand, it is necessary to combine the “devotion” to design according to the model with a rather strict style of architecture. A certain design skill is needed not only to create something, but even to use ready-made. 3r???. 3r33570. 3r???. 3r33570. Eric Evans
Domain-Driven Design: Tackling Complexity of the Heart of Software. 3r? 3516. The presented set of design patterns is not a strict architecture or a turnkey solution, but rather food for thought. 3r? 3519. 3r???. 3r33570.
Screaming architecture
3r???. 3r33570. 3r? 3516. Similar thoughts occurred in the minds of many developers and designers of complex systems. 3r? 3519. 3r???. 3r33570. 3r? 3516. In 201? an article was published by Robert Martin - 3-333543. Screaming Architecture 3-333549. which says that your code should not just describe the subject area, but yell about it, preferably with a mat. 3r? 3519. 3r???. 3r33570. 3r3187. So what is your application scream? The structure of the package; do they scream: Health Care System, or Accounting System, or Inventory Management System? Or do they scream: Rails, or Spring /Hibernate, or ASP? 3r???. 3r33570. 3r???. 3r33570. Robert C. Martin, September 3? 2011
3r? 3516. Robert says that the code of your application should reflect the activity of the application, instead of adjusting to the rules of the framework. The framework structure should not limit your architecture. The application, in turn, should not be tied to the database or http protocol, these are just storage and delivery mechanisms. The bounding box is a tool. You should not become an adept frame maker. Tests of your application are tests of the logic of its operation, and not testing of the http protocol. 3r? 3519. 3r???. 3r33570.
Pure architecture 3r3506. 3r???. 3r33570. 3r? 3516. A year later, the next article by Robert Martin - 3r33838. The Clean Architecture
. In it, the author tells how to make the code scream. After studying several architectures, he identifies the basic principles: 3r3519. 3r???. 3r33570. 3r3-3160. 3r33570. 3r33547. Independence from the framework. The architecture does not depend on any existing library. This allows you to use frameworks as tools, not as constraints that bind your hands. 3r33554. 3r33570. 3r33547. Testability Business rules can be tested without a user interface, database, web server, or any other technical means. 3r33554. 3r33570. 3r33547. Independence from user interface. The user interface can be easily changed without changing the rest of the system. For example, a web interface can be replaced with a console interface without changing the business logic. 3r33554. 3r33570. 3r33547. Independence from the database. You can exchange Oracle or SQL Server for Mongo, BigTable, CouchDB or something else. The logic of your application should not be tied to a database. 3r33554. 3r33570. 3r33547. Independence from the impact of the environment. In fact, your business rules simply do not know anything about the outside world. 3r33554. 3r33570. 3r3174. 3r???. 3r33570. 3r? 3516. On Habré already published a very good article 3-33548. Misconceptions Clean Architecture
. Its author, 3r3-3110. Jeevuz 3r33535. very well chewed up the subtleties of understanding this approach. I strongly recommend to get acquainted with it as well as with original materials. 3r? 3519. 3r???. 3r33570. 3r3115. Variable architecture
3r???. 3r33570. 3r? 3516. The description of the approach presented above does not look so unambiguous. As part of the development of the architecture of a number of complex corporate systems, I and my colleagues developed a fairly clear interpretation of the described approaches, which I am going to present below. 3r? 3519. 3r???. 3r33570. 3r? 3516. Before the advent of computers and programming languages, paper workflow was used when building and managing systems with complex business logic. The result of any process was a document that ultimately described a particular business object. As a result, clerical work was reduced to three simple
Actions
: 3r33519. 3r???. 3r33570. 3r3-3160. 3r33570. 3r33547. Creating a document 3r3554. 3r33570. 3r33547. Document processing 3r33554. 3r33570. 3r33547. Work with the archive of documents 3r33554. 3r33570. 3r33547. Submission of the document 3r33554. 3r33570. 3r3174. 3r???. 3r33570. 3r3187. Document - recording information about the economic activity of a particular real business object. 3r3190. 3r? 3516. Please note that the document itself is not a real business object, but only its
Model 3r3494. . At the moment, paper documents are being superseded by electronic ones. A document can be a record in a table, a picture, a file, a sent letter, or any other piece of information. 3r???. 3r33570. I would not like to use the word document in the future, since it will be more confusing, we will use the concept of 3r3493. Entity
(Entity) of DDD terminology. But you can imagine that now your entire system is an electronic document management system that performs four simple
Actions
. 3r? 3519. 3r???. 3r33570. 3r3-3160. 3r33570. 3r33547. Collecting 3r33554. 3r33570. 3r33547. Processing 3r???. 3r33570. 3r33547. Storage 3r?554. 3r33570. 3r33547. Representation
3r33570. 3r3174. 3r???. 3r33570. 3r3187. Action (Action) - the structural unit of the business model; a relatively complete separate act of a perceived goal, the arbitrariness and premeditation of the individual activity of a business object, distinguished by the end user. 3r3190. 3r? 3516. A good example is 3r3493. Acts
is a theatrical act. Theater simulates events from real life. The act is a meaningful part of the play. But in order to make the story complete, you need to lose several acts in a strictly defined order. We call this order in our architecture
Mode
. 3r? 3519. 3r???. 3r33570. 3r3187. Mode (Conduction) - set
Action 3r3494. in a certain order, having a complete meaning, bearing the benefit of the end user. 3r3190. 3r? 3516. 3r3192. 3r? 3519. 3r???. 3r33570. 3r? 3516. For the likes of
Modes 3r3494. the work was coined by a selective jig or
CVT
(Selector). More precisely, the “patent for 3r-3301” was obtained. US2870278A
. We know this device as a "twist" of a washing machine. Architectural "twist" is given at the beginning of the article. 3r? 3519. 3r???. 3r33570. 3r? 3516. The variability of the approach is manifested in the fact that with such an architecture you can choose any of the four 3r3493. Modes 3r3494. , passing that you will not make extra
Action 3r3494. . 3r? 3519. 3r???. 3r33570. 3r? 3516. Starting the washing machine, you can select the mode: wash, rinse or spin. If you choose to wash, then your machine will still rinse the laundry, and then it will wring out. With rinsing included, you are sure to get a spin. Spin - final 3r3493. Action
in the process of washing it is the “simplest”. Our architecture is the simplest
Activity 3r3494. - 3r3493. Presentation 3r3494. , let's start with it. 3r? 3519. 3r???. 3r33570.
Representation
3r???. 3r33570. 3r? 3516. If we talk about a pure representation without accessing the database or an external source, then we give out some static information: html-page, file, directory lying in the form of json'a. We can even give out just
Code response
- 200: 3r3195. 3r???. 3r33570. 3r? 3516. Let's write the simplest "Health checker" 3r33535. 3r???. 3r33570. 3r3406. 3r3407. module Health
class Endpoints < Sinatra::Base
get '/check' do; end
end
end 3r33434. 3r???. 3r33570. 3r? 3516. In the most primitive form, our scheme will look like this:
3r???. 3r33570. 3r? 3516. 3r? 3519. 3r???. 3r33570. 3r33525. 3r33526. Lyrical digression [/b] 3r33528. 3r? 3516. I ask you to note that in the framework of Sinatra class
Endpoints
combines in itself like
Router 3r3494. , and 3r3493. Controller
in one class. Does this not violate the principle of sole responsibility? In fact, Endpoints is not a class, but a layer expressed through a class, and its area of responsibility is at a higher level. 3r? 3519. 3r???. 3r33570. 3r? 3516. Ok, but what about
Router 3r3494. and 3r3493. Controller
? They are not represented by a set of classes, but by the name and implementation of a function. A static file is generally a file. One class is responsible for one responsibility, but do not try to express every responsibility through a class. Proceed from practicality, not from dogmatism. 3r? 3519. 3r3566. 3r3566. 3r???. 3r33570.
Working with the storage system (Storage)
3r???. 3r33570. 3r? 3516. Business is demanding on the availability of your application. Why would someone need your service if we cannot use it at the right moment? To ensure data integrity, we record a change in the state of a business object after each processing. 3r? 3519. 3r???. 3r33570. 3r? 3516. To retrieve an object from the repository, no business logic is required. Imagine that we are automating the operation of a hotel chain and we have a magazine of guests at the front desk. We decided to look at the information about the visitor. 3r? 3519. 3r???. 3r33570. 3r3406. 3r3407. module reception
class Endpoints < Sinatra::Base
3r33570. # Show item
get '/residents /: id', provides:: json do
resident = Repository :: Residents.find params[:id]3r33570. status 200 3r33570. serialize (resident) 3r33570. end
end
end 3r33434. 3r???. 3r33570. 3r? 3516.
Working with the storage system
in the form of a graphic scheme:
3r???. 3r33570. 3r? 3516. 3r33333. 3r? 3519. 3r???. 3r33570. 3r? 3516. How can we notice the communication between the level responsible for 3r3493. Storage 3r3494. , and the level responsible for data presentation is implemented through the Response model. This model does not belong to any of these layers. In fact, this is a business object and it is located on the layer responsible for the business logic. 3r? 3519. 3r???. 3r33570.
Processing (Processing)
3r???. 3r33570. 3r? 3516. If it comes to the fact that the object model changes on the basis of its properties without adding new data, then we turn to layer
Interactor
directly. Layer 3r3493. Interactor
is the key in our application, it describes the entire business logic in the form of individual 3r3493. Use cases 3r3494. (Use Cases) and it is on it is a change 3r3493. Entities 3r3494. . 3r? 3519. 3r???. 3r33570. 3r? 3516. Consider this use case. In our hotel, the visitor is already registered, but we celebrate each his arrival or departure. 3r? 3519. 3r???. 3r33570. 3r3406. 3r3407. module reception
class Endpoints < Sinatra::Base
3r33570. # Register resident arrival
post '/residents /: uid /arrival', provides:: json do
result = Interactors :: Arrival.call (resident_id: params[:id])
check! (result) do
status 201 3r33570. serialize result.data
end
end
3r33570. # Register resident departure
post '/residents /: uid /departure', provides:: json do
result = Interactors :: Departure.call (resident_id: params[:id])
check! (result) do
status 201 3r33570. serialize result.data
end
end
end
end 3r33434. 3r???. 3r33570. 3r? 3516. Let's stop a little. Why not make the implementation of a single method with the parameter status
? Interactors 3r33380. Arrival and 3r33380. Departure radically different. If a guest has come to us, then we need to check whether the cleaning has ended, whether new messages have arrived for him, etc. When he leaves, we, on the contrary, must initiate cleaning if necessary. In turn, we don’t even remember the messages, because if he were at the hotel, we would call him right away. It is all this business logic that we are writing on layer Interactor . 3r? 3519. 3r???. 3r33570. 3r? 3516. 3r33333. 3r? 3519. 3r???. 3r33570. 3r? 3516. But what should we do if we have data from the outside? This connects action Data Collection 3r3494. . 3r? 3519. 3r???. 3r33570.
Collecting
3r???. 3r33570. 3r? 3516. During the first registration of a guest at a hotel, he fills out a registration form. This form is verified. If the data true, then there is a business process Registration. The process returns data — the created “Resident” business model. We present this model to the guest in a readable form: 3r3–3519. 3r???. 3r33570. 3r3406. 3r3407. module receptionclass Endpoints < Sinatra::Base
3r33570. # Register new resident
post '/residents', provides:[:json]do 3r33570. form = Forms :: Registration.new (params)
complete! form do 3r33570. check! form.result do
status 201 3r33570. serialize form.result.data
end
end
end
end
end 3r33434. 3r???. 3r33570. 3r? 3516. Schematically it looks like this:
3r???. 3r33570. 3r? 3516.

Actions
. 3r33554. 3r33570. 3r33547. The sequence is 3r3493. Action 3r3494. determined by
Mode 3r3494. . 3r33554. 3r33570. 3r33547.
Modes 3r3494. incremental. 3r33554. 3r33570. 3r33547. The more "complicated"
Mode
complements the more "simple", on strictly one action. 3r33554. 3r33570. 3r33547. Each action takes place within the same
Layer 3r3494. . 3r33554. 3r33570. 3r33547. Each layer is represented by 3r3493. Class 3r3494. . 3r33554. 3r33570. 3r33547. Inside the layer can be
Classes-Layers
and 3r3493. Responsibility classes
. 3r33554. 3r33570. 3r33547. Communication takes place only between
Layer 3r3494. and 3r3493. Intralayer Class
. 3r33554. 3r33570. 3r33547.
Presentation Models
are exceptions. 3r33554. 3r33570. 3r33547. Error handling should occur at a level of
Class-Layer
. 3r33554. 3r33570. 3r33556. 3r???. 3r33570. 3r? 3516. 3r301501. 3r? 3519. 3r???. 3r33570.
General scheme 3r3506. 3r???. 3r33570. 3r? 3516. This approach has a high threshold of entry. Its application requires from the designer a lot of experience for a clear understanding of the tasks to be solved. The complexity also represents the variety of choice of the necessary tool. But, despite the complexity of the structure, implementation at the code level is incredibly simple and expressive. Although it contains a number of conventions and powers of attorney. In the future, we will analyze each design pattern separately, describe how to create it, test it and designate the scope. And in order not to get confused in their diversity, a full map is offered: 3r3-3522. 3r33570. 3r33512. 3r? 3519. 3r???. 3r33570. 3r? 3516. 3r? 3517. Map in high resolution
3r? 3519. 3r???. 3r33570. 3r? 3522. 3r???. 3r33570. 3r33525. 3r33526. Sources of Inspiration [/b] 3r33528. 3r? 3529. 3r33570. 3r33547. Problem-Oriented Design, Eric J. Evans 3r355454. 3r33570. 3r33547. Kate Matsudeira: Scalable Web Architecture and Distributed Systems 3r3554. 3r33570. 3r33547. 3r33538. https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html
3r33554. 3r33570. 3r33547. 3r? 3543. https://blog.cleancoder.com/uncle-bob/2011/09/30/Screaming-Architecture.html
3r33554. 3r33570. 3r33547. 3r33548. https://habr.com/company/mobileup/blog/335382/ 3r???. 3r33570. 3r???. 3r33570. 3r33554. 3r33570. 3r33556. 3r3566. 3r3566. 3r3566. 3r33570. 3r33570. 3r33570. 3r33535. ! function (e) {function t (t, n) {if (! (n in e)) {for (var r, a = e.document, i = a.scripts, o = i.length; o-- ;) if (-1! == i[o].src.indexOf (t)) {r = i[o]; break} if (! r) {r = a.createElement ("script"), r.type = "text /jаvascript", r.async =! ? r.defer =! ? r.src = t, r.charset = "UTF-8"; var d = function () {var e = a.getElementsByTagName ("script")[0]; e. ): d ()}}} t ("//mediator.mail.ru/script/2820404/"""_mediator") () (); 3r33535. 3r33570. 3r3566. 3r33570. 3r33570. 3r33570. 3r33570.
It may be interesting
weber
Author13-11-2018, 17:17
Publication DateRuby on Rails / Programming
Category- Comments: 0
- Views: 395
Knowledge is very important to do any ritual properly but it is very hard to find a true knowledge about tantra, vashikaran, healing etc but thanks to avijeet aacharya who is supporting people by his free article like you and spreading the knowledge to needy people.
I seen your page and it look so interesting and i am thankful to you for spreading knowledge by this portal. if someone wants to learn about different types of powerful vashikaran mantra for boyfriend so read avijeet aacharya pages on his portal and find interesting topics and updates.
[hide]Call Girl in Delhi[/http://escortservicesinnewdelhi.launchrock.com/] | [hide]Escort Services in New Delhi[/https://telegra.ph/Call-Girls-in-Delhi-7428151367-Call-Girls-Services-in
-Mahipalpur-01-15] | [hide]Call Girls Services in Mahipalpur[/https://escortservicesinnewdelhi.mystrikingly.com/] | [hide]Sex Services in Paharganj[/http://www.geocities.ws/natashasingh76/index.html]