When
It will cause boundary problems in the system
This interface is also tailored and constrained to meet the needs of the application. It results in code that is easier to understand and harder to misuse.
Multiple methods can be used when using TypeScript Dictionary like:
Using dictionary directly leads to boundary problems:
Proper usage:
It is good to write some tests to test the 3rd party codes that we use
Could write some tests to explore our understanding of the third-party code. - Jim Newkirk
https://blog.thecodewhisperer.com/permalink/when-to-write-learning-tests
https://www.frederikbanke.com/linkedin-api-learning-tests/
Skip
Though might not always write learning tests, should always have boundary tests for migration when the version of the 3rd package change.
There is another kind of boundary, one that separates the known from the unknown.
This design also gives us a very convenient seam in the code for testing. Using a suitable FakeTransmitter, we can test the CommunicationsController classes. We can also create boundary tests once we have the TransmitterAPI that make sure we are using the API correctly.
Communication Controller
is not ready yetTrasmitter
is an interface that we wish to havetransmit
in Trasmitter
will receive the input from the real API, and provide output to others that use Trasmitter
TransmitterAdapter
is to bridge the gap between the real API Communication Controller
and our interface Trasmitter
FakeTransmitter
work????
Source
https://refactoring.guru/design-patterns/book
“The only thing that never changes is that everything changes.”
― Louis L'Amour
Same as boundaries. The goal is to be able to adapt to the changes without high costs such as time to rework. A good practice is to rely on what you can control, such as the interface that you design and wish to have, instead of depending on the 3rd party API, which you don't have full control of.
learn
clean code
test automation