· Sep 5, 2021

When to Use which kind of Method

Hello Everyone

I am new to cache. I know there are 2 types of methods in cache. One is Instance method (Which can be call through object creation of particular class) and other is Class methods (which can be call through ##Class(MyPackage.Car).CarModels()). 

I want to know the difference when to create a instance method vs when to create a class methods.

Thanks in advance!!.

Product version: IRIS 2021.1
Discussion (3)1
Log in or sign up to continue

Hi Virat,

From what I understand, this is very similar to Static Methods and Instance Methods in Java. Instance methods are the behaviors on a particular object... you can run them only after you create the object with .New(). Class methods, on the other hand, are available without having to create an object first. 

There is probably a more formal answer out there, but I typically use Class Methods when I write a Utility class with lots of methods that do specific tasks and that may need to be available from several entry points to the application. On the other hand, when I design Objects with Properties and Methods, the methods are typically Instance methods.