Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

jQuery Basics - Planning question

In this part of the problem solving process, Andrew lists all the steps required to fix the problem. My question is, what is a good way to get started learning how to list the plan when trying to tackle a project on your own? If I had the planning down, performing is the easier part. If it's just about experience, how would you even get off the ground to accumulate it?

2 Answers

Andrew Shook
Andrew Shook
31,709 Points

I start my planning process by defining what my goal is and then defining what the data is that I am working with. For example, I need to build a jQuery form validator ( note that I would never do this because there are a lot of good ones out there). So in this case my goal is to validate a form and my data will be the user input from the form.

Then the next step in my process is to determine what I need to do with the data to accomplish my goal. The short answer is I need to validate it. The long answer is I need to define what is and what is not valid for each input field in the form. For this I use my Google-fu and do some research. For example, what are common features of an email address. Well, it will have some kind of string, followed by an @ symbol, followed by another string, followed by a dot, followed by another string. So all email address look something like this: blah@blahoo.com

Once I finish my research I build out the structor I need to start testing (the form in this case), and determine what steps I need to take to check the data. In this example, I should probably stop the form from submitting until the jQuery validates it. How should I do that? Lets ask google. Now that the form isn't submitting what should I do? Well each field will probably need its own validator so I start writing those. They work fine individually but I didn't tell the jQuery when is should use each validator. How do I do that? GOOGLE IT or ask a co-worker/boss/forum. Oh I'll just tell jQuery to check the type attribute of each input element and then select the correct validator.

That's pretty much my work follow. Figure out the goal, figure out the data, and then figure out how to get the data to do what you need it to do. And if the data can be broken down in to chunks (like the form example), then I separate the data by its differences and group things that are alike. In the end, breaking a complex problem like this down take practice so it's just a matter of doing it over and over again.

EDIT TL; DR:

  1. Define what the goal is and what data you will be working with.
  2. Examine data and determine whether it can be broken down into smaller groups. If so, group thing that are alike and separate them from things that are different.
  3. Determine requirements for data. Ask your self what do you need to do with the each group of data to accomplish my goal.
  4. Reacher methods for the best way to meet your requirements for each data group.
  5. Determine steps needed to process the data as a whole and then as individual groups.
  6. Build method for processing each group of data and then test individually.
  7. If necessary, build method for unifying the separate data processing methods.
  8. Add each individual data processing method to the unifying method one by one. Test for bugs before adding next method.
  9. Once all methods are unified, test and debug.
  10. Check to make sure all goals and requirements are meet. If not make corrections.
  11. Understand that all systems (e.i your library or program) have there limitations and shortcomings. Decide if the limitations or shortcomings of your work will have a negative impact (user experience, backwards or forwards compatibility). If shortcoming or limitation are likely to cause a lot of problems, go back to step 4.
Andrew Chalkley
Andrew Chalkley
Treehouse Guest Teacher

> In the end, breaking a complex problem like this down take practice so it's just a matter of doing it over and over again.

Yep!

James Barnett
James Barnett
39,199 Points
  • figure out the various parts of a large problem.
  • the large parts into smaller pieces.
  • Keep going until you've got "bite-sized" features that you can code to 20 or 30 lines
  • Get the code working

Your goal is then to keep your code working adding together bite-sized features until you get to the large problem.