What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

Coder77

New Member
Joined
Sep 24, 2015
Messages
23
Reaction score
0
After viewing code posted on the forums and exceptions causing complete crashing of plugins and ArcheBuddy completely has lead me to one conclusion. Simply put, where in the **** are all the exception handling? unit testing? try/catch? I just feel like people don't understand the necessity of a few things when coding using .NET C#:

1. Clean and Well Formatted Code with XML Documentation

2. Try/Catch and Exception Handling

3. Use Locks when accessing data and variables your threads share. (Parallel Programming 101: Data Races)

The biggest is the exception handling and try/catch use. You don't have to handle the exception at every level of every function. Simple implement...

Code:
try
{
     // Code Here

}
catch // you don't have to actually specify an exception here, unless you plan on handling a specific exception like IOException, just throw. It helps with the stack trace.
{
      // Log Message
      throw;
}

At the highest levels of your functions, the big guys, you do major exception handling. This is the best way to also try something that you know will cause an exception without crashing your program.

What do you guys think?
 
1. Clean and Well Formatted Code with XML Documentation

2. Try/Catch and Exception Handling

3. Use Locks when accessing data and variables your threads share. (Parallel Programming 101: Data Races)

While I totally agree with points 2 & 3, I personally don't see 1 as a neccessity. It's nice to have well-documented code by others, but I can understand everyone who leaves it to the potential (re-)user of his work to figure out what is actually going on - in free code. After all, I do not expect plugins released by other users (plugins that come with the bot and paid plugins put aside) to be tutorials.

Regards,

p4mdude

p.s.: might elaborate later.
 
Last edited:
I personally don't see 1 as a neccessity. It's nice to have well-documented code by others, but I can understand everyone who leaves it to the potential (re-)user of his work to figure out what is actually going on - in free code. After all, I do not expect plugins released by other users (plugins that come with the bot and paid plugins put aside) to be tutorials.

I can understand how you can see this is not a necessity, but when it comes to writing code, even in free-code, you need to make your code look well formatted still. For example many people like to do if statements without brackets because it's one statement to execute if the IF statement proves true.

Another thing people like to do is use 'var' for every variable. Please stop. If you do this, you need to stop. CLR or Common Language Runtime, has to do extra work every time you use var, and so yes it's "easy" and "convenient", but it makes your code almost unreadable and it's just being lazy in my opinion and causing more overhead.

Documentation is a last step. By leaving it up to the next re-user to understand your code is bad practice, and any expert programmer would tell you the same thing.
 
I can understand how you can see this is not a necessity, but when it comes to writing code, even in free-code, you need to make your code look well formatted still. For example many people like to do if statements without brackets because it's one statement to execute if the IF statement proves true.

Another thing people like to do is use 'var' for every variable. Please stop. If you do this, you need to stop. CLR or Common Language Runtime, has to do extra work every time you use var, and so yes it's "easy" and "convenient", but it makes your code almost unreadable and it's just being lazy in my opinion and causing more overhead.

Documentation is a last step. By leaving it up to the next re-user to understand your code is bad practice, and any expert programmer would tell you the same thing.


Hi, I would say that point 1. is completely a preference, unless you're working on a project that it's intent is to be released to public (speaking of forums), that is simply for an easier understanding of what's going on, could also say soloely for large projects, or when that one is getting lost in it's own code. Other than that, it is really not necessary. (But always nice to see well formatted code)

Regarding this last reply... Using var, does absolutely not slow down anything, not by a ms.
 
Last edited:
Another thing people like to do is use 'var' for every variable. Please stop. If you do this, you need to stop. CLR or Common Language Runtime, has to do extra work every time you use var, and so yes it's "easy" and "convenient", but it makes your code almost unreadable and it's just being lazy in my opinion and causing more overhead.

var is typed (implicit type) in C#.
It just means that the compiler determines and assigns the most appropriate type during build step, not during runtime
 
Hi, I would say that point 1. is completely a preference
Sure, anyone has the right to code spaghetti code, doesn't make them a decent coder. The title of the article was decent coding standards. Not, what is needed and what is not for a program to function. Now, if you never plan on your source code being read by the public, write spaghetti code for all I care, but when people post code on here for plugins, help, etc, I don't even bother to help if it's written without any spaces, and only var. Also, most people are not solo coders their entire programming career; bad habits are very hard to break. Someone in our office is abusing it like crazy and I have to write over 10,000 lines of code because he cannot debug it. Why? Because he used var for everything, so it becomes context clue debugging.

Regarding this last reply... Using var, does absolutely not slow down anything, not by a ms.
After further research into updates to the CLR compiler you are right about JIT run-time performance, However I have found that it does require extra work to compile now because they have updated CIL to be optimized enough to require the same amount of CIL lines of code as if you had declared it with its class name. No run-time performance affected. I appreciate the correction.

Personal opinion, using var outside a completely necessary situation is not decent coding standards. I have searched the internet in looks for an article that supports the use of var every where, and a vast arguments of using it is because its faster to type, and because it's easier to read which the latter "advantage" is highly debatable. Tortoise and the Hare analogy. Sure you can write your code faster, but can you debug it faster? Can you release it faster? Can it be read, understood, and maintained if need be by another programmer of the same caliber?

I write on forums to expand my knowledge and try to share mine with other people. I enjoy being wrong as much as right. I am sorry if this thread seemed like an attack to anyone on their ability to program, that was not the intent or purpose of my thread. I could be the worst programmer on these threads for all I know.
 
Back
Top