user972087
user972087

Reputation: 675

Adapt parameter pattern

What is the different between Adapt Parameter Pattern VS Extract Interface?

According to this ASP.net weblog:

Sometimes you are not able to use Extract Interface refactoring because interface of parameter may be too large or there may be no interface at all. You just have class to pass in and you are not able to fake it or extend it to get class testable.

The only difference that I see in the code is: extracting the interface of passed class with different name and make it manually.

Could you please give me an example (eventually with source code) to highlight their differences in code in more detail?

Upvotes: 1

Views: 1303

Answers (1)

Amy B
Amy B

Reputation: 110111

In the ExtractInterface article, the author creates an interface and a mock implementation.

in the Adapt Parameter article, the author creates an interface, a mock implementation and a wrapper implemenation. The original class is adapted/wrapped, because the original class can't be modified for some reason. One could say (if they read the article backwards), that first he Adapted the Parameter (by wrapping it), and then Extracted the Interface from the wrapper.

Upvotes: 1

Related Questions