- Joined
- Jun 5, 2008
- Messages
- 2,573
So i have an issue which has thrown me into a thinking for far too many times.
I have a system which i had lying around for some time, i decided to start rewriting it.
Now i wanted to keep it modular and to separate the parts of the data structure, data manipulation and data rendering.
And so we come to my problem, i need two variables (a x and y coordinate) to be passable between two libraries only but is inside a global block of one.
Example:
Is there any way without making them non-private or merging the two libraries to pass these 2 variables to library Two for example?
The other thing:
I have several simmilar data structures so i resorted to using an interface extended via structs.
Now in order to have more readability and cleaner code i wanted to implement a static operator:
But as operators aren't allowed in interfaces (or at least i couldn't get them to work) i used the following structure:
So any ideas on a better structure?
I read that stub methods are almost never used, so i would like to hear of a different aproach.
And i hope the usage of the operator is okay in this case.
I have a system which i had lying around for some time, i decided to start rewriting it.
Now i wanted to keep it modular and to separate the parts of the data structure, data manipulation and data rendering.
And so we come to my problem, i need two variables (a x and y coordinate) to be passable between two libraries only but is inside a global block of one.
Example:
JASS:
library One
globals
private constant real x = 10.0
private constant real y = 2.0
endglobals
endlibrary
Is there any way without making them non-private or merging the two libraries to pass these 2 variables to library Two for example?
The other thing:
I have several simmilar data structures so i resorted to using an interface extended via structs.
Now in order to have more readability and cleaner code i wanted to implement a static operator:
JASS:
static method operator [] takes integer i returns thistype
local thistype this = LoadInteger(SomeHashtable, i, someKey)
return this
endmethod
But as operators aren't allowed in interfaces (or at least i couldn't get them to work) i used the following structure:
JASS:
struct a
integer b
integer c
static method operator [] takes integer i returns thistype
local thistype this = LoadInteger(SomeHashtable, i, someKey)
return this
endmethod
stub method firstAction takes nothing returns nothing
endmethod
endstruct
struct one extends a
method firstAction takes nothing returns nothing
set b = 1 //example ofc, not this trivial.
endmethod
endstruct
So any ideas on a better structure?
I read that stub methods are almost never used, so i would like to hear of a different aproach.
And i hope the usage of the operator is okay in this case.