Matt Pocock
Legacy code is code without an organisational advocate
When you understand the intent of legacy code, it stops being legacy
What's wrong with this process?
You need to track all the dependencies first
Then, understand all the implementation details
The intent of the code is the last thing you understand
Let's go again!
mattpocock/react-finland-talk
This problem scales with complexity
How would you mitigate it?
What's the solution?
Intent first, implementation second
Explicit events > Implicit dependencies
Tired: the diagram represents the code
Wired: the diagram is the code
interface PokemonFetcherProps {
id: string;
}
const PokemonFetcher = (props: PokemonFetcherProps) => {
const [pokemonData, setPokemonData] = useState();
const [typeData, setPokemonTypeData] = useState();
useEffect(() => {
if (pokemonData) {
fetchPokemonType(pokemonData.typeId).then((data) => {
setPokemonTypeData(data);
});
}
}, [pokemonData]);
useEffect(() => {
fetchPokemon(props.id).then((data) => {
setPokemonData(data);
});
}, [props.id]);
};
one bit of code
Blockquote:
Technology is Neither Good, Nor Bad; Nor is it Neutral.
Melvin Kranzberg, Technology and History: “Kranzberg’s Laws”, 1986
“
”
state
event