Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMichael Williams
Courses Plus Student 8,059 PointsThis video went waaaaaaaay over my head. Can someone explain it to me like I'm 5? Or 3, even?
I get that you're drawing in the info from one file to another, but I don't get Andrew's explanation. Here's the video: https://teamtreehouse.com/library/organizing-your-code-with-require
4 Answers
Kevin Gates
15,053 PointsI think he is trying to separate the logic / ideas. So the profile.js is the main JavaScript code where you actually have a lot of processing going on.
Separate from that concern is his app.js file which is where he wants to manage his inputs / outputs.
By separating concerns, he has modularized his code. This means if he creates another file, let's say an API for another application he has, he could make that API code to also utilize that same profile.js file.
Additionally, if he knows his profile.js file works, that means if an error occurs, he has smaller groupings of code to debug.
To summarize:
- It's cleaner to see (organization).
- Separating concerns and modularizing allows you to easily reuse portions of your code.
- Its organization can improve debugging.
Hope this was helpful. :)
Rick Gleitz
47,876 PointsAdding to what Kevin Gates said, it's pretty much the same reason we have separate CSS and JavaScript files for a website rather than putting it all in-line in the HTML file.
Ryan Agatep
Full Stack JavaScript Techdegree Graduate 17,705 PointsManaging the inputs/outputs in the app.js makes sense. I had the same issue and also needed simplified explanation. 😁