November 2018
Intermediate to advanced
346 pages
8h 12m
English
Sometimes, the application of DI is not wrong, but just unnecessary. A common manifestation of this is premature future-proofing. Premature future-proofing occurs when we add features to software that we don't yet need, based on the assumption that we might need it one day. As you might expect, this results in unnecessary work and complexity.
Let's look at an example by borrowing from our example service. Currently, we have a Get endpoint, as shown in the following code:
// GetHandler is the HTTP handler for the "Get Person" endpointtype GetHandler struct { cfg GetConfig getter GetModel}// ServeHTTP implements http.Handlerfunc (h *GetHandler) ServeHTTP(response http.ResponseWriter, request *http.Request) { // extract ...
Read now
Unlock full access