What is better?

0zaru

Learning vJASS ;)
Reaction score
60
I want to know something about vjass:

First, what is better ? One struct that has a lot of data inside or differents struct with partial data in?

For example:

JASS:

scope <somename>

private struct BlastData
unit Blast
real currdist
timer Move
trigger DetectUnits

//all methods etc..
endstruct

private struct vortexData
unit vortex
timer absorb
trigger destroy

//methods etc

endstruct

//all functions etc
endscope


Well basically is part of my spell, when a small blast of ice makes contact with an enemy unit is explodes in a vortex, so I made 2 datas, one used when move the blast and another to make the vortex. Would be better to use one struct only ?
 

Tinki3

Special Member
Reaction score
418
> Would be better to use one struct only ?

Well, IMO, it depends on how you want to use the data in a struct.

Say you want to make a spell where a target-unit is knocked-back, and
then after it travels some distance, it explodes, knocking other enemies
inside a small area backwards from the point where the target landed.

I would personally use 2 structs - 1 for knocking the target back,
and 1 for dealing with the multiple knocking-backing of the other enemies.

Like I said, depends on how you want to use the struct(s).
In your case, it would be "easier" to use 2.
 

The_Kingpin

Member (Who are you and why should I care?)
Reaction score
41
Well, I find it easier to create structs for specific purposes. If I made that, I would probably make one struct to control the blast and another to control vortexes. When the spell is cast, create a new instance of the blast struct, and then for every unit it touches, create vortex structs.
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
Moreover, you may use the extend syntax to extend your struct.
 

Vexorian

Why no custom sig?
Reaction score
187
I want to know something about vjass:

First, what is better ? One struct that has a lot of data inside or differents struct with partial data in?


You are joining the design pattern discussion, a discussion that's kind of worthless.

Do what feels better to you.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top