Methods and Shared Methods

What is/are the primary differences(s) between a Method and a Shared Method in Xojo. Why use one over the other? Is it primarily scope-related?

Thx.

Shared methods of classes can be accessed without creating an instance, as opposed to regular methods.

Right. Normal methods might also be called “instance methods” since you need a class instance to use them. Shared Methods are sometimes called “class methods” because they work directly from the class, not an instance.

These are both discussed in the Classes topic of the User Guide: http://developer.xojo.com/userguide/classes

Thank you, Paul and Alex.

I was recently reading through the PDF book created by Brad as well as the User Guide series. Sounds like I missed retaining what I read about in Book 1. Will definitely revisit the topic. I’m trying to educate some fellow developers and sometimes run into questions I’ve not thought about in-depth.

Shared methods belong to the Class, regular methods belong to the Instance. A classic use of Shared methods is for managing the instances of a class as a group. If you use a shared method to allocate new instances and keep track of them, then you can also use shared methods to do things such as “tell me how many instances exist”