5 ms·
> const createUser = ( > attributes: UserAttributes, > onCreate: (user: User) => void > ): User => { > user = User.create(attributes); > onCreate(u
by cbrogrammer 4y ago
> const createUser = (
> attributes: UserAttributes,
> onCreate: (user: User) => void
> ): User => {
> user = User.create(attributes);
> onCreate(user);
This stood out to me, in an otherwise tame article, as probably the most terrible overthought interface possible. A literal callback function passed as a function reference to something that does three lines of code? Good luck with that, I much prefer even a slightly procedual implementation.
- rglullis 4y agoThe three line function here is an example, but I spent a good part of a sprint having to deal with a 730-line function that could've been used as a perfect "real world scenario" of why this abuse of control flags (or type keys) is a bad idea.