public and private, when would you use which

BlitzMax Forums/BlitzMax Beginners Area/public and private, when would you use which

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

FlameDuck:

a) set methods are useful to perform error checking, other validation, or secondary functions when a variable is set. In my 'position' example, it may be useful to check for collision or bound when setting the x or y coordinate.

b) there may be a time in the future where you realize that a single property field was not the best way of handling the data. Maybe you realize that the data needs to come from a different place, like a contained member, to weed out redundancy, or that it needs to be calculated on the fly. In this case, using a get method instead of simply accessing the variable directly allows you to change how the value is handled behind the scenes without changing any of your source that uses the type/module in question.

Separation of interface and implementation is GOOD.