HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

UserData library needs feedback

10-24-2008, 07:16 PM#1
Themis
I've created this library to globally improve speed and readability.
Personally I think its almost done, but before I release it into the public I'd like some feedback of the pro's.

This library was first build to use variables instead of natives which almost any time return the same value.
However, after using this sometime I've modified it and it now holds data which can be used in almost any type of script.
Making extensions to this library is pretty easy, However I did not make it so it does anything more then just being a "userdata" library.
Making things for example "changing a player name or "hold SetPlayerColor" into account is something rather easy to make.

I've made an example script on how to use this script, just look how easy it is to create an advanced script without having to worry about anything about player id's and variable names, etc..
The example code is just a tiny fraction of what this system can do.

Anyways, tell me what you think of it, what can perhaps be improved, bugs.. etc.


Userdata Library
Expand JASS:

HandleVars Library ( Required by the UserData Library )
Expand JASS:

Example Script ( For the UserData library )
Expand JASS:
10-24-2008, 07:43 PM#2
Rising_Dusk
I2H is long considered an unsafe practice in coding. You should make it your first prerogative to eliminate it from your coding practices and code.
10-24-2008, 08:01 PM#3
Themis
Quote:
Originally Posted by Rising_Dusk
I2H is long considered an unsafe practice in coding. You should make it your first prerogative to eliminate it from your coding practices and code.

I don't use the HandleVars library for that, notice that the textmacro's for I2H aren't runned.
I use the library mainly for the type2type macro, in this case H2I.
However, I added extensions to it so if for any reason whatsover i need those functions I can enable it easily without having to create 2 functions.

I see many scripts with a private H2I function, I think its rather idiotic to do that.
It just takes 4 extra lines of coding for no reason, perhaps a few bytes but you can't host maps with a higher size of 4mbs, in that case those few bytes do help.
10-24-2008, 09:44 PM#4
Rising_Dusk
Quote:
Originally Posted by Themis
I see many scripts with a private H2I function, I think its rather idiotic to do that.
It just takes 4 extra lines of coding for no reason, perhaps a few bytes but you can't host maps with a higher size of 4mbs, in that case those few bytes do help.
This is why Vexorian will (hopefully) one day add a built in H2I into vJass. Still, though, it's much better to have a 4-line H2I as a required library than a hundred-line long library that's used for only one minuscule feature from it. The only real merit to your claim is the point on initializing game caches, since you can technically run out of those. That's an unreasonable upper limit to hit, though, so it's almost a moot point altogether anyways.

Also, that find host function can be really unreliable if the host lags when the game loads or if the map is hosted via a third party program (as many of the things on BNet these days are).
10-24-2008, 10:18 PM#5
Themis
So perhaps add an option to either use findHost or have default player assigned to the host.
And when the host leaves, a new host is assigned.

However, adding the option to update the host when the game is fully loaded could be an improvement aswell.
Anyways, even with third party programs the host still should respond the fastest.
10-25-2008, 10:45 PM#6
Rising_Dusk
Quote:
Originally Posted by Themis
However, adding the option to update the host when the game is fully loaded could be an improvement aswell.
Anyways, even with third party programs the host still should respond the fastest.
This is not true at all. Most 3rd party hosting programs, if not all, make the game function for each player as if it's hosted locally for each, very much unlike standard BNet. This would make it fairly random who the GetHost function returned in such a case. Additionally, syncing is even less reliable at a point later than map initialization, since God knows what can happen to slow up a connection mid-game.

It's a tricky problem to create a solution for, since all solutions are very inelegant and unpredictable.
10-26-2008, 07:10 AM#7
dead_or_alivex
Smart method, using the indices of the struct created as player numbers. Quite nice.

And yeah, I think you should use a private H2I. That way, your system wouldn't require external systems (especially outdated ones). A 4-lines snippet of code is definitely worth the portability IMO.
10-26-2008, 05:21 PM#8
Themis
I actually think its fine the way it is, I'd prefer to think h2i, s2i, i2s, etc.. are a native.
This is currently either achieve able by creating those functions in the map header, or by creating a library out of them that is required by others.

However, I need a initialized game cache for the findHost method and i need a h2i function.
Updating the findHost method so that it not uses a gamecache system is rather inefficient because I can either create a global for it, or use a local for it.
Extra lines of code only because you guys think HandleVars is outdated and refuse to use it.
As I see it, you guys treat HandleVars as a fad and because there is something new doesn't mean that a system like that can be thrown out the window.

HandleVars is an exention to Jass, just as vJass is.
Perhaps there are better and faster ways to do things now, but duplicating 1 function each time a library requires it is just fundamental bullshit.

I have created a few extensions for example a recycle textmacro library

Creating all 3 library's + the one of the user data library is a total of 4 requests for the h2i function, which is a total 4 x 4 = 16 additional lines of code.
And throughout my library's I need a private function about 12 times created if I listen to you.
12 x 4 = 48 lines of additional bullshit code.
Not to mention a few s2i and i2s functions.

I created the HandleVars library for reasons
- 1 time a GameCache initialization so never would it exceed a 265 creation limit.
- Add a function ( such as h2i ) by just running 1 text macro.
- When text macro's aren't executed, no function is created.
- So I never have to create h2i and other functions of the return bug.
- Unused functions are removed by the optimizer.

Lets say you work for a company that creates programs or games, And you come with things like this you guys get fired right away.
This is not the way to program, duplicates of functions wth.

This is what makes me an individual, unlike you guys.
I think this HandleVars library should be a mandatory library for scripts that use the return bug.

As Rising_Dusk said that perhaps someday Vexorian will auto make those functions to vJass should be a great improvement, however I still need an initialized game cache which is another reason of the use of the HandleVars library.
10-26-2008, 06:44 PM#9
dead_or_alivex


Firstly, that thing about the number of extra lines is just illogical.

Going with your argument, I should import the entire Caster System because I want CS_H2I() and CS_SafeX() and a few other functions? That just defeats the purpose of modularity and portability, the latter being one of the paradigms vJass was built on (Vex said something like that IIRC).

Quote:
Perhaps there are better and faster ways to do things now...
You avoided this point. If there are better ways... why not use them, in the name of progress? Why use admittedly inferior ways?

Quote:
This is what makes me an individual, unlike you guys.
Huh?

Well, I guess it does, but not necessarily in a good way.

I don't really want to argue with you, so, use whichever method you feel more comfortable with.
10-26-2008, 07:14 PM#10
the-thingy
Collapse JASS:
    // runtextmacro HandleVars( "Integer", "integer" )
    // runtextmacro HandleVars( "Real", "real" )
    // runtextmacro HandleVars( "Boolean", "boolean" )
    // runtextmacro HandleVars( "String", "string" )
    
    // runtextmacro HandleVarsEx( "Handle", "handle" )
    // runtextmacro HandleVarsEx( "Unit", "unit" )
    // runtextmacro HandleVarsEx( "Timer", "timer" )
    // runtextmacro HandleVarsEx( "Trigger", "trigger" )
    // runtextmacro HandleVarsEx( "Effect", "effect" )
    // runtextmacro HandleVarsEx( "Group", "group" )
    // runtextmacro HandleVarsEx( "Lightning", "lightning" )
    // runtextmacro HandleVarsEx( "Widget", "widget" )
Shouldn't those be //! (or did you just leave them as comments for the sake of having some random comments :P)

Quote:
duplicates of functions wth.
Well, since there isn't a native H2I function, people have no other choice than to create their own if they require a H2I function, but want to separate themselves from another system. Why should I have to import another system if I don't want to, and when I can just create the H2I function which will take about 15 seconds.
It's not going to break the map in any way to have a duplicate of the function, and it's far more convienient, it can reduce importing requirements (which import two libraries, one of which is only required for a single function, when I can just import one?), and I doubt anyone, at this stage, could be arsed recoding their system, adding extra stuff which isn't even needed, just to replace something they already had...

If everyone could work together simultaneously, there probably would be only one H2I function per map, but sadly, something like that is probably never going to happen.

I don't know the exact length of the Handle Vars code, but it's just an example figure to make the point

Quote:
however I still need an initialized game cache which is another reason of the use of the HandleVars library.
Couldn't that have been done within the UserData library?
10-26-2008, 07:26 PM#11
Themis
Quote:
Firstly, that thing about the number of extra lines is just illogical.
I think its rather Illogical to duplicate functions.

Quote:
Going with your argument, I should import the entire Caster System because I want CS_H2I() and CS_SafeX() and a few other functions?
Handle Vars is not an "entire system", its a simple library that exists of a few functions to let people use the Game Cache and the return bug functions with ease.

Quote:
That just defeats the purpose of modularity and portability, the latter being one of the paradigms vJass was built on (Vex said something like that IIRC).
Perhaps adding those functions would give it more "portability".
There is no doubt that Vexorian is a great programmer, but when Vexorian says Its good to inject yourself with HIV, would you take his advise blindly and do it yourself too?
Everybody has its own way of programming, so does Vexorian.
If Vexorian likes to create duplicates of functions, let him. It doesn't mean you have to do it as well.

Quote:
You avoided this point. If there are better ways... why not use them, in the name of progress? Why use admittedly inferior ways?
I was merely talking about I2H, which is supported by the system however not activated.

Quote:
Huh? Well, I guess it does, but not necessarily in a good way.
I think that it would be a matter of perspective.

Quote:
I don't really want to argue with you, so, use whichever method you feel more comfortable with.
Neither do I, but you're not the first who says ( or is gonna say ) "I think you should use a private H2I"
It just pisses me off that people say that without giving me a good reason enough why not to do it.
I made a Read Me scope, said what HandleVars is and why it is required for.
If you plan on using this, you can make up your own mind of rather to customize the library or not.
I totally agree on your statement "use whichever method you feel more comfortable with".
But if you say that I need to use private I2H functions your just kindly saying to me that I do it wrong and that your way is the way to program it right.


Quote:
Shouldn't those be //! (or did you just leave them as comments for the sake of having some random comments :P)
I2H are slower then the structs now a days, I avoid the use of them but if for any reason I need it a simple "!" enables the functions.

Quote:
If everyone could work together simultaneously, there probably would be only one H2I function per map, but sadly, something like that is probably never going to happen.
And that is what I'm aiming for. Every single 1 of my library's and systems just does and what it says it is.
For example if I created a "Caster System" it would only hold methods and structs that has to do with "casters".
Functions like cs_h2i and cs_safex has nothing to do with that, its a manner of conversion which was used and called in the past in "handlevars" system.
10-26-2008, 07:51 PM#12
Troll-Brain
Sorry for off_topic but "wth" means "what the hell" ?
10-26-2008, 11:52 PM#13
Pyrogasm
Yes.
10-27-2008, 04:25 AM#14
dead_or_alivex
A lot of your arguments are just fallacious, and don't make any sense.

Quote:
Originally Posted by Themis
I think its rather Illogical to duplicate functions.
No, I don't think you understand. The whole thing about the number of lines is nonsense. No opinions there, because that's not what happens.

Quote:
Handle Vars is not an "entire system", its a simple library that exists of a few functions to let people use the Game Cache and the return bug functions with ease.
CS is also a simple library that exists (sic.) of a few functions to let people make spells with ease. I don't get the distinction between an "entire system" and a "simple library". CS is made up of useful functions, just like Handle Vars is; it's just that CS is more bulky. According to your argument, it would be worth importing CS for those few useful functions, no?

If you're concerned with the bulk of an imported system, you're only supporting my point that you should duplicate needed functions, and undermining your own.

Quote:
Perhaps adding those functions would give it more "portability".
There is no doubt that Vexorian is a great programmer, but when Vexorian says Its good to inject yourself with HIV, would you take his advise blindly and do it yourself too?
Again, point not addressed. And, no, just for the record, I do what Vexorian does because I think his opinion is sound, and I agree with the modular concept. I don't do it based on some misguided opinion of my own that I am a superior individual because of my habits.

Quote:
Neither do I, but you're not the first who says ( or is gonna say ) "I think you should use a private H2I"
It just pisses me off that people say that without giving me a good reason enough why not to do it.
Rising and the-thingy said it. I concurred with them. And, go read my post again; perhaps you missed this. I did justify my opinion.

Quote:
Originally Posted by Me
And yeah, I think you should use a private H2I. That way, your system wouldn't require external systems (especially outdated ones). A 4-lines snippet of code is definitely worth the portability IMO.
Quote:
But if you say that I need to use private I2H functions your just kindly saying to me that I do it wrong and that your way is the way to program it right.
That's exactly what I'm doing. You posted this library for feedback, and I gave a supported opinion of my own.

Quote:
And that is what I'm aiming for. Every single 1 of my library's and systems just does and what it says it is.
For example if I created a "Caster System" it would only hold methods and structs that has to do with "casters".
Functions like cs_h2i and cs_safex has nothing to do with that, its a manner of conversion which was used and called in the past in "handlevars" system.
Yes, I'm sure that's a good way of doing things, but in an ideal world, maybe. Obviously, we would all wish for everyone to follow a certain standard of development, and conform to the same good habits. That's hard to achieve, however, and everyone (people who make systems, in particular) thus has to make allowances for the habits and needs of others. You can't demand that everyone use your mass of interdependent systems, or anyone else's, for that matter.
10-27-2008, 05:26 AM#15
Jazradel
Vex really should implement something like:
Quote:
unique function H2I takes nothing returns nothing
endfunction
Which would only result in a single H2I function existing. That would stop people complaining about duplicating code.

I agree with dead_or_alivex, you should be including H2I.