Lessons for building
resilient codebases
Alex Moldovan
https://alexmoldovan.dev
Founder @ JSHeroes
Product Engineer @ CodeSandbox
https://bit.ly/alex-jsnation
Lessons for building
resilient codebases
Lessons for building
resilient codebases
<code />
Team changes
Priorities shifting
Product roadmap
Business pivots
Time passing
<code />
Team changes
Priorities shifting
Product roadmap
Business pivots
Time passing
<code />
Team changes
Priorities shifting
Product roadmap
Business pivots
Time passing
Lesson #1
Accept imperfection
"Perfect is the enemy of good"
Repo reference: https://github.com/codesandbox/codesandbox-client
The imperfect architecture model
Architecture must not stand in your way
Resonable shortcuts can be taken when needed
Exceptions are tolerated (but well documented)
Lesson #2
Colocation is king
https://alexmoldovan.dev/code-bites/colocation-is-king
Write
Read
👩💻
function whoYouGonnaCall() {
return "GHOSTBUSTERS!";
}
👨🏽💻
👩🏿💻
👩💻
Write phase
Let's look at some code 👀 👀 👀
Read phase
A case against reusability?
Lesson #3
Reusability is a double edged sword
The good
The bad
Abstraction
De-duplication
Separation of concerns
Zombie code
Unnecessary abstraction
Change propagation
Should I reuse it?
Will these things change together?
How often do you change the reusable code?
Do you need to understand the reusable code?
Lesson #4
Leave traces behind
👩💻
function whoYouGonnaCall() {
return "GHOSTBUSTERS!";
}
👨🏽💻
👩💻
function whoYouGonnaCall() {
return "GHOSTBUSTERS!";
}
function whoYouGonnaCall() {
return "GHOSTBUSTERS!";
}
⌛ 3 months
⌛ 3 months
Leave traces behind
Comment branch intensive code
Break algorithm in smaller readable steps
Hoist clear values used in conditional rendering
Lesson #5
Better strict than sorry
https://www.typescriptlang.org/tsconfig/#strictNullChecks
Better strict than sorry
Use TypeScript as "strict" as you can
Explicitly type all states for your data
Handle all these possible states
Recap
1. Accept imperfection
2. Colocation is king
3. Reusability is a double edged sword
4. Leave traces behind
5. Better strict than sorry
Thank you ❤️
Alex Moldovan
Founder @ JSHeroes
Product Engineer @ CodeSandbox
https://bit.ly/alex-jsnation
https://alexmoldovan.dev
Lessons for building resilient codebases
By Alex Moldovan
Lessons for building resilient codebases
- 359