That kikito's class variable name is different from the instance variable name. I'm simply being consistent with the way method naming works: if an instance has a value for a certain key, it will be used, otherwise the same one in the class, if it isn't there, the one in its superclass, etc.TechnoCat wrote:What is the difference between these two? Other than capitalization?
Since when would that matter? It surely doesn't matter for method names, does it?kikito wrote:Second, it is a "ghost atribute". Think about this:
If you explicitly did self.intensity = ... on the initializer, you will get 'intensity' printed out. But it will not be printed out if you just put 'intensity' as a class variable. It could be kind of inconsistent, too: depending on the implementation, some instances would print 'instance' and others wouldn't.Code: Select all
for k,v in pairs(pickle) print(k, '=>', v) end
That, and less complexity.kikito wrote:The only benefit is that you get rid of one line on the initializer.
Hm. Well, the way I did it would still be future-proof then.kikito wrote:In addition to this, on middleclass there's the assumption that 'methods are in classes, and attributes are in instances'. It's not currently used or enforced (I think) on middleclass-extras, but it might in the future (think serialization). Instances using class variables like that are less future-proof.