5. The Monolith
A monolith is a geological feature consisting of a single massive stone or rock, such as some
mountains, or a single large piece of rock placed as, or within, a monument or building.
https://en.wikipedia.org/wiki/Monolith
A software system is called "monolithic" if it has a monolithic architecture, in which functionally
distinguishable aspects (for example data input and output, data processing, error handling, and the
user interface) are all interwoven, rather than containing architecturally separate components.
https://en.wikipedia.org/wiki/Monolithic_system
8. REST
REST has become the default technology to support Microservices Architecture
● It's HTTP(S)
● Use HTTP Verbs for actions: GET, PUT, POST, DELETE, PATCH, ...
● Use HTTP Status Codes to provide meaningful and normalized responses to
clients
● Easily extensible using HTTP Headers
● Support multiple authentication mechanisms
● JSON is more simple and less verbose than XML
13. Combine dependency level with
● Development environment
○ Setup
○ Maintain
● Keep services up to date
● Keep database schema and data
● Test
○ Time it takes to finish tests
○ Dependency from data
● CI/CD
○ Keep a stable environment for end-to-end tests
● Contract stability
● Communication between maintainers
15. Terminology
Dummy objects are passed around but never actually used. Usually they are just used to fill parameter lists.
Fake objects actually have working implementations, but usually take some shortcut which makes them not
suitable for production (an in memory database is a good example).
Stubs provide canned answers to calls made during the test, usually not responding at all to anything outside
what's programmed in for the test.
Spies are stubs that also record some information based on how they were called. One form of this might be an
email service that records how many messages it was sent.
Mocks are objects pre-programmed with expectations which form a specification of the calls they are expected to
receive.
https://martinfowler.com/articles/mocksArentStubs.html
16. Mock your dependencies
Dependencies with real implementations are
replaced by mocked implementations that
provide similar behavior at the interface level.
19. Fake Techniques - Client Fake
Client App
XptoAPIClient
Xpto Web API
HTTP
FakeXptoAPI
Client
IXptoApiClient
Quick to implement and simple to use
No new components on the system
Using a Mock framework allows control of
results on automated tests
Doesn't test the HTTP layer
Requires coding to implement statefulness
The Production Code is not stimulated
Potential risk to "Go Live" with the Fake
instead of Real implementation
20. Fake Techniques - Proxy
Client App
XptoAPIClient
Xpto Web API
HTTP
Quick to implement and simple to use
Saved responses are similar to the real API
No coding necessary (although possible)
Easy to implement with containers
Very flexible: easy to modify responses
Contract changes invalidate previous saved
responses
Requires coding to implement statefulness
Difficult to implement Expectations
mechanism to integrated with automated tests
Store
and
Forward
Proxy
HTTP
Responses
21. Fake Techniques - Fake Server
Client App
XptoAPIClient
Xpto Web API
HTTP Not so flexible to change responses
Requires coding
Need to implement Expectations to integrate
with automated tests
Code generation accelerates development
Easy support for contract changes:
(just regenerate the code and change implementation)
Easy to create and share containers
Easy to implement statefulness
Fake Xpto Web
API
Production&Integration
Development&Tests
HTTP
27. Integrating with docker
Using docker to launch every 1st dependency allows easy
setup of the project.
$> git clone <repo>
$> docker-compose up deps
Open solution in Visual Studio and hit F5
No expensive setup of databases, messaging systems or other services
Docker images can be versioned alongside with the versions of the API
Can be used to run component tests (not integration tests)
28. Summary
● Fake the 1st level dependencies to avoid having the entire dependency tree
● Choose your strategy: Client Fake, Proxy, Stateful Fake or any other that suits
● Consider generating as much code as possible
● Potentially high upfront investment - big gains in the long run
● Make it easy for the developers to
○ Run the project
○ Manage the versions of the dependencies they are using
○ Write automated tests
● Make components tests running against Fakes instead