Learn about the importance of efficiency in code. Coding is like organizing a closet. It should be easy to access the things you use everyday like shirts and pants, but organized enough that almost anything can be retrieved.
- [Instructor] In thinking about efficiency, let's think about a closet. Your closet will have pants, coats, socks, and shirts, but some of these items you'll wear more than others. This is just like in code where there are some processes you'll use more often at a given time. Think of your closet like the place where you have all of your code. In order to be efficient in picking out what you want to wear, your closet should be organized, and this is the same for your code in your app or website. Say it's summer time, but your coats are in the middle of your closet.
We might want to reorganize so that way our shirts are in the middle, rather than our coats, because we'll be wearing them a lot in the summer. So if we move the coats to a different shelf, and place the shirts in a more accessible space, the middle of our closet, it will be easier to access the T-shirts we wear every single day. However, if this was winter time, we would probably want our coats somewhere in the middle. Just like in code, you'll want the stuff you use a lot to be quicker to access than the stuff you don't use as often.
Everything should still be accessible, but it's okay if something takes more time to get to you as long as you don't try to retrieve it very often. Digging in your closet for that one missing sock often takes a lot of time, and this is what we try to prevent by making efficient programs. Furthermore, it's usually easier to organize your closet when you have less stuff. Hence, it's often easier to clean your code and make it more efficient if you have less lines in your program. A messy closet is like messy code. It will be harder to use and access what you want.
Code efficiency is key. No one will use your programs if they take forever to do what you want them to do. Think if you were making an app, you don't want it to take forever to load a certain screen, because then you will lose users. Efficiency is about using your resources wisely, and figuring out what you can do with what you are given without it taking forever. If you are interested in these types of problems, check out Foundations of Programming: Code Efficiency. This course will go more into the theory of efficiency in computer science, as well as how to make your programs more efficient overall.
- How to approach problems
- Things to consider when preparing to program
- Overview of common coding languages
- How to think like a mobile app developer
- The importance of planning
- Breaking problems into smaller chunks
- How to think like a data scientist
- The importance of code efficiency
- Organizing code with color-coding and comments