reduxjs / redux

A JS library for predictable global state management
https://redux.js.org
MIT License
60.79k stars 15.27k forks source link

Discussion: revamped docs content, structure, and teaching flow #3313

Closed markerikson closed 4 years ago

markerikson commented 5 years ago

Per discussion in #2590 , we'd like to rethink the Redux docs content and structure pretty much from the ground up. Now that we've got the new docs site up and running, it's time to start brainstorming what that content should look like. (There's already a bunch of discussion and notes in #2590, but I wanted to open a new issue specifically to brainstorm ideas.)

There's a few questions that we should try to answer:

In general, there's lots of good Redux tutorials, articles, and resources out there. I would like us to beg, borrow, and steal the best ideas and examples out there for use with the docs (with permission if appropriate, of course :) )

Anyone is welcome to contribute to this discussion, but I'd particularly like to get involvement from other people who have experience writing material that teaches Redux or working on docs. On that note, tagging:

@dceddia @rwieruch @joshwcomeau @valentinogagliardi @alexkrolick @matthew-gerstman @tylermcginnis @gaearon @timdorr

matthew-gerstman commented 5 years ago

How should we organize the content? What are the weaknesses and deficiencies in the current docs that we are trying to resolve?

IMO organization is the problem we're trying to solve here. We have a lot of content and its hard to find/parse. Here's a rough outline similar to the one @alexkrolick did in the previous thread.

Outline

Landing Page (Readme)

We should be optimizing here for not scaring the user. I don't think we should be using the docs to sell redux, chances are the reader has already opted into it by default.

This should cover a basic what is redux and how to install it. We should then push the user to one of the major sections I'll outline below.

Getting Started Guide

Api Reference

This should feel like a reference textbook. Lots of definitions, explanations of how to use the store etc.

Integrations

Typescript, Vue, ReasonML, SSR, whatever else people are using redux with.

Other questions

How do we handle teaching prerequisite concepts like immutability, JS array methods, and event emitters, in relation to the actual Redux concepts and usage?

I think these should be things we mention in the getting started section and then link out to in the API reference section.

How do we differentiate between teaching "plain" Redux usage, and usage with a UI layer like React-Redux?

Do we really want to encourage plain redux usage anymore? Do we have any kind of stats on how many people still do this? I also feel like people who want to roll their own redux integration will be mostly focused on the API spec.

How do we integrate teaching and encouraging the use of redux-starter-kit into the new docs?

We could decide that redux-starter-kit is the fastest way to get the user through the getting started guide. If we do that we start teaching the starter kit instead of redux core.

markerikson commented 5 years ago

Do we really want to encourage plain redux usage anymore?

Not "encourage", exactly, but I think there's definitely value in teaching people what the bare-bones "by hand" usage looks like, so they understand what's happening. That way the later abstractions will make more sense.

As part of that, much of what RSK does only really makes sense once you understand the annoyances of doing everything "the hard way":

But those are all abstractions that really benefit from the user understanding what doing it by hand looks like, so they know what's going on. Quoting Dan:

Dan Abramov, just now : "if you want to teach someone why to use an abstraction, you should first make them feel the pain of not having it"

matthew-gerstman commented 5 years ago

Just wanna clarify here.

When I said bare-bones I mean redux without react-redux, redux-starter-kit etc. I'm thinking manually calling subscribe etc.

I think we should be pushing some level of abstraction by default. That could be either react-redux or RSK.

To nitpick on Dan's quote. I don't think we need to teach the "why" right away.

I want to give readers a sense of accomplishment (by using abstractions) as quickly as possible and then push them to learn underlying concepts (pub/sub, immutability, etc).

markerikson commented 5 years ago

Right, so the over-arching question here is, how do we structure the content based on that?

Also note that React-Redux and RSK aren't mutually exclusive - RSK is just about the "Redux usage" level, and thus useful no matter what UI layer you're using.

matthew-gerstman commented 5 years ago

Does this basic outline seem reasonable? I kind of think of it like the user is gonna do a depth first search on the docs so getting started should be light and then the other two can go much deeper.

markerikson commented 5 years ago

My Thoughts

I'm gonna toss out my initial thoughts off the top of my head, without doing further in-depth analysis and comparison with other approaches.

In general:

Thoughts on Current Sections

Landing Page

Right now we've got a giant "Get Started" button, and the top bar links set points to "Getting Started", "API", "FAQ", Github repo, and the "Need Help?" section of "Getting Started".

We've also got the "sales pitch" paragraphs + icons, links to React Redux and Redux Starter Kit, and (for now) the docs revamp survey.

I'd really like to have some kind of "guided path" links here, like:

I want to:

  • Try Redux for the first time
  • Learn through tutorials
  • Understand how to "think in Redux"
  • Learn best practices for real-world usage

These might link directly to specific pages, or they might point to an intermediate page that further links to "Read pages A, K, and Q, in that order". (Examples: https://twitter.com/jaaaarwr/status/1079570766742675456 , https://metacademy.org/ )

Introduction

"Getting Started", "Installation", and "Examples" are probably okay as-is, and probably keep "Learning Resources" here too. "Motivation", "Three Principles", and "Prior Art" should probably be moved into the new "Thinking in Redux" category. "Ecosystem" should be moved under the new "Real World Usage" category. We should add a new "Quick Start" page that shows fast app setup using RSK and React Redux.

Tutorials

I want to have a series of tutorials that add increasing levels of complexity. These might be based on or tied into the existing projects in the "examples" folder. The exact project types and implementations should be carefully thought out to help get across the specific concepts we want to teach for each one.

I'd like to keep these tutorials as focused as possible. That means skipping stuff like "three-phase actions", writing action constants inline instead of as separate variables and files, etc. I also want to start with as much stuff in a single file to begin with, and only split it into multiple files later, at which point I want to use "feature folders" instead of "folder-by-type". I also want to hold off on showing action creators right away. (Related: I ran a Twitter poll on what folder structure the tutorials and examples should show by default.)

Possible sequence:

Recipes

Oh, dear. This section has become such a hodgepodge of random stuff. A lot of the content in here is good, but needs to be moved to other sections, primarily a new "Real World Usage" section, and possibly a new "Guides" section.

Thoughts on some specific pages:

FAQ

Again, I wrote this, so I'm rather proud of it (and have heard lots of good comments about it). Main thoughts here:

Other

The "Feedback" page should go away. I didn't even think I included it in the new docs page. We never used the Product Pains site in any meaningful way. At most, it should point to the issues list, SO, Reactiflux, etc.

There's overlap between "Troubleshooting" and "FAQ" that we ought to think through.

Ideas for New Sections

Real World Usage

This should be the biggest improvement to the revamped docs: lots of guidance on how to correctly structure a meaningful Redux app. This is the biggest area we don't cover well right now. Large portions of this could be existing material that's moved around, but we definitely need to cover things like:

Should probably also have some "advanced usage" sections in here, like store enhancers, batching subscription notifications, etc.

Using Redux with a UI

This section should start with a page that talks about the basic update sequence (subscribe, get state, update UI), and show how to do it in vanilla JS. It should then have multiple pages that talk about how to use Redux with each major UI framework (React, Angular, Vue, Ember).

Understanding Redux

This section has several objectives:

Style Guide

This is a direct ripoff inspiration from the Vue.js Style Guide page. The goal here is to actually express opinions on what we think are good approaches, but also qualify how strongly we feel about each one. Items off the top of my head:

Suggested Revised Structure

With all that in mind, here's a sketch of what the new docs structure might look like (with handwaving of the exact individual sub-pages):

Other Thoughts

Looking at Vue's docs specifically, they don't have everything all in one giant TOC list. There's separate TOCs for "Guide", "API", "Style Guide", "Examples", and "Cookbook". Have to say it's not immediately discoverable - those are listed in a hover menu labeled "Learn" in the header. There's another hover menu labeled "Ecosystem" that has "Help", "Tooling", "Core Libs", "News", and "Resource Lists". Not sure if that's something we would want to emulate, or even if it's possible with Docusaurus.

We've already got a lot of content, and we're looking at adding a lot more. I'm concerned about how big the TOC is going to get, and how people will find the info they need. Docusaurus doesn't currently let us minimize TOC sections by default, but there's a PR. Is that something we'd want to use?

I want to get involvement from other Redux tutorial authors, both for ideas and actual content as well.

I've bookmarked a bunch of articles on how to write good documentation. I need to actually read through those and try to pull out some lessons. We should also spend some time going over docs sites for other libs and see what useful techniques we can pull out.

I can't do this all myself - gonna need a lot of assistance :)

Finally, I've been running a survey asking for feedback on the current docs structure, and suggestions for improvement. We're currently at about 100 responses, although I tweaked the questions after the first 75 or so. I'm attaching a PDF with a printed version of the summarized responses, and a spreadsheet with the actual responses:

Redux docs improvements survey responses.pdf

Google Sheets: Redux Docs Redesign Survey (Responses)

wgao19 commented 5 years ago

Hope to contribute here too :)

I'm a fan of small, concise, well-organized official docs.

Suggest smaller docs, more guides > tutorials, more intentions with examples

So based on @markerikson 's suggested outline, can I suggest to combine "tutorials", "real-world" (tutorials have a "real-world" section too), "using with UI" to a "usage" section. And instead of making them tutorial like, make them more "guide" like?

Another reason I wish to reduce "tutorials" in favor of "guides" is that there are a lot of podcast-based tutorials that might actually work better than docs. Dan's Redux course is free on egghead.io.

Suggested Outlines

(omitting the subsections)

And the "Usage" section, in particular, can have the following subsections:

I feel every single section under "real world usage" has tremendous value to address.

"Configuring store", for example, gets complex when using Redux with other libraries such as React-Router, Rehydrate, other middleware libraries, etc. In real life we connect quite a number of libraries. That file is a bit hairy. (It's very hairy, in fact 😅)

Each library most often includes guide on using Redux with just that library. Sitting in the center of this issue perhaps we should provide a guide on configuring Redux with all of those libraries.

More Real CodeSandboxes in "Real World Usage"

Like I mentioned earlier I think how it is intended to be used is valuable. And I think the official doc is very responsible to educating its intended usage.

Can we have more "real" examples to showcase good practices?

Can we possibly ask people to contribute by "donating" real usages, i.e. submitting link to a CodeSandbox that recreates the usages in their apps?

FAQ

I'd really love to have your "Blogged Answers series" here: i.e., answered questions turned into doc page. I'd like to help work on those too. Although, I think it'd work better if we encourage the people who asked the questions to write those pages.

timdorr commented 5 years ago

I think the only problem I see is there are like 5 different starting points for the docs. "Introduction", "Getting Started", "Quick Start", "Installation", "Intro", "Examples". Those all pop out at me, so I don't know which one to click on first. I believe those can be combined in some way. In particular, it's always irked me that we have a separate installation guide. That should just go in the Getting Started guide.

matthew-gerstman commented 5 years ago

As I think more on this I think we're missing some important data from the community about how Redux is used. I propose we put out a lightweight google form and try and get some responses.

@markerikson @timdorr If you like this idea I'll add you as owners of the doc

https://goo.gl/forms/POkWwcwnuk9HiPo12

matthew-gerstman commented 5 years ago

Just putting this all in one place. Here are all the polls @markerikson has run over the past 6ish weeks plus one retweeted from @gaearon

https://twitter.com/acemarke/status/1084245223226650624 https://twitter.com/acemarke/status/1083915904893808640 https://twitter.com/acemarke/status/1083767611299639296 https://twitter.com/acemarke/status/1086798115812843520 https://twitter.com/acemarke/status/1086748345513766912 https://twitter.com/dan_abramov/status/1083188821150322689 https://twitter.com/acemarke/status/1078332610609401856 https://twitter.com/acemarke/status/1069806552071266304

markerikson commented 5 years ago

Haha, thanks :)

markerikson commented 5 years ago

I've referenced the Vue docs already, but we should also specifically look at the NgRx docs for some comparison as well: https://ngrx.io/guide/store

Nimelrian commented 5 years ago

Chiming in since Mark has asked for more feedback over on Reactiflux.

Disclaimer and Preface

I'll disclaim beforehand that I have not used the docs for almost 2 years now, mainly because Redux's API is so small that it's easy to learn it by heart.

I'll also preface my comments with stating that I'm one of those devs who argue that people should learn the basics of a language and its standard library before heading towards more complex topics. This is especially evident with the JavaScript community, where people often run into problems because they don't understand the language they're working with and dive straight into UI development. As such, I would expect someone who wants to start using Redux to have a general understanding of JS.

An inexperienced dev diving straight into advanced topics causes frustration on two sides:

  1. The rookie becomes frustrated because they run into errors without knowing what causes them
  2. The more experienced devs who have to deal with the rookie's subsequent questions about basic topics, which the rookie could answer themselves if they would have started at a more suitable point on the learning curve.

Current Docs

Now, for my actual comments for the current docs, so I can establish a foundation to base my arguments regarding the revamped docs on:

Revamped Docs

That's it from me so far :)

matthew-gerstman commented 5 years ago

I'd really like to get started on actually writing so I'm going to propose some process 😱

  1. Let's agree on an outline. @markerikson and @timdorr I imagine you two have the final say here. My vote is Mark's proposal.
  2. Open a new branch and setup the TOC. Let's just get page headers for everything we want.
  3. Allow the community to write the bulk of the content and code samples. Pull requests should be submitted to the branch from #2.
  4. Copyedit so it sounds like it's coming from one voice.

Anything I'm missing? @markerikson @timdorr can we get some kind of kickoff? I'm happy to contribute a lot to #3, but I'm not comfortable kicking off the TOC.

markerikson commented 5 years ago

@matthew-gerstman : sounds good to me. I am unfortunately going to have to focus on the React-Redux side of things for the near future ( per https://github.com/reduxjs/react-redux/issues/1177 ), but happy to chip in on this side as much as possible.

I'd say we'll use my proposed outline as a starting point and tweak as necessary from there.

I've created a docs/revamp-baseline branch, and set up a new Netlify site at https://redux-docs-revamp.netlify.com/ that deploys from that branch so that we can get previews and stuff as we go.

We can probably start by shuffling around the existing pages that just need to be moved into new locations. This would require moving the files themselves, changing the structure in website/sidebar.json, and adding appropriate redirect entries from the old URLs to new URLs in website/_redirects.

markerikson commented 5 years ago

Some good feedback from a beginner who feels the current tutorial is too confusing:

https://github.com/reduxjs/redux/issues/2933#issuecomment-480538889

More feedback:

https://www.reddit.com/r/reactjs/comments/bggdip/remove_redux_itself_is_very_simple/ell1w0t/?context=3

https://www.reddit.com/r/reactjs/comments/bqwa3m/is_there_a_way_around_learning_redux/eonpyeu/?context=3

https://www.reddit.com/r/reactjs/comments/cdx75c/how_i_ruined_my_application_performances_by_using/etx2ubq/

Dan's suggested phrasing for "single source of truth":

https://twitter.com/dan_abramov/status/1165390539707027456

bcnichols3 commented 5 years ago

hey @markerikson, we bumped into each other on r/reactjs. Thought I'd put some thoughts down here for you. Your idea here:

Try Redux for the first time Learn through tutorials Understand how to "think in Redux" Learn best practices for real-world usage

sounds like a great idea, honestly. People come back to Redux at all different levels and having four big buttons to cater to each person sounds very smart: TRY REDUX, TUTORIALS THINK IN REDUX and BEST PRACTICES all feel like great call-to-action buttons. You might also do a link to a library of video demos?

I do like the four sales pitch paragraphs you have, but I don't think the wording adequately explains what you get. DEBUGGABLE should be at top left and come with a video of an app running with Redux DevTools. A Learn More button can take you to their repo. The video they currently have in the Chrome Store isn't especially compelling, by the way. It's just hard to tell what's going on and why it's so useful. The copy could be like this:

Watch your app's state change from the browser. Rewind and fast-forward user interactions, or just log full change and error reports. GET REDUX DEVTOOLS

I'd change "centralized" to "organized". A big thing programmers tell me they dislike about Redux is how it smells like global state. This is not the case, Redux state is quite protected, so I think this needs to highlight how Redux isn't leaking your state everywhere. It's making it easily accessible and enables you to expose only the portions necessary for a particular piece of code, which makes that code way more testable as you don't have to mock massive structures to stand it up. I might suggest this:

Redux stores have only one way in and one way out, relieving the stress around complex state changes. Ask simple questions, write simple code, test with a snap. THINK IN REDUX

I might also change "predictable" to something else. Most people who are considering Redux are using React, so they've already signed on to Flux. You might use this space instead to highlight Redux-Starter-Kit and how it allows you to set up Redux with less boilerplate than ever, the other biggest gripe people have with Redux. You might also play up your typescript support, which is a huge deal for a lot of code shops these days.

The "flexible" block is great, I'd just add another small call-to-action button there to go to the Ecosystem page. You might also make the top of that page more fun and prioritize things by use cases. Caching and persistence, analytics, form wizards, load-from-storage PWA support are probably the biggest topics here.

Hopefully these are useful thoughts!

markerikson commented 4 years ago

Wrote a Reddit comment summarizing how the Redux DevTools extension works, and linking a couple articles that cover it in more detail:

https://www.reddit.com/r/reactjs/comments/df0bvv/why_redux_makes_you_a_better_javascript_developer/f3395aq/?context=3

markerikson commented 4 years ago

Another interesting idea: linting the docs content to remove words like "simple" and "easy":

https://twitter.com/rickhanlonii/status/1183785117145325568

timdorr commented 4 years ago

If we do that, we should only make it a warning, not a hard failure. retext/alexjs doesn't take into account context, so it can create a ton of false positives. But I like the idea at its core.

leonardoelias commented 4 years ago

1️⃣ I believe we can build a playground on Redux. Where we would have some examples that the user can change and break the application. 2️⃣ Easy translation into other languages.

Look at: https://nextjs.org/learn/basics/getting-started https://www.gatsbyjs.org/tutorial/part-one/

leonardoelias commented 4 years ago

Could we redesign the site? If so, I would like to participate, I have great ideas.

markerikson commented 4 years ago

@leonardoelias : I'm not planning to redesign the site appearance, just the content.

I'd definitely be interested in adding translations, but I think that needs to wait until we've completed redoing the content.

timdorr commented 4 years ago

Closing in favor of #3592