mirror of
https://github.com/glen9527/Clean-Code-zh.git
synced 2025-12-18 03:04:21 +08:00
md 引入图片资源
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# 第 11 章 Systems
|
||||
by Dr. Kevin Dean Wampler
|
||||
|
||||
Image
|
||||

|
||||
|
||||
“Complexity kills. It sucks the life out of developers, it makes products difficult to plan, build, and test.”
|
||||
|
||||
@@ -54,7 +54,7 @@ Sometimes, of course, we need to make the application responsible for when an ob
|
||||
|
||||
Figure 11-1 Separating construction in main()
|
||||
|
||||
Image
|
||||

|
||||
|
||||
LineItem instances to add to an Order. In this case we can use the ABSTRACT FACTORY2 pattern to give the application control of when to build the LineItems, but keep the details of that construction separate from the application code. (See Figure 11-2.)
|
||||
|
||||
@@ -63,7 +63,7 @@ LineItem instances to add to an Order. In this case we can use the ABSTRACT FACT
|
||||
|
||||
Figure 11-2 Separation construction with factory
|
||||
|
||||
Image
|
||||

|
||||
|
||||
Again notice that all the dependencies point from main toward the OrderProcessing application. This means that the application is decoupled from the details of how to build a LineItem. That capability is held in the LineItemFactoryImplementation, which is on the main side of the line. And yet the application is in complete control of when the LineItem instances get built and can even provide application-specific constructor arguments.
|
||||
|
||||
@@ -328,7 +328,7 @@ Each “bean” is like one part of a nested “Russian doll,” with a domain o
|
||||
|
||||
Figure 11-3 The “Russian doll” of decorators
|
||||
|
||||
Image
|
||||

|
||||
|
||||
The client believes it is invoking getAccounts() on a Bank object, but it is actually talking to the outermost of a set of nested DECORATOR14 objects that extend the basic behavior of the Bank POJO. We could add other decorators for transactions, caching, and so forth.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user