• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[vJASS] Your often use API...

Status
Not open for further replies.
according to Maggy, interfaces are not advisable (I think its coz they create a lot of unneeded code + slow)... I used to use them before... basically all they do is provide your structs with replaceable methods (can be replaced by another struct that extends your struct)

if ur familiar with other languages, it's like overwriting the methods of the parent class...

JASS:
interface AI
    method Fire takes nothing returns nothing defaults nothing
endinterface

struct A extends AI
    method Fire takes nothing returns nothing
        call BJDebugMSG("A")
    endmethod
endstruct

struct B extends A
    method Fire takes nothing returns nothing
        call BJDebugMSG("B")
    endmethod
endstruct

struct C extends A
    method Fire takes nothing returns nothing
        call super //I forgot if this is the right syntax
        call BJDebugMSG("C")
    endmethod
endstruct

struct D extends A
endstruct

call A.Fire => returns message A
call B.Fire => returns message B
call C.Fire => returns message A and message C
call D.Fire => returns message A

personally, for API I mostly use struct method calls... I'm more used to it, plus it looks nice [Struct.method]

:)
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
Ok guys, what's your choice of API when making a system:

#1 - Functions only
#2 - Structs with all static methods and variables
#3 - Structs with all methods
#4 - Structs with all method operators
#5 - Structs with mixed methods and operators
#6 - Modules

Doesn't this entirely depend on the system? API should contain everything that's public.
 
Status
Not open for further replies.
Top