What Are the React Team Principles?
overreacted.io
overreacted.io
One interesting thing Sophie mentioned is that principles should be disagreeable, i.e. not universally accepted truisms. For example, I can flip around most of these and they would still represent a legit (but very different) approach to building a UI framework.
https://design.tidyverse.org/unifying-principles.html
One emphasis of theirs that I find really powerful is the "pit of success", where the least effort action moves toward a positive outcome.
Broader overview of tidyverse here:
To stretch this analogy, the less disagreeable "truisms/rules" that need to be followed are things like, the boat needs to be buoyant, you need to bring paddles, don't stand up, etc. I'm probably referring to the presence of documentation, reviews, testing, etc.
For example, "We value code quality while also balancing practical velocity."
Well yes I'd imagine every single team in the world agrees with that. That doesn't tell me very much.
"We focus on code quality over practical velocity."
Interesting; I now have a valuable piece of information as to whether I want to work with you, depending on other specifics of the project.
"We focus on practical velocity over code quality."
Also interesting and very informative for me and a good indicator of whether I want to work with you.
Now you might argue that no team will phrase things in such stark terms, because this oversimplifies things. That's a good indication that maybe these aren't fundamental principles you should commit to writing and instead you should look at others. Alternatively maybe you just need to add a bit of nuance. "We're willing to commit months to getting a new feature right from a technical perspective but not years" vs "We aren't willing to commit any more than a span of a few weeks at most" is more nuanced but still has great information value.
It's also worth pointing out your principles can't cover everything. The occasional "yes I know we generally value code quality but we just really need to ship this now" or "yes I know we generally value velocity but this feature needs to be done absolutely right" is okay as long as it's truly occasional. Sometimes you have to just go with some set of unwritten rules, otherwise you'll fall into the trap of "principles lawyering."
The point of having disagreeable principles is that they give valuable information and insight. Principles that everyone agrees with basically amount to "we try to be good at things not bad at things" which doesn't help anything. If this happens in management this becomes the bland mission statements and culture statements I'm sure everyone has seen before. We value integrity and transparency in the workplace! And exactly who is ever going to publicly announce the opposite (on the other hand this makes the opposite statement a very very valuable principle, albeit one that probably will cause very few people to want to work with you)? We strongly value transparency over social comfort in the workplace, to the point that we publicize within our company all performance reviews, formal reprimands, pay raises and current salary of everyone in the company. Well that's a way more interesting principle. Agree with it or not, it tells me so much more.
If your principles don't make some set of reasonable people say "nope that's not for me" then they probably aren't very useful.
I suspect the motivation behind your statement is to trade this off against experimentation, in which case a more disagreeable version of this statement might be "we value conservatism of design over experimentation."
The person would probably phrase it like "you should always do the right thing", and then argue why some things need to be done in a way other people consider too complicated, because (1) it's possible to do it in a way that satisfies some abstract principle, and (2) following the abstract principle is the right thing.
For example "whenever it is possible to make a unit test for something, you should do it", even in situations where team members would scream that you really don't need a unit test to verify that 2+2=4. This would make sense as an antidote towards the attitude that you don't really need to test simple things, where the definition of "simple things" keeps expanding until almost everything is considered a simple thing.
I haven't seen many teams write down their philosophies (principles), but the force is there. From this write, it is very obvious this is a very mature team. Most of what I've experienced is tribal knowledge and shared conversations. Decisions are weighed at design time and code review and shared this way.
The principles I've seen are generally known to engineers without the team knowledge. For instance in one team they built apis weighed against principle of least privledge.
It would be good to investigate further. Maybe encourge the team to write down the philosophies and re-review after some interval, business change, or if new members join.
As someone who has been using React for five years and especially liked it for its simple class API to write components, I was a bit taken aback by the introduction of a new powerful API that is incompatible with the simple class API.
That's represented in one of these principles.
Of course that doesn't help if you're still pulling in a lot of hooks, since it's 1 line per hook minimum.
At the same time, the React team _could_ have chosen to implement support for hooks in classes, but chose not to, both for simplicity and as a carrot to encourage folks to use function components where possible. Based on the discussions and examples I've seen, capabilities like Concurrent Mode and Fast Refresh work better with function components because there's fewer edge cases to worry about. While classes aren't going away in the foreseeable future, there's valid reasons to try to get the community to adopt function components more.
I did assume that hooks were not supported in classes because it would be too complex to support that use-case, but the linked article specifically has an "Absorb the Complexity" principle, so it seemed a bit weird to me. Also, I understand the decision to try to motivate the community to use function components more, but is this the trend that we can expect to continue seeing in React? Certain APIs being phased out until they finally become deprecated. I know it has happened a few times already in React, but not on the level of something like a class API.
Add: I think the whole article is very good for teams that work on a framework and how to evolve it long term. I am usually not a friend of Javscript but the section about hacks made me think that Javascript is actually a good language too enable hacks. this is much more difficult in a C++ environment where you tend to be very strict.
I think the spirit of it is correct but the way it is currently written is missing the part about when/how to reevaluate.
While an idea can be perfect, it might still be the wrong timing.
Theory can sometimes become a dream instead and chasing a dream could waste a lot of time and the project can get left behind.
As it is currently written, that principle could ruin a project.
I guess we should add "Use common sense, be self critical and have taste". that's the one thing that bothers me about today's development practices. They all seem to want 100% bullet proof instructions what to do when. There is no such thing.