• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Tuan Huang

  • Spring 2022
  • Fall 2021
  • About

ICM : W5

This week, I learned the idea of Object-Oriented Programming (OOP) from Dan Shiffman’s tutorials. Using class, I rewrote one of the codes from last week, without any change for end-users.  

The one I rewrote – 

I chose this one because there were 4 repetitive for() loops in the code. I remember that last week I tried to write these in nested loops, but I couldn’t manage to separate each group of lines. However, this week, making each group into an object, the variables in an object won’t be affected by each other, which makes the whole difference and turned out well. 

screenshot of code from p5js
the original code – a lot of repetitive for loops
screenshot of code from p5js
new code – writing with class, so much cleaner!

 

 

 

 

 

 

 

 

 

The transfers happening between class, constructor, and parameters are still not so intuitive to me though, so I tried to create another sketch base on these concepts.

05.01

05.02

sketch on p5.js

 

Primary Sidebar

Footer

Recent

  • #final project: E-Forms
  • #5 Form Generator + Auto-fill by computers
  • #4 Revisiting Digital Cut-up
  • 03: Form Generator
  • 04: Tunnel Cube

Tuan © 2025