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 trialGavin Broekema
Full Stack JavaScript Techdegree Student 22,443 PointsWhen is refactoring necessary?
So say I am creating a mock-up design or the "rough draft of a web page. Is it common practice to refactor throughout the actual development process? Or should I finish the rough draft then go back through and refactor during revision?
I feel like if I were to refactor every time I saw the opportunity, my project could become... Too DRY if that make sense.
2 Answers
jcorum
71,830 PointsYou got it. DRY is a rule or guideline. Technically, refactoring is the process of changing your code, for whatever reason. Usually it is to implement DRY, but not necessarily. There are other reasons to refactor. E.g., a more efficient way to do something.
CSS methods manipulate the HTML. Here's a link to a list of them: http://www.w3schools.com/jquery/jquery_ref_html.asp
jcorum
71,830 PointsGavin, you mention DRY. And, in my opinion, that is the key. You refactor whenever you find yourself duplicating code. For example, rather than copy some code and say you will return later and fix the duplication, you stop and put the code into, say, a separate method, and then call that method from the several places the code is needed.
That's not too DRY. It's just DRY enough.
Gavin Broekema
Full Stack JavaScript Techdegree Student 22,443 PointsOk, that makes sense.
As far as terminology goes, would "DRY" just be considered a rule and "refactoring" be the actual process of implementing DRY? Also how would you define the term "method" in CSS?