Here’s a question that might give some insight into the quality of your
codebase:
Can you have multiple instances of your application in a single process?
By that I mean that you could easily create and run parts of the application
and/or the whole thing in one process, without this causing bad behaviour. If
so, this probably suggests that the design is quite well factored.
It’s a similar idea to the questions in the Joel
test,
but for internal application structure.
How exactly this would look depends on the application itself, but as an example,
if you have an outer Application class, could you safely do this:
const app_1 = new Application();
const app_2 = new Application();
app_1.init();
app_2.init();
It doesn’t have to be an explicit Application or Container class; it could be
a function or some other entry point. The idea is that application set up and
structure is independent of process start up.
This is beneficial in a similar way to the benefits of being able to easily
isolate and instantiate a single class in a unit test. If it’s difficult to run
const subjectUnderTest = new FooBar() , it suggests that the FooBar class
might not be well-factored.
The same idea applies to whole modules and applications, too: if it’s difficult
to control application entry points, it’s difficult to control and refactor the
application as a whole.
One common example of when this becomes beneficial is the ability to run tests
in parallel. This is easy if the application is not bound tightly to the process
it exists in, avoids static and global state, and so on. If not, it’s difficult
to untangle it to allow running tests in parallel.
View post:
Can you have multiple instances of your application in a single process?
|