Ravenwolfe

Member
So, as many of you know, I'm not a professional developer. I am entirely self taught from looking at other scripts, searching on the internet and tinkering with RunUO.

I've gotten to the point that I can understand most of the code, fix bugs, work with git, etc. What I lack is understanding of effecient coding, memory use, etc. This is highlighted evrrytime I read a post by Praxiis, Voxpire, and several others.

My actual skills are in Computer Forensics. However, it would be very beneficial to my work to improve my coding skills. Also, I love UO and want to advance ServUO even further, and can do better with a more complete understanding.

That said, I have been looking at the colleges in my area for formal or online classes. Most of them seem to be general fundamentals or C++

So, I'm looking for advice from those of you that code professionally.

Would the C++ class help my knowledge if I want to code in C#? Are they similar enough? Would the fundamentals class be too basic, or would it give me a better base of understanding? Is there another option to taking a college class? I don't learn well from a book, I need guided hands on.

Thanks!
 
Last edited:
Ravenwolfe your not alone in the subject mate..

I am a fairly capable scripter when it comes to getting done things in C# but when i see some of the things other guys release like Vita Nex Core or Ultima Online i think to myself how the F*** do these guys do this stuff..

I could also use help on this subject to improve my knowledge when it comes to coding for Ultima Online (i don't code for anything else) maybe we could pay Voxpire or praxxis to teach of what it means to be a true programmer lol
 
C# is a viable language, and you guys aren't scripters, you are full blown programmers. There is no difference between UO Scripting and C# programming, the primary difference is that you're working off a base set of classes, instead of building everything from scratch. That being said C++ is faster, primarily because of how close it is to the data layer, but the amount of stuff you have to worry about goes up significantly. Knowledge in C++ wont really help you a lot in C# but it gives you some knowledge on how to do really cool things, like creative use of pass by reference.

I would suggest reading a book or two, and possibly practicing some algorithms in it, but stick to your C# its, higher level, and the stuff that it can't do fast enough, you can easily create in C/C++ and then import into a C# program.
 
Thanks, but call me scripter or programmer, no one with half a brain would pay me to write a program :p

Not that I'm looking to make money with programming, I already do quite well with forensics. However, I would love to be able to write a program from scratch, or create my own UO assistant (I really feel this is going to be a major need soon!), or maybe help code a forensic tool.

I'm attending a weeklong "Python for forensics" training this week, but it makes me really want to learn C# better!

I'll try some books, but I usually do better with a class or online class. I wish they had something local specifically for C#
 
There's nothing wrong with being self taught. Being able to reach out and learn a new skill or language or framework is very important. That being said, I was self taught in turbo pascal (20 years ago, I don't remember any of it) and c++.

The downside to being self taught is that when you learn it formally, you'll recognize a lot of bad habits that you've learned and will have to try to forget them. At least that is what happened to me.

Writing efficiency can be partially language specific, but there are tons of things that are not.

Data Structures is a key class and you really want to take it in a lower level language than c#. That class will teach you a lot about memory efficiency. You'll learn about trees, hash tables, and other ways to structure data. When you come to a language like c#, they may call a structure by something else (e.g. Dictionary), but you'll recognize what it is and when it's appropriate.

Another good one is Algorithms and Complexity. It will help you evaluate the efficiency of algorithms.

I hope that helps. If you have any questions, please let me know. I think you're doing a great job.
 
Last edited:
Also, I almost completely forgot. Take a look at MIT OpenCourseware. They have the lectures for classes that you can watch online. You can pretty much sit through one of their courses in your spare time and do all the assignments if you want. It's also good if you're learning about a specific topic.

Here's their advanced data structures class: http://ocw.mit.edu/courses/electric...d-data-structures-spring-2012/lecture-videos/

This is a higher level data structures class. I'd look for something more basic first.
 
So to sum it up i will never be anywhere near as good as Praxiiz lol.

This only leave me with one option get Praxiiz to work for me
 
I want to put my 2 bits in here. I learned how to code on my own, I think it was Euphoria that I started with. After I went to classes after teaching myself some C, C# and some C++, Java was in there too at some point.

When I was in college I found that for my Asso. they didn't have anything new to teach me and ended up taking classes I should have tested out of.

When I started my next bit for the bachelors I found that is finally started to get more involved with the deep mechanics.

Neways just wanted to put that out there.

But as always there are 10 types of people in the world:
  • Those that read binary
  • Those that do not read binary
 
There are two types of people in the world:
  • Those that can draw conclusions based on incomplete information
 
You guys are a huge help! Besides the valuable information about programming, you gave me a few T-Shirt ideas as well!

I really think the Object Oriented class and especially the Data Structures is what I need. I have trouble wrapping my head around Dictionaries, Hashtables, etc. Also, I have have trouble with the way things are linked in objects. I have been digging into the Customs Framework in ServUO trying to understand how it works but I don't get how the core, modules, and linked mobile thing works. I totally get properties stored on a mobile, but I can't seem to get that properties are stored on something other than a tangible object that I can see in game.
 
This is actually a major help for me too. :) Before An Corp came along, I never even dreamed about computer programming or anything IT related. Now I'm trying to self teach myself (rather poorly at that) and am attending basic programming classes at college. (Currently learning basic html and SQL)

Is it complicated and confusing? Sure is! Everything is like that though starting out. It's funny how your passions and hobbies can influence what sort of skills you develop and learn over time. It's exciting what the future holds.
 
These links are wonderful and going to check them out further.
*MIT still uses chalkboards?

I've been self taught too but using reference scripts and looking through the Script Support section.

Something that really helped was understanding the different Operators and what they mean/do. Otherwise referencing feels like a shot in the dark.
Best reference for those is MSDN http://msdn.microsoft.com/en-us/library/6a71f45d.aspx

Something else that helped is understanding that there's more than one way to write things both in code and the format of your code

going super basic here but it's meant for the general viewer

this
public override int GetAngerSound()
{
return Utility.Random(0x2CE, 2);
}

is the same as this

public override int GetAngerSound() { return Utility.Random(0x2CE, 2); }

and in terms of whitespace
it's the same as this

public override int GetAngerSound()
{


return Utility.Random(0x2CE, 2);


}

and something i just learned while reading O'Reilly's Learning C# book you can have an if statement without braces but only the first line after will be read as part of the if statement.
good to know when modifying scripts
 
and something i just learned while reading O'Reilly's Learning C# book you can have an if statement without braces but only the first line after will be read as part of the if statement.
good to know when modifying scripts

That was something that made Comparing ServUO files with RunUO tough for me, because RunUO uses no brackets to IF statements that have only one condition, and ServUO files have added brackets to every one of those IF statements..
 
That was something that made Comparing ServUO files with RunUO tough for me, because RunUO uses no brackets to IF statements that have only one condition, and ServUO files have added brackets to every one of those IF statements..
Code:
if (a == b)
  Console.WriteLine("A equals B");

is functionally the same as

Code:
if (a == b)
{
  Console.WriteLine("A equals B");
}

The second is better style / form / safer-for-other-developers in my opinion. At some point, if you're using the first method, someone will come in and add some code and forget that the if statement only applies to the single statement.

This is especially true in a community where people are new to programming and the language.

The other place you want braces is in a switch statement.

Code:
switch (age)
{
  case 10:
    int x = 10;
    Console.WriteLine("x is ten");
  break;

  case 12:
    double x = 12.0000000001;
    Console.WriteLine("x is barely over twelve");
  break;
}

Code:
switch (age)
{
  case 10:
  {
    int x = 10;
    Console.WriteLine("x is ten");
  }
  break;

  case 12:
  {
    double x = 12.0000000001;
    Console.WriteLine("x is barely over twelve");
  }
  break;
}

The first example won't even compile. Do you know why?

These are called best practices and vary from one organization to another. Everyone has an opinion about them - usually they are strong opinions that have been formed when you get bit by one of them.
 
Last edited:
One of the most common best practices that is constantly violated is the use of magic numbers.
Magic numbers are numbers that appear in code that really have no meaning just by looking at them.
Everyone has been guilty of this one at some time or another.

For example, look at this code:
Code:
       if (checkMobiles)
       {
         for (int i = 0; i < mobs.Count; ++i)
         {
           Mobile m = mobs[i];

           if (m.Location.m_X == x && m.Location.m_Y == y && (m.AccessLevel == AccessLevel.Player || !m.Hidden))
           {
             if ((m.Z + 16) > z && (z + height) > m.Z)
             {
               return false;
             }
           }
         }
       }

Where did the number 16 come from in m.Z + 16 ?

Better:

Code:
  //defined somewhere at the top of the class
  const int MobileStandardHeight = 16;


       if (checkMobiles)
       {
         for (int i = 0; i < mobs.Count; ++i)
         {
           Mobile m = mobs[i];

           if (m.Location.m_X == x && m.Location.m_Y == y && (m.AccessLevel == AccessLevel.Player || !m.Hidden))
           {
             if ((m.Z + MobileStandardHeight) > z && (z + height) > m.Z)
             {
               return false;
             }
           }
         }
       }

Now perhaps you could infer that 16 is the standard height of a mobile, but the he second example shows the programmer's intent and there is no doubt. If you don't use a const, then at least put a comment near it.

The other thing is usability from a shard owner's / developer's perspective. If you go into spell.cs and want to modify the maximum LMC, it's much easier to do if there is a list of constants at the top of the file and one of them is named MaximumLowerManaCost. Now that particular one may only appear in one spot and it has a comment near it, but what if it appeared in 15 spots? Even with comments, it's a hassle to change that one aspect of the spell system.
 
Last edited:
One of the most common best practices that is constantly violated is the use of magic numbers.

*tries to hide his spellbar script* :)

it has 8 magic numbers


Then there's the holy war between tabs and spaces....
tabs
i can highlight an entire section and press tab (if it's more than one line of code)


That was something that made Comparing ServUO files with RunUO tough for me, because RunUO uses no brackets to IF statements that have only one condition, and ServUO files have added brackets to every one of those IF statements..
agreed
i prefer to always use braces

either
GetAngerSound() { return Utility.Random(0x2CE, 2); }
or
GetAngerSound()
{ return Utility.Random(0x2CE, 2); }


depending on a few things. i like readability but also prefer to consolidate space to make reading/scrolling a little faster
 
I prefer to space my code out so I'll use
Code:
GetAngerSound()
{
return Utility.Random(0x2CE, 2);
}

The reason I tend to format my code this way is to make it easier to read.

I tend to make things that require a lot of distro edits and find this way is easier to identify the changed section.

Not only that is makes the scripts look longer so gives the illusion it was a harder script to make :p
 
The first Switch Statement example leaves the braces out of the Cases which use more than one line. You could do that if it were only one line following the Case, but as that isnt the Case, you need to enclose them in Braces. Sorry, hate to see a question go unanswered (^8
 
In the switch statement without braces, everything is at the same scope, which means you are declaring two variables named x in one scope with different types (int and double).


In the second switch statement example, each case has it's own scope caused by the braces.
 
Ah ok...but even if there weren't variables I thought you needed braces if you did more than one line after the case. I don't know that much about programming to begin with...need to start reading up again. lol
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back