Hacker News new | ask | show | jobs
by cbrogrammer 1256 days 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.

1 comments

The 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.