Disadvantages of encapsulation

Precautions

It is good to encapsulate a method in java, but there is no annotation and API. Sometimes encapsulation can achieve the opposite effect. This reminds us that as an architect or programmer, we must write well annotations and APIs. So that our results can be Be properly used by others. On the contrary,
as a method for programmers to call the platform or other people, you must pay attention to the comments.

Counterexample

Today I called a platform to obtain the time, only know that this platform is the time to obtain the server. I use the millisecond value of this time to generate the waybill number used by the system, this waybill number has a unique key constraint in the data. I could not understand how this conflict milliseconds Why? because this method the overall transaction will write to a lot of queries and databases, at least there are tens of milliseconds, so the decision will not be repeated milliseconds.
Best not their When I solved it, I decided to decompile the platform package and view the original code. I knew from the source code that this time value was cached. If the current time and historical cache time exceed 10 minutes, re-assign the value. At this time, I suddenly realized that, It also seems to be enlightened.

Guess you like

Origin blog.csdn.net/qq_37375667/article/details/100058391