PAGNIs: Probably Are Gonna Need Its (2021)
A few more in my experience:<p>Database abstractability. Here I don&#x27;t mean &quot;type of database&quot; like Postgres vs. MySQL vs. Mongo, but making sure in your system you have the ability to target and isolate the entire DB. Integration testing is both vital and slow; as you grow you will be glad you have the ability to run multiple of them at once because they don&#x27;t interact. With MySQL &amp; Postgres this can be as easy as making sure you code takes the database name as a <i>parameter</i> instead of hard coding it. If your database lacks this feature, take the time to abstract out table names so you can use a certain prefix&#x2F;suffix for a given test.<p>If you can&#x27;t quickly recreate the schema and populate with some known set of test data, take the time to write code that will take an existing DB and truncate it back to start or whatever. You need those integration tests, and you need them to not take two hours to run. Get that going at the beginning. I&#x27;ve not yet gotten to the point I need prepopulated schema which is handed out by a central manager, and then the cleanup is run out of the actual test cycle, but I&#x27;d be willing to go that far. In 2022 it is likely not a problem at all to have literally a thousand copies of your schema lying around on some test DB server, just to make the tests run fast. Use some versioning solution to make sure they&#x27;re the right version.<p>There is a <i>LOT</i> of variation in databases here; you will need to tune your process to your DB. In some, schema creation is wicked fast and you can just write all your tests to write out new ones without a problem. In others it is slow but very parallelizable. In others it may be just plain slow, in which case the code to take existing schema and reset them is more valuable. In yet others truncation may be difficult and&#x2F;or slow due to loose serialization requirements. Do whatever it takes to make your integration tests fast, or at least, as fast as possible. Do not just settle for even simple tests taking 10 minutes because you naively do a slow thing. You really need these to go fast.<p>Authentication and authorization; the earlier you work in <i>some</i> solution, the happier you will be. Sometimes this is easy to retrofit, sometimes it really isn&#x27;t. Even if you start with authentication and a list of who can do what in the very early phases it&#x27;ll still prevent you from accidentally depending on having no auth at all.<p>Write your code to be thread&#x2F;async safe from the beginning, even if you have no use for it yet. You don&#x27;t want to be in a position where you need it but you&#x27;ve got a 2-year-old code base now built on the deep assumption of single-threading, and it only gets worse as the code base gets larger. It&#x27;s a slight marginal expense to keep it in mind, it&#x27;s a project-destroying nightmare to add it back in later.<p>In static languages, get the types declared as early as possible. Get away from (int, int, int, string, string, bool, bool) function signatures as quickly as you can. It&#x27;s not exactly impossible to retrofit better types later, but it&#x27;s at the very least a pain in the bum disproportional to the cost of having declared them correctly in the first place. Even if your first stab at real types is wrong, it&#x27;s <i>still</i> easier to fix them this way because you have the type name as a hook for your IDE, or in the worst case, for sheer grep-based refactoring. (Even in dynamic languages I&#x27;d recommend this, but they have more options and the analysis is more complicated. Still, I&#x27;d suggest having a &quot;user&quot; that knows how to render itself as a string is better than passing around the user&#x27;s name or something as a string everywhere and expecting every bit of code that needs to do some user-object-method-y thing to have to look it up themselves.)