sylvainpolletvillard / ObjectModel

Strong Dynamically Typed Object Modeling for JavaScript
http://objectmodel.js.org
MIT License
467 stars 28 forks source link

Flow, jagi/astronomy, or objectmodel for a meteor project #72

Closed gotjoshua closed 6 years ago

gotjoshua commented 6 years ago

First of all, is objectmodel "compatible" (appropriate to use) with meteor?

I am trying to compare the available options for object typing and decide, but I must admit I am a bit too green to really know what I should be comparing.

Flow is mentioned at the top of the objectmodel homepage, so I'm hoping for some insight.

sylvainpolletvillard commented 6 years ago

I'm not a Meteor user, but I don't see any reason why it wouldn't work with objectmodel.

Regarding flow and other static type checking solutions, I made a quick answer in the common questions section :

Models have been designed to use all the advantages of runtime validation, such as complex assertions, mixed value/type checking or custom error collectors. Compared to static type systems, the feature set is really different. I suggest you to combine the strengths of static and dynamic type-checking: use static annotations in your business logic layer, and Models at your API boundaries to validate user input, network responses or serialized data. You can also use both at the same place as demonstrated in the introduction video.

In other words, you should consider dynamic and static type-checking to be complementary, not alternatives.

sylvainpolletvillard commented 6 years ago

Did I answer your question ?

gotjoshua commented 6 years ago

Yes, I still need to dive more deeply into the offer to "use both at the same place" but we have decided to go forward with ObjectModel with Meteor - so i will need to address the issue soon!

Thanks again!

sylvainpolletvillard commented 6 years ago

Okay, my advice is to start slowly and use models on your API boundaries, especially the network responses. Then you can progressively add models where you feel the need to.

Note that using both static and dynamic type-checking at the same place is rarely useful, since 90% of the typing errors will be catched at compilation. This is only useful when you use advanced features such as value/regex checking, custom assertions, null-safe object traversal, and all the features that are not provided by a static type-checker such as TypeScript.