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

Add documentation #989

Closed
wants to merge 4 commits into from
Closed

Add documentation #989

wants to merge 4 commits into from

Conversation

mcmire
Copy link
Contributor

@mcmire mcmire commented Nov 24, 2022

Those of us that have worked on the monorepo have a lot of context around why it exists, what it does, and how to work with it, but for everyone else, this context may not exist. The set of guides in this commit aims to fill in the missing gaps. I've also included a bit around preview builds at the end. We may also need an expanded section on creating new releases, as people may not immediately jump to the docs for create-release-branch, and those docs may not be as comprehensive as they could be. This could come in a future PR, however.


Fixes #992.

@mcmire
Copy link
Contributor Author

mcmire commented Nov 24, 2022

As I started writing I realized I was going for a blog post / educational style with this documentation and stuck with it, but if there's anything that I could make shorter, let me know and I can revise. Also I tried to fact-check some of the technical details as I went along (particularly the Jest stuff) but if there's anything that's clearly wrong, let me know. Basically feel free to go nuts with proof-reading.

Those of us that have worked on the monorepo have a lot of context
around why it exists, what it does, and how to work with it, but
for everyone else, this context may not exist. The set of guides in this
commit aims to fill in the missing gaps. I've also included a bit around
preview builds at the end. We may also need an expanded section on
creating new releases, as people may not immediately jump to the docs
for `create-release-branch`, and those docs may not be as comprehensive
as they could be. This could come in a future PR, however.

Run `yarn lint` to lint all files and show possible violations, or run `yarn lint:fix` to fix any automatically fixable violations.

### Release & Publishing

This project follows a unique release process. The [`create-release-branch`](https://github.com/MetaMask/create-release-branch) tool and [`action-publish-release`](https://github.com/MetaMask/action-publish-release) GitHub action are used to automate the release process; see those repositories for more information about how they work.
This project follows a process which is unique to this repo. The [`create-release-branch`](https://github.com/MetaMask/create-release-branch) tool and [`action-publish-release`](https://github.com/MetaMask/action-publish-release) GitHub action are used to automate the release process; see those repositories for more information about how they work.
Copy link
Contributor

Choose a reason for hiding this comment

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

I find "unique" a strange way here, it reads as some claim of novelty. Maybe "custom" or "its own"? Also I do find the addition of "to this repo" somewhat redundant (even if more precise)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's fair. I can simplify this a bit.

@@ -0,0 +1,15 @@
# Why a monorepo?
Copy link
Contributor

Choose a reason for hiding this comment

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

Thought: why.md isn't a very descriptive name and this focuses on a specific aspect of the architecture. Though it does seem relevant and useful as such.

Here's one thought: Merge what.md, why.md, and the Structure section of how.md into architecture.md , and this could be a ## Motivation section there?

Copy link
Member

Choose a reason for hiding this comment

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

That would make sense to me. The historical context for how things used to work, and the specific problems we have, will rapidly become less relevant. Explaining the ongoing benefits is useful though.

Copy link
Member

@Gudahtt Gudahtt Nov 24, 2022

Choose a reason for hiding this comment

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

Reminds me of the old README this package had, though that was far longer and even less relevant. There was an elaborate justification given for why we should use TypeScript over JavaScript. I'm sure people needed convincing at the time, but it felt a bit misplaced after we became more invested in using TS as a team.

Copy link
Contributor Author

@mcmire mcmire Nov 29, 2022

Choose a reason for hiding this comment

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

Good points! I'll try condensing the content and removing the historical angle. (edit: or at least rewording it to sound like it comes from the present and not from the past)


To use them, you'll need to do a few of things:

1. You'll need to create a personal access token within your GitHub account. If you have not already done so, go into the [token settings for your account](https://github.com/settings/tokens) and [create a token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-personal-access-token-classic). (Note: there are two types of tokens; you'll want a **classic** token.)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can assume the reader knows how to get a GH access token (or look it up elsewhere)? Emphasis on classic seems relevant, though.

Copy link
Member

Choose a reason for hiding this comment

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

The linked article is the official documentation. That does seem like the best place to point people. I guess we could shorten this sentence to omit the "go into the token settings" part, as that's already covered by the article as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Something like this?

Suggested change
1. You'll need to create a personal access token within your GitHub account. If you have not already done so, go into the [token settings for your account](https://github.com/settings/tokens) and [create a token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-personal-access-token-classic). (Note: there are two types of tokens; you'll want a **classic** token.)
1. You'll need to create a **classic** [personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-personal-access-token-classic).

alternatively,

Suggested change
1. You'll need to create a personal access token within your GitHub account. If you have not already done so, go into the [token settings for your account](https://github.com/settings/tokens) and [create a token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-personal-access-token-classic). (Note: there are two types of tokens; you'll want a **classic** token.)
1. You'll need to [create](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-personal-access-token-classic) a **classic** personal access token.

//npm.pkg.github.com/:_authToken=<insert your personal access token here>
```

3. Over here in `controllers`, push up a draft PR for this repo (or place an existing PR into draft mode), then make a comment on the PR with the text:
Copy link
Contributor

@legobeat legobeat Nov 24, 2022

Choose a reason for hiding this comment

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

We should probably make it normative that people run CI on their own forks? (As-is this not explicit about it, considering "this repo" technically depends on if you read it before or after forking). Consider that this will also be perused by people unaffiliated with the MetaMask team.
Would there be additional setup instructions (like here we should mention or link to to capture that?

Suggested change
3. Over here in `controllers`, push up a draft PR for this repo (or place an existing PR into draft mode), then make a comment on the PR with the text:
3. In you fork of `MetaMask/controllers`, create a draft PR for this repo (or place an existing PR into draft mode), then make a comment on the PR with the text:

Copy link
Member

Choose a reason for hiding this comment

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

This trigger only works for branches on this repo. Forks aren't supported by preview builds. We have been encouraging people on the team not to use forks, because compatibility with certain CI steps is worse.

It's difficult to safely build any integrations that work with forks and allow interacting with the upstream repo. We don't want to give untrusted third parties access to a write token for this repository for example, even one scoped just to comments, because that would let them create fake metamaskbot comments.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess I have to look into preview builds and try it out to see how the limitations arise.

Some of the below is just opinion, even if I write normatively.

Without having seen more than 1 case of things behaving differently, it seems like when it comes to producing builds and uploading them, there is fundamentally nothing apart from setting different registry and access token etc that should differ...? Ie everything done in this central repo should be doable transparently on forks as long as the expected env vars / secrets are there.

This is also with the assumption that we want to allow contributors on equal terms even if they're not part of the MM org. Even if we'd say and think we do, failing CI steps, as well as documentation presented as general but effectively only relevant for MM org internal use (I believe that first-time contributors need manual approval to have their draft PRs builds, and that having a draft PR pop up here for everyone who want to make a build is going to become untenable sooner than later) make that less likely and affect expectations, reducing probability of potential contributors actually engaging constructively.

Consider also overage costs and throughput for CI - things add up.

I completely understand that documentation should reflect reality. But I also would like to accommodate and normalize a more distributed flow. Perhaps this file/section can stay on the cooler (that is, pull it out of this PR for now to not block) until the outstanding CI issues are resolved and we can present something that can also set best practices and be more generally applicable?

Until then (given some of the complications above), and without clearer enumeration of alternatives (talked about below), I'd consider this internal docs rather than something that's useful to make public.

Copy link
Member

Choose a reason for hiding this comment

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

We absolutely want to ensure external contributors can be effective contributors. It should be straightforward enough to document how they can manually publish to their own private registry to test changes.

The only part of "preview builds" we can't allow from forks is the use of our registry, and the ability to trigger publishing from comments on our PRs. But neither of those are essential to allow contributors to publish and test changes.

I don't see a problem with including internal docs as public documentation in the README, as long as it's clearly documented as internal. Ideally we'd have equivalent steps for external contributors though, where possible/relevant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel like we should still include a part about preview builds in the docs as well. This is a new thing for all engineers, so featuring it in the docs raises visibility to those unaware and keeps us from having to explain how it works.

I can work on documenting how this could work for contributors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One question I have here as I rewrite this is, why are we requiring the @metamask-bot comment to only work on draft PRs? I feel like it complicates things a bit because I have to include this bit:

Continue to keep your controllers PR in draft mode until you're sure that you don't need to make any new changes. If you do push up a new commit to your PR, however, simply post another @metamask-bot preview-build comment and this will trigger another build.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we are doing that. We used the preview-builds command for the v34 release PR well after bringing it out of draft.

We're requiring extension and mobile PRs that utilize these builds to be draft PRs, so that we don't accidentally merge preview builds into the main branch.

@metamask-bot preview-build
```

This will trigger a GitHub Action which will build all of the packages in the monorepo using the code in the branch and publish them to GitHub Package Registry. You might need to wait a bit, but after a few minutes, you'll see a new comment with the new version that was published. 4. Back in your project, look for the package where you made your changes and replace its version with the one posted in the comment. 5. Run `yarn install`. You should be using the changes now. 5. Continue to keep your `controllers` PR in draft mode until you're sure that you don't need to make any new changes. If you do push up a new commit to your PR, however, simply post another `@metamask-bot preview-build` comment and this will trigger another build.
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like it's intended to or used to be a numbered list?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops! Not sure why I didn't catch this 😬

Every application needs to manage state. Some state is temporary. Perhaps the
user is on a screen which keeps track of whether a button is clickable/tappable depending on whether a request is taking place; but as soon as the user leaves that screen, that information is discarded. But some state is more permanent. Perhaps a screen needs to reuse information that was gathered on a previous screen, in which case the state is cached in memory; or perhaps the entire application needs to load all of the user's data when it starts, in which case the state is persisted to disk. Either way, we need a place to store that state, and that's where controllers come into play.

Currently, there are two styles of creating controllers which we've dubbed [BaseController v1](../packages/base-controller/src/BaseController.ts) and [BaseController v2](../packages/base-controller/src/BaseControllerV2.ts). Both versions offer the same set of basic functionality:
Copy link
Contributor

Choose a reason for hiding this comment

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

I know it's already prevalent but IMO we (see what I did there) should avoid speaking from first-person in docs like this - reserve that for discussion and P2P comms.

Suggested change
Currently, there are two styles of creating controllers which we've dubbed [BaseController v1](../packages/base-controller/src/BaseController.ts) and [BaseController v2](../packages/base-controller/src/BaseControllerV2.ts). Both versions offer the same set of basic functionality:
There are currently two styles of creating controllers, each with an associated TypeScript base class: [BaseController v1](../packages/base-controller/src/BaseController.ts) and [BaseController v2](../packages/base-controller/src/BaseControllerV2.ts). Both versions offer the same set of basic functionality:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can probably guess the reasoning for this, so I don't disagree, but I'm just curious — why in your opinion should this be avoided?

Copy link
Contributor

@legobeat legobeat Nov 30, 2022

Choose a reason for hiding this comment

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

There is more to it but here is one aspect: By introducing the "we", the reader is now forced to consider the author explicitly; who is writing this, when? In case of some open-source projects: Is this a message from the original author, the intermediary repository maintainers, or the company now owning the codebase? Regardless of if the reader thinks this matters or not, the context is now more dynamic. Technical documentation relates to the subject, independently of people and organizations. The author injecting themselves becomes a distraction.

For example, if we consider an alternative reality where we're documenting a proprietary hosted HTTP API, documenting rate-limiting behavior - this is one example of when I think a "we" could be warranted, depending on style.

Does that make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah! I hadn't thought about that but it makes perfect sense.

- The application can update the state at any time.
- In another location, the application can listen for and respond to state changes (or stop listening altogether).

v2 includes a number of improvements over v1, resulting in a more simplified and solidified API. One aspect worth noting with v2, however, is that not only can controllers communicate with the application, but controllers can also communicate with each other — and this is done in a way that doesn't require the controller package that's doing the receiving to depend on the controller that's doing the sending. This capability is provided by [ControllerMessenger](../packages/base-controller/src/ControllerMessenger.ts).
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I got it right here but somehow I think that part can be simplified a bit?

Suggested change
v2 includes a number of improvements over v1, resulting in a more simplified and solidified API. One aspect worth noting with v2, however, is that not only can controllers communicate with the application, but controllers can also communicate with each other — and this is done in a way that doesn't require the controller package that's doing the receiving to depend on the controller that's doing the sending. This capability is provided by [ControllerMessenger](../packages/base-controller/src/ControllerMessenger.ts).
v2 includes a number of improvements over v1, resulting in a more simplified and solidified API. One aspect worth noting with v2, however, is that not only can controllers communicate with the application, but controllers can also expose APIs for any other controllers to interface with. This capability is provided by [ControllerMessenger](../packages/base-controller/src/ControllerMessenger.ts).

@@ -0,0 +1,33 @@
# Testing monorepo changes against other projects
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Testing monorepo changes against other projects
# Using your forked version as a dependency in other modules

Or something like that?

@@ -0,0 +1,33 @@
# Testing monorepo changes against other projects

Let's say that you're working on a feature in one of our products and this feature relies on changes that you need to make to one or more packages within this repo. You make those changes here, but now you want to make sure that they fulfill the need you have in your product and don't break anything. How do you integrate these changes into your product?
Copy link
Contributor

Choose a reason for hiding this comment

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

I actually had to do a reread to get this one. Let's see if we can make it more straightforward. I also think it can work better within a context (maybe it can be a section under common_tasks.md rather than an independent file?)

(Initial attempt, I'm not proposing it):

Suggested change
Let's say that you're working on a feature in one of our products and this feature relies on changes that you need to make to one or more packages within this repo. You make those changes here, but now you want to make sure that they fulfill the need you have in your product and don't break anything. How do you integrate these changes into your product?
Commonly, you will want to use controllers in external projects, including changes you are working on. There are different ways to do this. When working locally, you may be using [npm](https://docs.npmjs.com/cli/v9/commands/npm-link) or [yarn link](https://classic.yarnpkg.com/lang/en/docs/cli/link/), or changing the `dependencies` in `package.json` of your downstream package to something like `"@metamask/foo-controller": "file:///home/user/src/metamask/packages/foo-controller"`.
This will usually not work easily in instrumented CI builds and other more restricted environments.

...Then I started writing about hosting a private registry using Verdaccio as an alternative.

Do you think it might make more sense to mention preview builds as one option among several (in which the instructions below can still be its own subsection)? I'd be happy to take a stab at part of it if it sounds good to you @mcmire - I think it shouldn't be too hard to get an unpermissioned option going as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

And to you point in the PR comment, the contents of this file is what I would say might belong better in a blog post or article.

Copy link
Member

Choose a reason for hiding this comment

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

I found this a bit challenging to read as well.

Just to clarify though, the solution we're describing here is using a private registry. We're using the GitHub Packages registry. This "preview build" system is just a convenient way of publishing arbitrary commits.

Rather than manually publishing, a user can instead type @metamaskbot preview-build, and it will build and publish everything for you.

Regarding alternatives, publishing is the only strategy that we've found to work with CI. For local development there are alternatives, though it's not easy to explain all of the caveats to getting those working either.

Copy link
Member

Choose a reason for hiding this comment

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

This article might be improved by summarizing the problem scenario more concisely, then proceeding directly to the solution rather than enumerating alternatives first. We can leave alternative strategies for the end.

e.g.

Suggested change
Let's say that you're working on a feature in one of our products and this feature relies on changes that you need to make to one or more packages within this repo. You make those changes here, but now you want to make sure that they fulfill the need you have in your product and don't break anything. How do you integrate these changes into your product?
Commonly, you will want to test your changes both locally and in CI before they are merged or published. Our use of the `workspace:` protocol prevents most common strategies from working because it doesn't get resolved until the package is published. We have setup scripts to publish "preview" builds to a private registry to make it easier to test changes while they are still under review.

Copy link
Contributor

@legobeat legobeat Nov 25, 2022

Choose a reason for hiding this comment

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

I do appreciate the reasoning of your last proposal @Gudahtt . Just two things:

  1. Can this be communicated without using "we"/"us"?
  2. "We have setup scripts" could be read as referring to yarn setup, resulting in confusion. Making one of the words into a link to the relevant script would make things a lot more clear.

Copy link
Member

Choose a reason for hiding this comment

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

Take 2:

Suggested change
Let's say that you're working on a feature in one of our products and this feature relies on changes that you need to make to one or more packages within this repo. You make those changes here, but now you want to make sure that they fulfill the need you have in your product and don't break anything. How do you integrate these changes into your product?
Commonly, you will want to test your changes both locally and in CI before they are merged or published. The use of the `workspace:` protocol prevents most common strategies from working because it doesn't get resolved until the package is published. To solve that problem, this repository has scripts to simplify the process of publishing any arbitrary commit to a private registry to test with.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll work on rewriting this whole document to be less blog post-y / announcement-y and use the feedback here.

- Occasionally, a product team tasked with carving out a new feature needed to make temporary modifications to one or more controllers during development, but this was difficult, as they were forced to fork the repo and keep it up to date.
- Beyond the controllers repo, we were maintaining code for other shared libraries in separate repos, and keeping these repos architecturally aligned with each other had grown to be painful.

We aimed to improve these situations by splitting up `@metamask/controllers` into many packages, where each package corresponded to a single controller (except for a few cases). By doing this:
Copy link
Contributor

@legobeat legobeat Nov 24, 2022

Choose a reason for hiding this comment

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

Suggested change
We aimed to improve these situations by splitting up `@metamask/controllers` into many packages, where each package corresponded to a single controller (except for a few cases). By doing this:
This led to splitting up `@metamask/controllers` into many packages, where each package corresponded to a single controller (except for a few cases). This is where the current architecture comes from. By doing this:


We aimed to improve these situations by splitting up `@metamask/controllers` into many packages, where each package corresponded to a single controller (except for a few cases). By doing this:

- Product teams could now choose which controllers they wanted to use in their project without the fear of relying on more dependencies than were necessary.
Copy link
Contributor

@legobeat legobeat Nov 24, 2022

Choose a reason for hiding this comment

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

Suggested change
- Product teams could now choose which controllers they wanted to use in their project without the fear of relying on more dependencies than were necessary.
- Users can now pick and choose which controllers to use in their projects without worrying about pulling in more dependencies than necessary.

We aimed to improve these situations by splitting up `@metamask/controllers` into many packages, where each package corresponded to a single controller (except for a few cases). By doing this:

- Product teams could now choose which controllers they wanted to use in their project without the fear of relying on more dependencies than were necessary.
- Instead of forking, product teams can publish [preview builds](./preview-builds.md) for in-progress work and make use of those builds in products to test them out as they are working on new features.
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for my education: Why was this facilitated by breaking apart the packages? What made that unviable for the monopackage?

Copy link
Member

@Gudahtt Gudahtt Nov 24, 2022

Choose a reason for hiding this comment

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

I'm not sure about this sentence. Previously, controller forks weren't (to my knowledge) used for experiments that often. They were used by mobile as a short/medium-term way to introduce controller changes quickly and release them in mobile, bypassing the need to make that change functional for the extension and agreeable for other teams. Though it has been over a year since I've seen that done (more recently they've used patches instead).

Experiments were done by installing deps from git references. Which was made impractical due to the Yarn v3 workspaces: protocol.

Copy link
Member

Choose a reason for hiding this comment

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

What we could list here as a benefit is that we've made it easier to fork individual controllers without everything else, reducing the maintenance burden of those forks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this sentence doesn't make any sense as a motivation, does it 😕 Admittedly, I editorialized the monorepo kickoff document a bit. Given that we aren't able to link to that document anyway I think I will just steal what you wrote @Gudahtt. Maybe the part about forking still makes sense but I'll work it in more as a benefit than a motivation as you said.

- Instead of forking, product teams can publish [preview builds](./preview-builds.md) for in-progress work and make use of those builds in products to test them out as they are working on new features.
- Although not carried out yet, in the future we hope to bring shared libraries as well as additional controllers not hosted here into this repo so that we can standardize the shape of each package much more easily than we can today.

For a more in-depth explanation of challenges and solutions, read the [kickoff document for the monorepo project](https://docs.google.com/document/d/1G3M-lcwvfNFs3Tq4lVzhywqzYhCqPqBN7c5n8TC9sWM/edit).
Copy link
Contributor

Choose a reason for hiding this comment

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

Authwalled link - can this be published?

Copy link
Member

@Gudahtt Gudahtt Nov 24, 2022

Choose a reason for hiding this comment

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

Hmm. I guess we could publish it. It seems a bit in-the-weeds though, not especially relevant to external contributors, especially over time. And it has links to other internal docs.

We should at least note that it's an internal doc though (anyone with a ConsenSys account should have comment access).

Copy link
Contributor Author

@mcmire mcmire Nov 29, 2022

Choose a reason for hiding this comment

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

I think I might remove this link entirely and work in more of the text itself into this document (assuming that it still makes sense to explain the motivations behind the monorepo). If our intent is to keep this private I don't want to risk it leaking out.

@Gudahtt
Copy link
Member

Gudahtt commented Nov 24, 2022

Wow this covers a lot! I see what you mean about this being in the style of a blog post. I do find that format can work well for learning things. But it's less effective for reference docs, having to search through the text each time you refer back to something. Maybe we can keep this style, but pull out some of the information into more concise reference docs.

docs/what.md Outdated

The short answer is that it's our solution to managing and disseminating state changes within our products.

Every application needs to manage state. Some state is temporary. Perhaps the
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, this paragraph seems a bit... meandering. I like the idea of establishing what application state is; just saying "state" can be a bit too abstract to grasp. Maybe we can reformat this to separate the examples of application state from the details about some state being transient, some persisted, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair!

Comment on lines +29 to 35
Or, in graph form:

![Dependency graph](assets/dependency-graph.png)

> **Note**
> To regenerate this graph, run `yarn generate-dependency-graph`.

Copy link
Contributor

Choose a reason for hiding this comment

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

Intended together with #989 (comment)

Or, in graph form:[^1]

![Dependency graph](assets/dependency-graph.png)

Refer to individual packages for usage instructions.



[^1]: To regenerate this graph, run `yarn generate-dependency-graph`.

Copy link
Contributor Author

@mcmire mcmire Nov 29, 2022

Choose a reason for hiding this comment

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

Ah. I keep forgetting GitHub supports footnotes. That will put the note all the way at the bottom of the document. I guess that's okay — it's not something that needs to be referenced that often.

Comment on lines +12 to +14
- The developer can preload the state (say, from a persistent location) when initializing.
- The application can update the state at any time.
- In another location, the application can listen for and respond to state changes (or stop listening altogether).
Copy link
Member

Choose a reason for hiding this comment

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

Not sure about the use of "location" here. The first time it seems like it means a location on disk, and the second it seems like you mean somewhere else in the codebase.

Maybe something like this would be clearer:

Suggested change
- The developer can preload the state (say, from a persistent location) when initializing.
- The application can update the state at any time.
- In another location, the application can listen for and respond to state changes (or stop listening altogether).
- State can be set as part of initialization.
- State can be updated at any time.
- Controllers allow subscribing to state updates.

Copy link
Contributor Author

@mcmire mcmire Nov 29, 2022

Choose a reason for hiding this comment

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

Ah, gotcha, good point.

I was trying to make it a bit more visualizable rather than abstract, and I feel like using the active form achieves that more than passive, but your rewording is more concise, so I like that. I'll play around with this a bit more.

mcmire and others added 3 commits November 29, 2022 09:58
Co-authored-by: legobeat <[email protected]>
Co-authored-by: legobeat <[email protected]>
@mcmire
Copy link
Contributor Author

mcmire commented Nov 29, 2022

Thanks for the feedback @legobeat and @Gudahtt! Now that I've written all of this out, I'm going to take another stab at these docs using a more concise reference style rather than an informal, explainer, blog post style. I'll make a new PR but leave this open in the meantime for continued discussion.

@mcmire
Copy link
Contributor Author

mcmire commented Nov 30, 2022

Okay, I've extracted the basic information from this PR into #993, and am placing this PR into draft to indicate WIP. I plan on rewriting the architectural aspects at a later time.

@mcmire mcmire marked this pull request as draft November 30, 2022 17:47
@Gudahtt
Copy link
Member

Gudahtt commented Dec 8, 2022

@mcmire is there anything here you still wanted to move forward, or can this be closed?

And similarly, do you think we can close the linked issue?

@mcmire
Copy link
Contributor Author

mcmire commented Dec 8, 2022

The essential portions of the documentation here have been extracted and merged, and the non-essential portions I will have to rewrite, but I am not working on that at the moment. Rather than clutter up the PR list, I will close this (I will likely end up making a new PR anyway).

@mcmire mcmire closed this Dec 8, 2022
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.

Document the purpose and history of the controller pattern
3 participants