Programmer Code Guidelines

Been reading lots lately and never actually put into writing how I write my code. First thing first, variety of things and habits what you should keep in the back of mind.

Functions and Methods I’ve been writing functions and methods and never in my mind try to stop between the difference. Here is what I’ve learn about functions

  • Functions should be stateless and only cares about the argument being passed.  Can return a value or just do any work. Mostly use for utility helpers.
  • Methods are usually part of an object. When methods are called it should change a state or depends on the state the object belongs to.

Arguments pass as Copy or Reference When passing an argument to a method or function, should we consider passing a value or a reference? Passing a value means creating a copy of the argument that can increase memory usage, passing a reference avoid this. This is basically useful when passing a resource reference value.

Modularity Write codes in a modular way, this decreases headaches of debugging later on. Making it modular allows for add ons and modules to be added later on. Modularity is separation of functions and logic  in your code. If you can have separate files for each function is ideal.

Naming Convention make sure to adhere to a convention in declaring functions , objects and variables. I have decided to use this convention for general programming, although different conventions works for different  languages. For C# and windows related code, function name starts with capital letter. And private property starts with “_” underscore. For other things I use, “_” underscore for variables and camel casing for functions. Classes starts with capital letter.

Leave a Reply

Your email address will not be published. Required fields are marked *