Learning from Solution Code
Learning from Solution Code
When you compare your solution to the official solution code, you’ll likely find that there are more differences than you were expecting. This is to be expected, and does not mean that your solution is wrong!
Reviewing solution code is one of the most effective ways of getting better at programming. When you are coding on the job, you will likely be working with code that was written by many different people and throughout a wide time-frame. Being able to read and get up to speed with someone else’s code is a valuable skill that will enable you to be more confident when contributing to shared projects.
Furthermore, comparing your work to the solution code gives you the chance to:
- Review the syntax of the solution. Is there any new syntax that you don’t understand or aren’t comfortable using yet? Review documentation like the MDN JavaScript docs and search for unfamiliar syntax on Stack Overflow if so.
- Think back to the decisions that you made when doing the project. What reasons did you have for making the decisions that you did? After seeing the solution, would you still make the same decisions?
- Think about readability. Often times, the solution code will prioritize readability and maintainability. On long-term collaborative projects, writing clear and readable code is a priority to ensure that other software engineers can understand the codebase well enough to add to it.
- Think about performance. For web apps, this usually means paying attention to the slower steps in the process: when the client sends a request across the internet to the server, and when the server queries the database. Is your code making any unnecessary requests? Are there any steps that could be batched together to limit the number of round-trips between the browser, server, and database? How does the performance of your code compare to the performance of the solution code? Performance should generally not be prioritized over readability/maintainability, but it is something worth considering when reviewing solution code.
Remember that struggle is important when permanently developing a new skillset and that debugging is also a skill that you need to build! Try not to peek at the solution code until you’ve completed the project, or unless you’re really stuck and your struggle has become totally unproductive. Have fun!
'The Codecademy Team, composed of experienced educators and tech experts, is dedicated to making tech skills accessible to all. We empower learners worldwide with expert-reviewed content that develops and enhances the technical skills needed to advance and succeed in their careers.'
Meet the full teamRelated articles
- Article
What is Diff?
Learn about the comparison tool in code editors. 👀 - Article
Giving and Receiving Code Review
Learn what code review is an how to perform one - Article
Transforming Code Errors into Learning Opportunities
Discover how to view coding errors as valuable learning experiences in our comprehensive guide. Learn effective strategies for identifying, analyzing, and fixing errors in your code.
Learn more on Codecademy
- Skill path
Create a Back-End App with JavaScript
Learn how to build back-end web APIs using Express.js, Node.js, SQL, and a Node.js-SQLite database library.Includes 8 CoursesWith CertificateBeginner Friendly30 hours - Course
Learn Python Developer Tools with VS Code
Dive into the world of developer tools with Python and VS Code! Learn how to set up, debug, and unit test your code in your own environment.With CertificateAdvanced2 hours - Skill path
Code Foundations
Start your programming journey with an introduction to the world of code and basic concepts.Includes 5 CoursesWith CertificateBeginner Friendly4 hours