
8 Jan
2016
8 Jan
'16
5:38 a.m.
How should one go about deciding to use data or class?
class: class lets specify more than one method. when you define instance yet do not implement all methods, compiler warns. if you try to call class method without an instance for that type, compiler warns. pattern matching: compiler does not warn if methods do not match every constructor of the data type. one way to decide if not sure, is to pick one way which seems easier to refactor. when more code is written, it usually becomes obvious if this approach does not fit. then refactor.
Which is more appropriate here? depends on the rest of the code. if this is it, then there is no real difference.