Design Quotations

xiaoxiao2021-03-06  68

1. Is it necessary to separate? Why is it separated?

Separation realizes the separation of data and functionality. There is no need to transfer function interface when passing data. Just data transmission, why should I expose the function interface to the web layer? There is only data available in the web layer. Avoiding the impact of the call interface of the web layer programmer. In fact, it is incorrect in the web layer.

This understanding is problematic, and the control of the function interface can be controlled by access control keywords, such as only package permissions.

2, but after the TO and object are separated, there is a duplicate data. So why not avoid repeating?

The idea is to carry only the necessary data, abandon every excess data, improve the transmission performance.

is it necessary? Just a little bit of performance

It seems that it is not necessary. However, when the web layer is constructed, he is impossible to pass any data outside of the ID.

This is easy to solve A, let the data outside the ID are empty.

3, why not let business objects inherit to?

Prevent business objects and TO coupling too tight.

But TO is actually a tight coupling as a member variable?

Relatively speaking, the coupling of the inheritance is stronger than the coupling of the member variable, such as I can completely replace member variables, use other ways to save data.

No, your constructor uses To, this is a strong coupling

However, the member variable method should write a lot of repetition code. For example, I want to change the value of an attribute, you have to provide a set method, he just passes, this is a repetition.

I can provide a GetTo method to make people call, and then let customers use the TO's SET method.

Oh, is this not to enhance the coupling? I use inherited ways to make business objects easily used in the Spring architecture.

1. Reference to TO in To Why are you arrac?

This will not be converted without the type.

But isn't you very troublesome when you increase the data such as deletion? Using an array is just convenient when reading. Increased deletions more frequently. The trouble read can be simplified by converting to an array, and List is converted to data is not difficult. Moreover, the business object can use these LISTs directly as a container without rehabilizing other List to do containers, avoiding code repetition.

2. Simple and deduplicate the report, is it necessary to use the object? Isn't it just updated to the database?

After the particle size refinement, the use of object-oriented things can bring reuse, do not have to change it in the future.

转载请注明原文地址:https://www.9cbs.com/read-119940.html

New Post(0)