nicholas-miklaucic/scarlet

Use getters/setters exclusively?

Closed this issue · 2 comments

For ease of use and brevity, I've been using public attributes. Perhaps it'd be better to use getters and setters?

In Rust...usually not. :)

If you really are wondering if plain old data structures should use this, don't worry about it. Getter and setter methods, in the strict sense, don't fit Rust, which is NOT an OOP language.

There's a great Reddit comment about this here, if you're curious about why. :)

The reason I posted this was because I didn't want Color methods to break because you changed the attributes manually to something outside of the range, or bounds check on every single method. This has been solved because you can explicitly fix bounds if you'd like, and AFAIK pretty much everything behaves as it should when you give it out-of-bounds data (which does have its use cases). I'm closing this. Thanks for the info!