Cleaner Code Basics

Lesson

Cleaner Code Basics

When making big projects if you have created lots of small sets of code in different classes or repeated code, it can make it a lot more confusing when someone else or you try to look back over it.

Have a look at the two links of code underneath and work out which one is created with clean code and which is not.

https://scratch.mit.edu/projects/352229277/editor

https://scratch.mit.edu/projects/352229279/editor

How to code cleanly:

  • Don’t use lots of “When Green Flag Clicked” blocks try to combine them into one block so it can be read through easily.
  • When naming variables and broadcasts use sensible names such as lives and score rather than using random letters such as “a” or “aaa”.
  • Only keep code relevant to a sprite within its code.

@

Not recently active