Skip to content
This repository has been archived by the owner on May 28, 2019. It is now read-only.

Don’t use Promises #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Zearin
Copy link

@Zearin Zearin commented Mar 2, 2016

In the spirit of Issue #8 (Don’t use EventEmitter), this PR removes Promises from microcuke.

Reasoning:

  • Although Promises are not JS-specific, they are an async idea.
  • Fewer people are familiar with async programming than normal/sync programming.
  • Asynchronous programming styles vary wildly across libraries and languages.
  • A previous comment in the source said something to the effect of, “we’re using Promises, because JavaScript. You should just return a boolean, because it’s simpler!”
    • If microcuke is supposed to a minimalist, simple-as-possible reference implementation, Promises introduce a barrier to the person reading microcuke in order to write their own implementation. (Code that would be a simple for-loop becomes a nested group of promises and anonymous function calls; a simple return value (boolean) is replaced by a more complex block of code; etc.)

The benefits of this have a lot of overlap with those of Issue #8 (removing EventEmitter):

  • People who are unfamiliar with Promises or async programming will not be put off by unfamiliarity with Promises
  • Easier to read and understand (even for people who do understand Promises)
  • Easier to port to other languages
  • When porting to other languages, someone can use their preferred async tools/constructs in their implementation
  • We can add comments like, “Your implementation could use async here if desired” to encourage performance for implementations, while microcuke itself remains simple and straightforward to read and grok

## Summary:

- Removes Promises from TestStep
- Rewrite TestStep so it’s easier for newcomers to grok, and factor out the complex middle execution to a separate function
- Edit tests for TestStep accordingly

## Details

Like the planned removal of EventEmitter, Promises make microcuke harder to understand and less porting-friendly for people using it to write an implementation.

This hopefully makes microcuke the TestStep class easier to understand, faster.
Making microcuke simpler to grok as a reference implementation.
Making microcuke simpler to grok as a reference implementation.
@Zearin
Copy link
Author

Zearin commented Jun 15, 2016

@aslakhellesoy ping

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

Successfully merging this pull request may close these issues.

1 participant