codecombat / treema

jQuery plugin that generates HTML interfaces to edit JSON data defined by json-schema.
http://codecombat.github.io/treema/
MIT License
152 stars 36 forks source link

Split logic for specific node into a strategy class, rather than subclasses #29

Open sderickson opened 10 years ago

sderickson commented 10 years ago

Each Treema node represents one property in the json data. There are some things that are universal about a node, like how it handles navigation or that it has a working schema, or its state and path. There's also logic mixed in that is to be overridden by subclasses, like how to edit or render the value. Possibly split this logic into the generic Treema node class and the Treema strategy class. This will mainly be good for cases when a node changes its working schema; you don't have to swap in the Treema node object instance if you can just swap in a strategy object. Consider having the strategy object be a singleton that gets passed in all relevant state, and leaving the generic node class to maintain state.