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

Refactor opportunities & experiments includes #2641

Merged
merged 4 commits into from
Jan 13, 2023
Merged

Refactor opportunities & experiments includes #2641

merged 4 commits into from
Jan 13, 2023

Conversation

stoyan
Copy link
Contributor

@stoyan stoyan commented Jan 12, 2023

  • Refactoring due to a recent global var mishap
  • Add AssesmentRegistry singleton
  • Categories are now constants
  • Each opp calls register() to add an opportunity
  • Each opp is now defined in an anonymous function (where needed) as to not bleed temporary vars as globals
  • Using e.g. global $testStepResult makes it obvious where we have further space to improve, e.g. memoize the function that returns test step result and call it when needed, as opposed to rely on a global

Usage:

// get the single registry object
$reg = AssesmentRegistry::getInstance();

// register a new opportunity
$reg->register(
  AssesmentRegistry::Quick,  // category
  ['title' => 'etc...'], // actual opp
);

// use 'em all in common.inc
$assesments = $reg->getAll();

* Refactoring due to a recent global var mishap
* Add `AssesmentRegistry` singleton
* Each opp calls `register()` to add an opportunity
@scottjehl
Copy link
Contributor

I'm pouring over this incredibly thorough and complete PR and I guess my only feedback so far is a minor variable edit change: assesment -> assessment?

This looks really great, @stoyan

Copy link
Contributor

@jefflembeck jefflembeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YES

@stoyan stoyan merged commit 42e4f0b into master Jan 13, 2023
@stoyan stoyan deleted the assesmentreg branch January 13, 2023 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants