September 7th, 2022

OOP for GUI

What is object-oriented programming?

It’s a collection of ideas.

  • Encapsulate code and data
  • Abstract data types
    • They hide how they work on the inside
    • “Abstract” = correct behavior, but the inside workings are hidden
  • Overloading
    • Changes how an operator works
    • For example, + on integers vs. strings
  • Inheritance
    • “I want an object just like another, but slightly different” (without copy and pasting)
    • DRY

People came up with objects because they’re a good model for many things in real life.

Java

  • One file per class (unlike C++, which has a header file and body file)
  • It’s an interpreted language
    • Java → Machine code for Java Virtual Machine → Execute code on the Java Virtual Machine
  • Compilation
    • javac Foo.java compiles Foo.class etc files
    • java Foo runs Foo.class’s public static void main method