Album Cover

Faking & Mocking Java

Close Preview
The fake replaces the awkward collaborator which we actually ship. In a statically typed language, this means they must have the same type. Therefore only two relationships are possible between Awkward and Fake:
Fake Derives From Awkward
Shared Interface
Fake Derives From AwkwardAwkward And Fake Derive From Interface
Of these, the relationship on the left is the most prevalent in strongly-typed languages. It involves a slight risk: Awkward's methods could be renamed while Fake's wouldn't, and then Fake would be useless. Proper tools and care should help mitigate this risk.
Rarely, there is a third possible relationship, where Awkward has a usable, bare-bones base class that we can use (rather than creating a fake). But strictly speaking, that base class isn't a fake.
(Reading...)
| Tweet...
Page rating: | Rate this Page