RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Question about RunUO source...

Status
Not open for further replies.

Viago

Knight
beacuse posting a sig without being a paid member is a rules violation, some have been banned for it. i sujest not being incompetant and comply
 

Courageous

Wanderer
Viago said:
beacuse posting a sig without being a paid member is a rules violation, some have been banned for it. i sujest not being incompetant and comply

Except I disagree (as do others, including a prominent web site or two) that this is a sig:

C//
 

Viago

Knight
leme clarafy some terms of what a sig is

a sig is used to end or be seperate from the post, meening after you are dont posting your text, the sig acts as a SIGNATURE. leme claify this. the seperation details that the context of the matter is seperate from the subject matter or acts as an identification. For example if i wer to post at the end of the post PEACe, viago. this is allowd because it is closing the the post, but not seperate from the post. If i wer to put at end of the post C//. since it is not pertaining to the subject matter, and more of a meens of identity, then it is a signature.
 

HellRazor

Knight
I can't believe some of the things people get wrapped around the axle about.

Half of the subscribers here don't even have access to the subscribers forum right now. Ryan has said that subscriptions are officially not working or desired right now until he gets them revamped. And we're going to have a fit over a 3 characters at the end of a post?

I think the moderators can make the call on what is allowed and what isn't.
 

TMSTKSBK

Lord
Yah...CEO says it best

Not Mod? Don't moderate. (<-- I'm as guilty as anyone else.)

So. Blah.


(edit -- whoa, holy crap, my sig is back :confused:)
 

A_Li_N

Knight
Courageous said:
To me a "magic number" is a hard coded number, directly in a file. These are to be avoided.
So, after reading through the 46 posts, here are my questions/opinions.
C, you say that having hard coded numbers is a bad thing, yet you pose the idea that making static 'named' int variables is a better idea. How, may I ask, is making an int variable that references another int variable any better? If your answer is because it is easy to change, then you should know that the cloc files are also easy to change.
You say that this idea is good because it gives 'meaning' to these 'magic numbers'.
Your example is this: Caster.SendLocalizedMessage( 500237 ); // Target can not be seen.
And you pose the example of the fix to be something like this: Caster.SendLocalizedMessage( TARGET_CANNOT_BE_SEEN );
This is but one example of the strings represented in the cloc files. The strings are not all that short and simple. Some of them are full conversations used for quests. How would you represent a full conversation in a 'named variable'? You couldn't make a variable name that encompases the entire string. And, since you couldn't, the scriptor would still have to look through the cloc files to find exactly what it says.

Even with a 'non-localized'/non 'magic number' database referencing 'magic numbers' with 'named variables', the scriptors would still have to look through to find what entry they want to use.

I've gone through a lot of code in the core and other distro files and it is probably 90% documented on what the 'magic number' is referencing. If it's not commented, it takes a whole 30 seconds to load the cloc viewer up and enter the number into the search to find what it means.

Courageous said:
If a cliloc code can be changed at any time, the very best strategy one can possibly have is a central location to adjust that in the event the change happens. This is one of the major advantages of a definitions file.
The definitions file already exists. It's called a cloc file and it's provided with each and every install of UO. What if 500237 got changed to 'Target can't be seen'? Would you simply change the reference number in that centralized location and not worry about the variable name? If you're naming the variables for better 'readability' with 'TARGET_CANNOT_BE_SEEN', then you would need to change the variable name to TARGET_CANT_BE_SEEN' to keep true to your rules. You would then need to rename all the refrences to that variable.

Another reason not to do this is the simple matter that doing it would use (waste) resources. You would have 'however many cloc entries there are' ints that would need to be held in memory. It would also have to then do another step to get to the same place. If 'a' goes to 'c', why throw in another step that says 'b = a' so use 'a' when you see 'b'?

Anyway, to sumerize in one word...useless. That's my take on this idea. Although you do bring a good debate :) (Notice I claim it as a debate and not an argument) Debates are informed arguments, and you seem to be well enough enformed.
 

Phantom

Knight
Lets not forget, every variable goes to the Stack\Heap, there are ALOT of clilic messages.

You would notice a HUGE performance decrease due to this fact, I don't even think modern computers could handle thousands upon thousands of static variabls within the Heap.

If you don't think it will make a difference, test your theory out, also the best reason why this idea sucks is the following.

You would have to do it by hand....
 

Courageous

Wanderer
Phantom said:
You would notice a HUGE performance decrease due to this fact, ...

As a software engineer with a good 15 years of performance engineering under my belt, I totally disagree.

C//
 

Phantom

Knight
Courageous said:
As a software engineer with a good 15 years of performance engineering under my belt, I totally disagree.

C//

Your saying having 5k+ variables in the HEAP, would not have a performance loss at all?
 

Phantom

Knight
Courageous said:
No, I don't believe so. Not observably.

C//

You would agree, that having that many variables Heap can't be good, lets not forget every perforance decrease can effect a shard in alot of ways.

You have 1500 scripts to compile, hundreds of additional static variables, and then there is the potential for millions of additional stacks because of the local variables on Items, Mobiles, ect.

Every bit of memory used, means more that has to be moved around, which means some performance will be lost.

I really dislike when people bring in professional programming into the picture dealing with RunUO. The simple fact is RunUO is unquie and the programming style is different, so not everything in the professional field applies to RunUO.
 

Courageous

Wanderer
Phantom said:
You would agree, that having that many variables Heap can't be good.

I would not agree. There is a reason that Djikstra quipped "Premature optimization is the root of all evil in programming".

C# puts static variables into the high frequency heap. This will more than satisfy. In addition, any frequent accesses to these numbers will be entirely covered by your L2 cache--you won't notice a thing.

Your belief that RunUO is somehow special this way is... strange.

To be fair: the first mantra of performance analysis is that the performance analyzer decides all (including which problems ought to be optimized). So in that sense, we're both wrong.

C//
 

Phantom

Knight
Courageous said:
I would not agree. There is a reason that Djikstra quipped "Premature optimization is the root of all evil in programming".

C# puts static variables into the high frequency heap. This will more than satisfy. In addition, any frequent accesses to these numbers will be entirely covered by your L2 cache--you won't notice a thing.

Your belief that RunUO is somehow special this way is... strange.

To be fair: the first mantra of performance analysis is that the performance analyzer decides all (including which problems ought to be optimized). So in that sense, we're both wrong.

C//

I will be honst I am not familar where C# places variables, I was using what I learned about C, to point out possible issues. If performance really isn't an issue in this case, yes I suppose I was wrong, but I disagree that doing your suggeston is a good idea.

The reason RunUO is special is because, over the years I have seen alot of people who know programmng, argue points and write buggy scripts to be used with RunUO.

Anyways RunUO has its own way of working, its different and of course just a program, but you have to understand it to work with it. I am sure you have found that working with the AI, that RunUO is not like any other program, thats why its so great.

All I know is I have seen countless "programmers" write horrible scripts, because they didn't understand RunUO and how it works with the client. If thats not the case for you, then well again I am wrong, but I still think using variables to handle something done by the client shouldn't be done.

If you wanted to just have a html file that was based on your suggestion, then I would agree thats a good idea, but to use variables on something like this just doesn't make sense.
 

Courageous

Wanderer
Anyways RunUO has its own way of working, its different and of course just a program, but you have to understand it to work with it. I am sure you have found that working with the AI, that RunUO is not like any other program, thats why its so great.

Now you and I do agree. :)

It's quite easy for a software person, no matter how good, to gloriously screw up something that he doesn't understand.

The variables issue is simply connected with "magic numbers". To learn more, read about them. They are a way of auto-documented numeric codes, so that other people understand them. Nothing more, nothing less. There main real purpose is for humans. They do have one additional and important functionality. If you mis-type a number, the current system may accept it. If you mis-type a constant's name, there's a very high chance it won't COMPILE.

Granted, I'm not offering to make this change, and really not pressing for anyone to make this change either. What I'm doing is being very persnickety about a style in the code.

This shouldn't be taken out of context: I find RunUO to be very well coded, generally. And being that I am a professional, and have had years of experience doing things like 4-man code reviews (!), this is a complement.

C//
 

Phantom

Knight
Courageous said:
Now you and I do agree. :)

It's quite easy for a software person, no matter how good, to gloriously screw up something that he doesn't understand.

The variables issue is simply connected with "magic numbers". To learn more, read about them. They are a way of auto-documented numeric codes, so that other people understand them. Nothing more, nothing less. There main real purpose is for humans. They do have one additional and important functionality. If you mis-type a number, the current system may accept it. If you mis-type a constant's name, there's a very high chance it won't COMPILE.

Granted, I'm not offering to make this change, and really not pressing for anyone to make this change either. What I'm doing is being very persnickety about a style in the code.

This shouldn't be taken out of context: I find RunUO to be very well coded, generally. And being that I am a professional, and have had years of experience doing things like 4-man code reviews (!), this is a complement.

C//

All I can say is, there are so many things that could be changed, that would make even more user friendly then this suggestion.

I will admit I don't know the term "magic numbers", but I am still going to disagree that this suggestion would make anything easier. Like other have said, there are some very long messages within the clilic, which would make it hard to make a variable for.

In the end you still would have to look up the message, to know what to use, so I don't see the difference. Given that fact, again I feel there is alot that could change that would make RunUO more user friendly and this I don't believe is one of them.
 
Status
Not open for further replies.
Top