Comments (5)
@romancortes points out that, for the purpose of serialization, it does not make sense to link properties of components until after all of them have been constructed and initialized. So, my thought about using the serialization properties to pass information into the initializer would not work. "properties" are really post-construction "linkage".
Bearing in mind that I’m not attacking a specific use case, I just fear we’re painting ourselves into a corner. Components rely on bindings to ensure consistency, so the present model works fine.
Regardless of whether initializers are parameterized, or whether properties are assigned before or after initialization, I think we need separate syntax for instantiation and creating subtypes.
from montage.
We’re planning a meeting to discuss this ticket. My ideas have shifted somewhat with education, so I’ll restate my ideas.
- Montage.create should be only a polymorphic method with the signature of
type.create(descriptor_opt)
. If the descriptor is omitted, it should default to an empty descriptor. This would be used directly for creating new types, and indirectly (through constructors or serializers) to create new instances. - Deprecate the two-argument form of
Montage.create(type, descriptor)
. Thecreate
function, though inspired by the static method ofObject.create
is not a static method. It would be clumsy forMontage.create(type, descriptor)
to calltype.create(descriptor)
to regain polymorphism. - Deprecate the behavior of
Montage.create()
where it callsdidCreate
in the no-argument case. The no-arg case should only differ by the defaulting of the descriptor argument. It is “too clever” for it to assume you’re instantiating if you omit a descriptor. - Ponder
didCreate()
. Does this method make sense for both serialization and programmatic initialization? Does it make more sense before or after serialized properties are populated? - Ponder the pattern for construction and initialization. The pattern for constructing instances should be terse.
Prototype.create().initWithThisArgumentPattern(…args)
is not terse.Constructor(…args)
is very terse, but not really going to happen since we don’t do constructors.Prototype.someName(…args)
is okay, and gives us the win thatPrototype
isthis
in the constructor function so we can dothis.create()
inside to make our instance, handing off to a polymorphiccreate
function.someName
could beinit
orconstruct
, but the key is that it would callthis.create()
internally so the user doesn’t have to.
from montage.
Outcome of meeting was:
Prototype.inherit(descriptor)
is for deriving a new typePrototype.create()
is for instantiation and initialization with no argumentsPrototype.createWith…(…)
forms are for instantiation and initialization with arguments
Migration path overlaps existing patterns:
Montage.create(Prototype, descriptor)
. Change toPrototype.inherit(descriptor)
Montage.create(Prototype)
. Change toPrototype.create()
(This pattern is only used once, in Logger)Prototype.create()
stays the samePrototype.create().init()
can be subsumed intoPrototype.create()
Prototype.create().initWithArguments(…args)
can be subsumed byPrototype.createWithArguments(…args)
The meeting approached consensus, but these changes remain contentious.
from montage.
Solved!!
from montage.
Perhaps there should be a party when you close an issue that is more than a 1000 behind the most recently opened issue!
from montage.
Related Issues (20)
- Components should automatically add their module id based conventioned CSS class name to the class attribute of their element
- the property _isTemplateInstantiated of Template doesn't reflect the reality.
- Remove deprecated multiSelect property from the range controller HOT 1
- DataService - Add ability to batch actions (create, update, delete)
- Implement Draggable/Droppable handling via getters & setters
- DataOrdering should be Ordering and in core
- MJSON objects are instantiated when the file is loaded, not required
- Redundant call to mapping.mapRawDataToObjectProperty if mapping result isn't a Promise HOT 1
- Add logic to a component that uses its serialization label as it's element's id to save manual writing
- DataService. _performAndDeleteOfflineOperation incorrectly null checks for offlineService and schema HOT 1
- Add Mutable Event pooling
- Remove Composers as public API and make them plugins to event manager
- Add default Component sandboxing of events coming from template's encapsulated DOM
- Add ability for Target to hosts it's own listeners
- core/extra/date is executed twice in running tests of a project relying on montage
- Add CSS custom properties client-side support for older browsers HOT 1
- Going from Main = Component.specialize(..) to class Main extends Component {} fails silently
- Can't ES6 import in a file eval-ed (by mr). Will require changes to evolve progressively
- PropertyDescriptor valueType = "enum" & enumValues =[...] doesn't use montage Enum
- clicking on a panel in a flow.info top left example right after releasing a drag block the panel to revert to the stable position it's supposed to go
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from montage.