Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluated decorator for Single and Optional #148

Open
lemonboston opened this issue Jan 24, 2018 · 0 comments
Open

Evaluated decorator for Single and Optional #148

lemonboston opened this issue Jan 24, 2018 · 0 comments
Labels

Comments

@lemonboston
Copy link

The question is how to handle the following cases with declarative object design:

  • A constructor parameter is a resource which we don't want to capture for unknown time, like a Cursor
  • We need to evaluate eagerly on a background thread before passing the object to UI thread

My only idea to handle it in the declarative object design approach is to have an Evaluated decorator for each type which would evaluate the 'properties' in the constructor. (So it can mostly only apply to types with methods without parameters.)
Any other solution I suppose would involve some other type/construct/pattern other than just declaring and decoration. I don't know what that would be. But in order to keep this declarative approach coherent and applicable ubiquitously in our code bases, I think this Evaluated decorator could serve this purpose. This means of course that they would be exempt from the no code in the constructor rule. Although, that code would never be meaningful logic, just caching values eagerly.

@dmfs What do you think? Would you accept a pull request for this?
If you didn't approve the idea, do you have any other way in mind how these cases can be handled?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant