Classes, Instances and Objects

There’s a fun “theoretical question” on the forums.

What is the relationship between a class, object, and instance?

Lets see if I can help any (or maybe just confuse the heck out of folks even more)

In Xojo in the IDE when you define a CLASS you are creating a “template” for how every item of this type will behave. You’re defining the properties, the methods, events etc etc etc. And EVERY item that IsA <this type I defined> returns true for IsA one of these.

AT runtime when you application runs and it uses the NEW operator to create a new item of this type you are creating new INSTANCES. Instances are the ACTUAL copies you create that you can manipulate at runtime.

And EVERY instance in Xojo IsA Object. Its the base object for EVERY dynamically created type where you use NEW to create one.

So CLASSES are a design time thing.

INSTANCES and OBJECTS are runtime things.

3 Replies to “Classes, Instances and Objects”

  1. In my head, this is pretty much what I’ve always understood to be the relevance and differences between them. And I was thinking of responding to that same forum thread as well – but you said it better than I could.

    Thank you.

  2. The ONE thing you wont find anywhere is Xojo is something like

    Class Foo
    Inherits Object
    End Class

    as this is always implied whenever a class does NOT have an explicitly stated superclass

    Just FYI

Comments are closed.