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 Object-Oriented JavaScript (2015) Practice Project Quiz Prototype

Order of prototypes

This is more of an observation rather than a question. I am sure it's subjective, but I feel Quiz.prototype.getCurrentQuestion should be stated before Quiz.prototype.guess.

I feel it's more of a chronoligical order and tells the story better. Also getCurrentQuestion is used within the guess prototype, so if we read code from top to bottom, we know where it's coming from instead of having to search for it, especially if reviewing your code several months later.

It took me a while to figure out that getCurrentQuestion was defined later in the code. This is a small project so it didn't take me a huge amount of time, but it did take extra time. In a larger project it would take even longer.

Am I wrong in my thinking? Or is there a reason it was declared after instead of before? I look forward to hearing other thoughts and opinions?

1 Answer

ludopuig
seal-mask
.a{fill-rule:evenodd;}techdegree
ludopuig
Full Stack JavaScript Techdegree Student 6,436 Points

Hi!

I think you are right, I also read it better your way but it depends also on programming style or even style guides inside organizations... at the end, we will sometimes find it one way, and sometimes the other, and yet other times in a complete other way we can't figure out now!