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 DOM Scripting By Example Improving the Application Code Refactor 1: Create List Items

Brian Patterson
Brian Patterson
19,588 Points

I hated this video!

I absolutely hated this video. If ever I felt that I was crap at programming this confirmed it. I just did not get from start to finish!

Abraham Juliot
Abraham Juliot
47,339 Points

Hi Brian, Really? I loved this video and this course is one of my favorites. What concept or aspect of the video are you having trouble with?

The video may be summarized as follows:

  1. Spot duplicate code
  2. Create a function to handle arguments of duplicate code
  3. Replace duplicate code with call to that created function

... repeat steps 1-3 as needed

brendon hanson
brendon hanson
6,191 Points

I agree! I couldn't understand any of this

RJ Foley IV
RJ Foley IV
7,785 Points

I’m coming up towards the end of the Beginning JavaScript track. Just to preface, I’ve LOVED taking this course and till these last two courses has been unbelievably accessible.

That said, in review: the issue with these latter two courses(JavaScript And The DOM & DOM Scripting by Example) is unlike the earlier courses — when it comes to explaining the crucial methods/properties/function aspects that are introduced and discussed — there’s a very serious lack of(practically non-existent (tree-branch DOM metaphors aside…)) real-world(possibly illustrated/animated) examples to help universally explain how they run.

It’s pretty much: “…Just go look at Modzilla.” (which can be confounding enough for a complete beginner… it’s why users have come to Treehouse in the first place).

My recommendation for Treehouse would be to revisit and attempt to explain the methods, properties, event objects and function-refactoring into real-world examples (similar to the coffee and race track metaphors in earlier courses). I know it’s not easy, but it would help retain people’s attention, improve understanding of what’s covered and possibly lead to more users through recommendations & word-of-mouth.

RJ Foley foley.design

I watched this one at least 3 times, I gets better.

9 Answers

Tanner Cruiseship
Tanner Cruiseship
5,707 Points

Yeah I'd have to agree. condensing the code was way more confusing than getting it to work. I don't believe in learning styles, I think Guil is just oblivious to the complexity of this compared to what he showed us before, a side effect of being really good at something.

Brian Patterson
Brian Patterson
19,588 Points

Thank you, Tanner, I'm glad I'm not the only one.

Boby Vilayvong
Boby Vilayvong
13,039 Points

Guil absolutely took it to a whole new level in this video. It's great to see that you can add and maneuver codes around to make it easier to read and still make it function the same. I think this skill in this video takes a lot of practice and some experience. Just keep at it, keep learning, keep practicing, you will get there!

Steven Parker
Steven Parker
208,478 Points

You might find this episode of The Treehouse Show helpful. It talks about different learning styles and blocks and ways to deal them them.

Brian Patterson
Brian Patterson
19,588 Points

I am going back to the DOM course and making notes. Also, I am applying the principle to a website that I am putting together.

Teacher Russell
Teacher Russell
16,872 Points

I'm a novice coder, but I have gone through all of the courses recommended to get to this one. I found myself sailing through it with ease and understanding everything immediately. It was fun. Then I hit the wall here in the last section. That usually means, it's time to learn something bigger and more challenging, and possibly important, which is why I'm here. After watching these last videos 3,4 and 5 times, taking notes, following along, etc, it's becoming clear and natural. Everything here seems to be built on something we covered in previous lessons/courses. Like others, I've had some issues and frustrating moments with courses and certain videos (sometimes because of the video, many others due to a lack of rest I had gotten between lessons or courses), but I have to say these JSDOM courses are very well put together. I think after mastering these lessons, a student would have the ability to look at a problem, and see the final solution more quickly, with less refactoring needed. They teach the steps leading up to the refactoring well, and help one's brain can understand the mechanics of the functions better. Hats off to Guil and Co. A lot of the value in Treehouse lies in learning how to use it.

Edwin Rivera
Edwin Rivera
4,541 Points

I half agree with this post, I feel like from the beginning they should reinforce doing the code with the dont repeat yourself method instead of having us do it this long complicated way just to have it deconstruct it, i had a hard time getting my code to work because i was trying to follow guil while trying to understand what he was doing. Im trying to tell myself it will get easier but i feel if we would have just done it from the get go with the functions, I would have understood it better. thats my 2 cents

well code refactoring is something that is common in the real world. so it's important to cover, but i feel like this jumped from beginner to expert without any in-between... i didnt understand a lot of the logic behind what was being condensed, and how he knew that would work in the same manner.

Isis van der Plas
Isis van der Plas
13,445 Points

don't feel bad! different people understand different things, you might grasp concepts that leave others with a gigantic questionmark above their heads ;) also rewatching videos (even more than once) might help. good luck!

Rose Gao
Rose Gao
5,911 Points

However , I like this video , I already have learnt too much from this video to improve my coding looks better tank before. thanks Steven Parker

Haley Bengtson
Haley Bengtson
Front End Web Development Techdegree Student 14,334 Points

I thought this video was fairly well explained. However, I have been practicing writing JavaScript and using the DOM for a few weeks now and have a better grasp on how to create functions to simplify the code, following the DRY method.

I could see where the code became repetitive and knew that refactoring the code would help to decrease that and make our code more 'modular' and less cluttered. I can understand where you are coming from in trying to understand how this makes it 'easier to read' since adding in additional functions to do the same code makes your eyes jump across the page rather than in chronological order. But, using these functions can help save you time in writing out additional code later on, making changes to your functions, and (in some instances) writing less code thus making the files smaller and more efficient when it comes to load time.

If you had a hard time following, and pausing the video and rewinding a bunch of times still doesn't help you, then maybe following other videos on learning the DOM or Javascript Functions would better prepare you for this lesson. Like I had previously mentioned, I had some practice in this for a few weeks, so it was fresh in my mind and I was better able to follow along.

Hope you were able to follow along and best of luck in coding!

Brian Patterson
Brian Patterson
19,588 Points

Thanks for the reply Haley Bengtson . I have a bit of a love hate relationship with coding. Mostly hate! I can't help thinking there is a better way of learning this stuff. I'm doing the Express JavaScript course and it has taken the place of the most hated course! I don't know whether I have been wired differently to you guys or I am pretty thick I do find this very hard.