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 trial
Lee Hughes
8,380 PointsGood code vs bad code
Whilst starting to learn more about code and some previous experience with WordPress and plugins I keep hearing good code vs bad code. Can someone expand on this further?
What is considered good code? Is it generally having the same application run with less code?
Thanks
2 Answers
Joshua Brown
9,683 PointsGood code is generally well commented and documented although that's probably said too often so I'll keep going.
Good code means avoiding replicating code more than once this probably applies to scripting/programming languages more than HTML and CSS. But, if your doing the same thing twice or more then it's time to take that code and make it a function. If you have long functions where code is duplicated it is probably a good idea to break that function down into separate functions as well.
Jake Craige
4,913 PointsAs said in some of the treehouse videos you want "DRY" code. Don't Repeat Yourself.
To expand on what Joshua said, more so than even well documented is code that is easy to read and flows well. This would be very hard to describe, it's something you start to gain with experience. Some code is just a pain to look at and try to follow it, some is quite easy to look at and follow what's going on and happening. The latter would be considered good code. One thing I think helps with this would be good variable and function names, good alignment of the code, no overly complex method in method in method to get info, at least not complicated ones that wouldn't make sense to another viewer.