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

Asyncing #4

Open
mmerkes opened this issue Mar 29, 2014 · 3 comments
Open

Asyncing #4

mmerkes opened this issue Mar 29, 2014 · 3 comments

Comments

@mmerkes
Copy link

mmerkes commented Mar 29, 2014

Introduce and explain asynchronous programming

@mmerkes
Copy link
Author

mmerkes commented Mar 29, 2014

Asyncing

When writing applications with Node, an essential operation is querying a database and processing the data once it's received. How would the performance of our application be if we always had to wait for the database to return data before would could perform any other operation?

Fortunately, Node allows for asynchronous operations (meaning, non-blocking input and output operations). Given a method for our database defined as db.findAll( tableName, callback ), write a program that finds all of the rows in the guestlist table, and print out the first_name and last_name for each row returned in the console.


  1. Sample data returned would be added to the hints
  2. db.findAll would be implemented in a setTimeout and return an array of objects
  3. I thought it might be helpful for beginners to get the basic idea of how querying a database would work
  4. In the hints section, we could provide an example of async with setTimeout

Does this look like an appropriate async exercise? I thought a more realistic operation would be better than the classic setTimeout examples. Any thoughts would be appreciated!

@davearel
Copy link
Owner

davearel commented Apr 1, 2014

@mmerkes I do like that it's realistic, and geared towards node.js.

It could be a little much, but given the proper boilerplate, a couple links to resources to better understand async, this exercise could be extremely rewarding to beginners. It would feel like they've actually programmed something, rather than coded an arbitrary example.

One thing to keep in mind is there may be two types of people coming to this exercise. Some that don't understand programming at all, and some that want to learn JavaScript but has some basic understanding of programming. Both scenarios require a proper introduction to async and why it's important, but those coming from other languages may not understand the importance of async in node.

@mmerkes
Copy link
Author

mmerkes commented Apr 1, 2014

All things being equal, creating realistic exercises is better, but I agree that this may be pushing it. Once we start writing this out further, we can try to get a sense of how well it fits in, and to simplify things, we could switch out the operation performed in the callback to fit in with previous exercises. Regardless, the hard part will be writing a concise and clear explanation of async. I'll try to get the first draft going to people have something to iterate off of.

Once we get to the point of having something to use, I can try to take advantage of a huge aspiring developer community out in Seattle to try to get a little feedback.

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

No branches or pull requests

2 participants