Freestanding Principle
Description
A project is freestanding when all components necessary for the operation and development of the project are provided by the project itself. A freestanding project doesn’t use resources that are shared with others or interact with external services that must be configured outside the project.
Benefits
- ensures each developer has a consistent development environment
- ensures each developer is free from any external impediments by removing shared resources
- allows developers to share the entire state of their changes in a copyable form for others to build on or test
Approach
Virtualization or emulation should be used to provide all necessary components for the development and operation of a project. It may be necessary to build our own simulated component when the component we wish to simulate does not provide an off-the-shelf container.
Examples of virtualization or emulation includes things like:
- Docker: PostgreSQL, mailpit, etc.
- Firebase Local Emulator Suite
Case Studies
SMTP for starmaker-rebuild
Violation
One of the necessary components of the system, an SMTP server, was not contained within the project. This introduced friction and inconsistency to the development process.
The architecture of the project looked like this:
- a database for storing the state of the system
- a client and server to allow users to interact with the system
- a job daemon for processing asynchronous jobs that may occur in the normal operation of the system (generating reports or sending any email required for the system to function)
In order for any mail-related features to be developed, improved, or tested, an external mail server needed to be set up and development environments needed extra configuration to use it.
When we used a shared resource, like mail.silverorange.com, we risked impeding the work of others. We could send unwanted mail to other developers or worse, to real customers! 😱
Fix
Contain SMTP server within the project using virtualization and emulation.
Docker provides virtualization while mailpit emulates an SMTP server.
Case Studies
- Using docker to run external services. The Starmaker rebuild project includes a docker container that provides a PostgreSQL database. Docker could also be used to run STMP services for the project. Currently most of our projects use external SMTP servers.
- Deployment information should also be contained within the project. We don’t want project specific information to live outside the project in places like sync-to-live.