A overview of some software design principles to keep in mind for your next project.
the action or fact of forming a united wholeThe idea behind this principle is to group your logic and/or features into groups/packages/modules (whatever makes sense). This makes it much easier to find what you are looking for in the future. Rather than looking through all your directories, you can open one folder and have all the work presented to you. Most of my work is done in React, where I have taken up an approach called “Module Driven Development”. Where each feature has its own “module”, grouping all the hooks, utilities, styles, etc in that one folder.
Mailer
interface that any third-party service can implement and pass that to your email service. Abstracting the logic needed for your service out to this Mailer
will give you a lot more flexibility in the future when requirements change or your client decides to change to a different provider.
It would also help with mocking, while doing your testing, you can mock a dummy Mailer
and use it while testing to “simulate” a real environment.
dates
and exported several utility functions to format, parse, calculate duration etc. Since they are all encapsulated in this module, we can easily install an alternative, replace moment in our dates
module and as long as your tests pass we can move the ticket to review.
However, if we imported moment throughout the entire codebase in 500 different files, repeated ourself constantely, we will need to find all those instances and replace them manually, making the entire process really annoying. Moving from working in 1 directory to working across every directory does not sound fun to me.
catch
block;