My faves are:
In my experience trying to prematurely optimize an app is a lot more time consuming than profiling and optimizing only the hotspots. Worse yet, you often end up optimizing the wrong things and still have a slow app at the end.
This problem exists for any named thing. What if you rename a function or an object property that is widely used? Same problem, right?
Usually the solution is a careful search/replace paired with some smoke testing and good source control/backup.
Thanks for taking the time to read and respond.
The girl killing herself was completely irrelevant.
The relevance of the suicide — and the reason I included it in this article — is that it is the event which made me realize that there are broader consequences to the work I do. It opened my eyes and…
Right. I think the best solution is for coding to become a Profession, in the same way that Law, Engineering, and Accounting are in many countries.
In most places, every Lawyer has to follow the same code of ethics and can refuse to do anything that violates that code without fear of retribution.
In the context of the shopping cart example in this article, that approach introduces an interesting challenge.
db parameter would have to be injected into each function and we would need a way to ensure that the caller couldn’t alter the state of the db outside of the context of the mutation functions (
I would politely refuse to do the task and explain why I’m uncomfortable with it. The most likely outcome is that the task will be assigned to someone else. At which point, you’ll have a good sense of what the company is about and you can quietly find another job and make a graceful exit.
After first publishing this piece on the freeCodeCamp blog, several news outlets carried stories about it and it was also shared via multiple social media channels. I also read this story aloud for the freeCodeCamp podcast. So, it’s possible you’ve come across it elsewhere.
Thank you for taking the time to write a reasoned response (I’m not sure why the OP didn’t do so themselves). I appreciate all feedback.
I didn’t invent Factory Functions. They were originally presented as an appealing alternative to Constructor Functions because they have fewer gotchas.