Skip to content

Remove Extraneous Examples #796

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

Open
sambensim opened this issue Apr 15, 2025 · 2 comments
Open

Remove Extraneous Examples #796

sambensim opened this issue Apr 15, 2025 · 2 comments

Comments

@sambensim
Copy link

Topic

Some examples seem rather repetitive, such as the second example here, which is more complicated that the initial example but not much simpler (one less argument) than the third.

I believe that examples should demonstrate something new and generally increase in complexity, though I'm not sure if this is the consensus of the community.

Is it worth combing through and looking for extraneous examples?

@ksen0
Copy link
Member

ksen0 commented Jun 5, 2025

Hi @sambensim ! In that particular example, though, the second example demonstrates usage with a callback and without the error handling, which might be helpful to show that the parameters are optional.

Tagging documentation steward @perminder-17 - p5.js uses optional parameters widely, do you have a sense of whether it's useful to have the multiple usages demonstrated, or if there's some other way to make optional parameter use really understandable and tangible for beginners?

@perminder-17
Copy link
Contributor

Thank you very much for sharing these examples. In my view, both snippets demonstrate distinct and valuable approaches, so having both examples is quite beneficial rather than problematic. The first example illustrates the well-established preload + setup pattern, which ensures that the image is fully loaded before any drawing operations occur, while the second example highlights the callback approach by invoking loadImage() directly within setup() and reacting immediately once loading completes. Each snippet therefore conveys a separate technique, one for guaranteed preloading and the other for on-the-fly loading with a callback. wihtout causing confusion. If additional clarity is desired, we could certainly include further illustrations, but these two already capture the primary options in a clear and concise manner. Thank you again for your thoughtful consideration.

@ksen0 I think the two examples we have strike a good balance but multiple demonstrations of exmples are always appriciated. To make optional parameters even clearer for beginners, we could (1) add brief inline comments in the snippets and (2) add a short “Optional Parameters” note in the Foundations section explaining that p5.js follows standard JavaScript behaviour.

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

No branches or pull requests

3 participants