4 ms·
Premature abstraction. Rule of 3 helps. But I found better principle for it: Any abstraction MUST be designed to be as close as possible to be language-primiti
by valand 7y ago
Premature abstraction. Rule of 3 helps. But I found better principle for it:
Any abstraction MUST be designed to be as close as possible to be language-primitive-like. Language primitives are reliable, predictable, and non-breaking. If they do, they don't affect business logic written on top of it. If parameters are added, defaults are provided. They don't just abstract, they enable developers to express business logic more elegantly.
The challenge is to pick the part of the code abstractable to be primitive-like first and make it a top priority.
This is why language features like Rust async, Go channel-based comm, ES6, C++ smart pointer was such hype in their time and is used up until now. It also applies to enabling tools such as React, tokio, wasm-bindgen, express, TypeScript, jquery (even this which is not a thing anymore).
- pvorb 7y agoI find abstractable parts in code by thinking about potential names for it. If there is no good name for a potential common function, it's probably not a good idea to extract the section into a function. Maybe it can be extracted into two separate functions with good names?
- konschubert 7y agoThis is a proxy for having a well-defined purpose for a function.
- pvorb 7y agoYes, absolutely, but it's one that's easier to teach juniors.
- aj7 7y agoLike.