8. Functions and Methods

Note

Project: Replace all the photos in the Facebook feed with photos of kittens or puppies.

Your kittenbook code is a mess. I’m sorry to say so, but it’s a complete mess. All your variables are global (see the later section, “Scope”), and it is unclear which instructions are meant to achieve what job. I suppose the mess is really my fault because I told you to write the code the way it is written, but it’s a mess nonetheless. You might be questioning my methods. If I’m supposed to be teaching you how to program, why would I tell you to write bad, messy code? I have my reasons, I promise. First, you can’t appreciate the value of clean code until you have worked with messy code. Second, to understand the tools you need ...

Get Learning to Program now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.