3 ms·
There might be something deeply interesting in that news actually. 'initialised = true' is obviously a bad pattern, now people cant argue about it anymore. Why
by quadcore 5y ago
There might be something deeply interesting in that news actually. 'initialised = true' is obviously a bad pattern, now people cant argue about it anymore. Why is it bad? Obviously, if you forgot the line then... BOOM. So instead I check whatever main variable the initialisation initialised before the initialisation starts - even when it looks a bit awkward cause it does sometimes. Also, the whole concept of initialisation is a bad pattern. You dont want to have an initialisation whenever you can avoid it, you want to perform the whole calculation every time. 'initialisation' implies a state machine. You dont want state machines, you want stateless machines, as much as possible. So yeah, 'initialisation' is a good optimisation some of the time and most of it a bad compulsive-caching habit.
'initialised = true' just costed people $10M. I really like those DeFi things cause at first glance.. I think they might actually teach people how to code!
- meowface 5y ago>So instead I check whatever main variable the initialisation initialised before the initialisation starts - even when it looks a bit awkward cause it does sometimes. Also, the whole concept of initialisation is a bad pattern. You dont want to have an initialisation whenever you can avoid it, you want to perform the whole calculation every time. 'initialisation' implies a state machine. You dont want state machines, you want stateless machines, as much as possible. So yeah, 'initialisation' is a good optimisation some of the time and most of it a bad compulsive-caching habit. One issue is that every operation in Ethereum smart contracts costs some gas, with differing gas costs for different kinds of operations. I'm not sure to what degree it applies in this case, if at all, but anything you can do to reduce the number of operations (and minimize costly operations) helps reduce gas costs.