|
|
|
|
|
by AnimalMuppet
258 days ago
|
|
Access control. Here's a struct that maintains an invariant - say, that field a is less than field b. That invariant should be set when it is created. You find a bug where a is greater than b. Where is the bug? With a struct, it can be anywhere in the code - any line that touches the struct. But with a (well designed) class, a and b are private, and so you only have to look at lines of code within the class. The surface area where the bug can be is much smaller. The bigger the code base and the more well-used the class is, the more this matters. |
|