question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Recommendations about implicit state

See original GitHub issue

Working with Cycle I often find myself in situation where some issue can be solved with either implicit or explicit state. For example, we have a toggler. Toggler has 2 states: favorite and non-favorite.

Implicit state

Intent relies on HTML class to produce both favup$ and unfav$ observables. So some state is implicitly encapsulated in DOM. This reminds our old days with jQuery where ALL state was in DOM so DOM served as XML database. It was imperfect, though worked to some degree. Short: fat Intent, skinny Model.

Explicit state

Intent produce just toggle$ observable. It’s a model purpose to decipher it. In many cases will require to have scan in Model, because scan is one of the few stateful methods. Short: skinny Intent, fat Model.

Second option is probably both more complex and more “idealistic”. On the other hand, Intent barely deserves it’s name when it’s completely pure and state agnostic…

This question is obviously non-Cycle specific. But I wonder: are both approaches conventional from the author point of view? If implicit state is properly encapsulated, can it still cause some unwanted consequences later? Should we avoid implicit DOM state in Cycle whenever possible or not? Or both are fine and it’s a developer task to decide when it’s time to switch from Implicit to Explicit?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
staltzcommented, Mar 27, 2015

But I wonder: are both approaches conventional from the author point of view?

I prefer explicit. Skinny Intent is not a problem. Sometimes it really is skinny (specially on click events), sometimes it’s not (when doing voice recognition for instance, you need to run an algorithm. The best place to put it in is Intent).

If implicit state is properly encapsulated, can it still cause some unwanted consequences later?

If it causes some unwanted consequences, then it’s not properly encapsulated. 😉

Should we avoid implicit DOM state in Cycle whenever possible or not?

Yes we should avoid.

Or both are fine and it’s a developer task to decide when it’s time to switch from Implicit to Explicit?

I recommend explicit, and to clarify some potential fears: Cycle is not optimized for minimal boilerplate nor productivity. It’s optimized for separation of concerns. If a developer wants to speed up his development processes, he will often find himself mixing concerns, taking shortcuts. Cycle is not a framework for those types of shortcuts, unfortunately (or fortunately). I’m not saying they are a bad thing, I’m just saying Cycle is not the right tool for that if maximum productivity is a requirement.

0reactions
staltzcommented, Mar 30, 2015

Can we made React-like warning about missing key? It would help a lot.

Good idea, I’ll make an issue for that.

(do you mind if I close this issue? We can reopen if needed)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reflections and Recommendations on Implicit Biases Within ...
Addressing implicit bias and minimizing its negative effect on the conduct of science begins with the individual and must be supported by ...
Read more >
Recommendations Implicit in Policy Defaults
We have shown that policymakers' choice of default can convey an implicit recommendation that decision makers are sensitive to, but we have not...
Read more >
The FaceTime Bug and the Dangers of Implicit State Machines
The solution is simple: explicitly model the states, events, and transitions in your programs. This can be done at a higher-level of abstraction ......
Read more >
Recommendations Implicit in Policy Defaults - SAGE Journals
We have shown that policymakers' choice of default can convey an implicit recommendation that decision makers are sensitive to, but we have not...
Read more >
Spring Statemachine - implicit state transitions - Stack Overflow
1 Answer 1 ... If I understand this correctly, you want a "domino" like effect on state transitions (cascade transitions - so that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found