Class Interface add method

Following the example on Xojo Documentation: Animals, Cat and Dog
The class Animal is a class interface with a method: Speak
When creating the classes: Dog, Cat, Bird, etc. they get the Speak method and everything works.

Now, I decide than I need another method: WalkingSound as Text.
Once added to the class interface it not appears on the already created Animal(Dog, Cat, Bird, etc), if I create a new class: Cow, for example, that one yes, it will have the Speak, and WalkingSound methods.

If uncheck from the classes already created the class interface and relocate it, the new method do not appears there. The compiler warns that the class x is missing the WalkingSound method. The question:

Should I add manually to all already created classes the method? Is not a better way?

No, you need to add it manually, or (I think) you can turn off the Interface, then turn it back on so it adds the missing methods.

But think about this: an interface is for otherwise distinct classes that do the same type of thing but are not the same, e.g., a Readable or Writeable. In a lot of cases, you’d be better off with a Superclass/Subclass structure where the Super has the common methods and raises events that the subclasses implement.

turn off the Interface, then turn it back<

Doesn’t work.

Thanks, I’ll try another approach.

It does actually, but you need to click the OK button in between.

  1. Right-click and select Implement Interface
  2. Uncheck the interface in question
  3. Click OK
  4. Right-click and select Implement Interface
  5. Re-check the interface in question
  6. Click OK

The missing methods will be added.

You’re right, must remove interface + OK, then implement again.
In any case, if there are many classes that implement this interface you must go one after one doing this…

You could just go to the items and add the method yourself. It’ll even autocomplete in the method’s name field.

Thanks, I believe the Class Interface is not the right way to do my purpose.
Thanks anyway.