How do I get rid of magic numbers in java without declaring a massive amount of finals or static finals? Keep in mind looping, arrays are not allowed. It doesn't seem possible? Help appreciated. thanks.
Example code:
drawOval(5, 5, width, height);
drawOval(10, 10, width, height);
drawOval(15, 15, width, height);
drawOval(20, 20, width, height);
drawOval(25, 25, width, height);
Defining constants is really your only option. What's your opposition to using them? They are definitely worth their space in this context. Future developers would much rather see extra constants than be confused by what those numbers mean.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With