CCI Diploma 2020/2021: Unit 1: Lecture 7: Classing.
Back to slide index.
Hi!
I'm going to start every lecture with a promise and an artist to reference.
I promise that by the end of this lecture you'll be able to understand how you can use objects in your code to scale from one interesting thing to whole ecologies of interesting things, reacting to each other.
The artist of the day is Timothy Morton, who isn't an artist at all.
I was first drawn to his work by this tweet and his book, Hyperobjects.
Hyperobjects are a "objects that are so massively distributed in time and space as to transcend spatiotemporal specificity, such as global warming, styrofoam, and radioactive plutonium". It really helped me start to think about why we aren't doing anything about global warming and what artists and designers can do about that.
I think alot of Timothy's work is about what objects are, how they work and what they do in the world - which is why he's perfect for today's lecture - which is on exactly those things! N.B. Object orientated ontology and object orientated programming are not the same thing. But they do use the same word. So there!
The main thing I want you keep in mind today is the power of object orientated programming (OOP) is that we can combine data and logic together - this makes it much easier to build really large scale software systems, and to share those systems with others - often known as libraries of code. Libraries of code can be abstracted into Application Programming Interfaces (API's) - which is a way of abstracting a load of complexity behind a series of commands and formats of data. For example, Google, Amazon, Microsoft and Apple all provide API's to their operating systems (either locally or on the cloud).
By the end of this lecture, you'll know more about:
Two pioneers in computing, Seymour Papert and Alan Kay, and how they helped contribute to the creation of Graphical User Interfaces (GUI's) and a new way of programming that was invented to make that happen - Object Orientated Programming (OOP).
What OOP is, and how the idea of abstraction plays into it.
How to do OOP using p5.js - time for lots of chickens and eggs to come together!
https://p5js.org/examples/objects-objects.html
https://p5js.org/examples/objects-multiple-objects.html
https://p5js.org/examples/objects-array-of-objects.html
https://p5js.org/examples/objects-objects-2.html
https://p5js.org/examples/objects-composite-objects.html
As well as Abstraction, Encapsulation is an important concept in OOP. A way of thinking about it is sealing away data from other bits of code - only the methods of an object should be able to get at it's data - i.e. no direct access to data - only via methods. Please see Daniel Shiffman's Coding Train playlist on "Topics of JavaScript/ES6-ES8", especially the videos on Classes in JavaScript with ES6 and Inheritance in JavaScript. FYI ES6 and ES8 are just acronyms for new versions of JavaScript. All the numberings are confusing, don't worry.
How to add other libraries of JavaScript code to your p5.js projects, and some of the most interesting ones I've used in my work.
p5.js has many libraries, some core and some contributed. Let's take a look at them. But first, what is a software library?
One thing to realise is that p5.js is a library itself!
Allison Parrish has posted a great tutorial on how to use external JavaScript libraries with p5.js, let's go through it together and get it going in the p5.js editor.
Do you remember that falling logo I showed you in a previous lecture? Let's take a look at how it includes other libraries apart from p5.js - p5.gui and matter.js. Making GUI's for your sketches is a great idea because you can use that GUI to quickly tweak settings and the like - to explore the "possibility space" of your code. I love using physics simulations to animate with because I'm too lazy to do keyframe animation.
Any programmer will tell you that dealing with date and time and timezones is a nightmare - I've used moment.js several times in my projects, particuarly to generate nice filenames.
Let's finish with a quick tour through some other JavaScript libraries that might be useful.
Thanks!
Back to slide index.