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 trialTony Minseok Kim
Front End Web Development Techdegree Student 11,682 PointsIn real life situation, or workplace situation
So Guil just put all the codes into a function, so that it is more readable and easy to use it over and over again, but I was just wondering when it comes to a real life situation, do you guys usually make functions first or just like Guil, make functions after once you find repeating code lines.
1 Answer
Dane Parchment
Treehouse Moderator 11,077 PointsIn the "real-world" it's normally a bit of both. In general, you will be using and creating many functions. But there may be some instances where you find a lot of code repeated in multiple places in your codebase. Instead of just leaving them there, in an effort to be DRY (Don't Repeat Yourself), the common code is generally extracted into a new function.
Tony Minseok Kim
Front End Web Development Techdegree Student 11,682 PointsTony Minseok Kim
Front End Web Development Techdegree Student 11,682 Pointsahh I see! Thank you!