Talk about the domain and entity

This time in charge of overseas affairs, today with the client to go overseas store payment process. Since then most of the domestic channels are aggregated SDK, the client would pay little attention to business processes, but under the previous demo and follow the parameters of access channels provided directly on. First po a business process diagrams, and then withdraw to the topic.

Simply draw a flow chart of what you can see from the graph, the server throughout the payment process many times do long-distance calls. Because Store provides API is based out of OAuth2.0 for AccessToken were packaged and automatically updated based on its validity, and then with today's topic.

In fact, this AccessToken data container is a small thing, data members inside it basically Store the returned data parameters, but I need follow-up to its expiration time monitoring. So, AccessToken objects will be added to this createTime member variables in the result parameter remote call. With this package will soon be the following structure:

Then, based on the callback FooAccessToken serialize operations. The question is: so can it?

I smell bad taste code:

1.FooAccessToken domain model is not required to carry such a heavy responsibility? SDK and on the bridge project, we developed is based on the model of anemia, the entity is not required to simulate, just focus on the data flow just fine.

2. Based on FooAccessToken callback operation sequence of the encapsulated AccessToken directly coupled to the transport layer, which is not conducive to subsequent changes.

In this extract the code file, and then with the following changes:

Although it looks "superfluous", but more clear and straightforward on the code level and the semantics. Based anemia model, business objects more inclined to the data carrier, but not appropriate given the object's behavior. Business objects should not be directly coupled together with a transport object, the need for external isolation at the transport layer.

 

Guess you like

Origin www.cnblogs.com/jason-koo/p/11204516.html