3 ms·
How do you factor out "this" in cases where methods and instance data logically belong together?
by sideshowb 10y ago
How do you factor out "this" in cases where methods and instance data logically belong together?
- beaconstudios 10y agoIf you're completely getting rid of "this" references then you're probably following a functional style and will keep data and functions separate, passing pure data as arguments rather than combining data and functions into classes.
- boubiyeah 10y ago1) Either use a functional style like beaconstudios said where it's perfectly normal to separate the data and the processing. 2) Or if you want to keep an OO style, use the module pattern with private functions closing over the data.
- cerved 10y agoUsing an object factory and referencing the object within the factory's lexical scope