Skip to main content

💭 Best Practices

When I first started programming, I was eager to learn and apply all the "Best Practices". Who doesn't want to start standing on the shoulders of giants?

A best practice is a method or technique that has been generally accepted as superior to alternatives because it tends to produce superior results.

-- Wikipedia

I am now still eager to learn the current "Best Practices" when start something new, or revisit something built in the past. However, I've learnt over time that:

  • They are to solve a problem under certain context/circumstances
  • They are considered superior to alternatives at a past point in time

So before or after applying any "Best Practice", I stop and ask some questions:

  • What problems(s) do they solve?
    • Do I have the same problem?
    • Do I have the same context/constrains?
  • What tradeoff did they make?
  • Are there new alternatives now?
  • Can I come up with a better alternative?

The software engineering world is rapidly evolving. Yesterday's best practice becomes tomorrow's anti-pattern. So I'd firstly like to understand the "WHY" and if it still applies, instead of thinking "that's how things are done around here", like the monkeys in the 5 Monkeys Experiment.

Then, I would like to evaluate my own trade-offs based on the current context as well as my team's preferences, and determine if the value is worth the effort.

Last but not the least, can I contribute some new ideas myself?

When I first learned TDD, I really loved the fast feedback loop. However, I found it very hard with UI development. At the time, I was developing games with Flash ActionScript, and I created a tool to develop "UI-Unit" in isolation. It is very similar to the ideas behind Storybook, which is now very popular in web UI development.

When I was migrating an AngularJs project to Angular, I wasn't happy with the "best practices" on custom icons via icon fonts, or redux-style state management solutions. So I created my own SVG based icon components, and a key-based query layer for fetching/caching/updating server states. Which are now both common practice in React projects (most icon libraries, and React Query).

I will continue learning and building, try to keep up with the best practices along the way. Hopefully, make some contribution to the innovations.