PlausiblyDamp
Administrator
1. I tend to avoid commenting what a variable is i.e.
I would tend to give a more descriptive name to the variable
2. No real opinion, I tend to use regions to group related functions / interfaces etc rather than individual methods.
3 + 4. Personally I tend to avoid hungarian naming as a decent compiler / editor will give you the type information and detect and mismatches for you. If you code data type information into a variable that is just another thing that needs to be kept in sync with the code - the number of times I've seen VB code (mainly VB6 but the idea is the same) where variables declared like iOrderNumber weren't integers but longs - they were probably an integer originally but the declaration got updated to a new data type and the variable was never renamed for fear of breaking the code...
If the variables have a meaningful name regardless of length then I'm happy.
I personally would have written the above class definition similar to
I did have to guess at some of the variable usage but you should get the general idea, I would also have tended to wrap the variables inside properties rather than leaving them public but that's another issue entirely.
C#:
public static Device dxDevice1 = null; //Draws on pnl_map
2. No real opinion, I tend to use regions to group related functions / interfaces etc rather than individual methods.
3 + 4. Personally I tend to avoid hungarian naming as a decent compiler / editor will give you the type information and detect and mismatches for you. If you code data type information into a variable that is just another thing that needs to be kept in sync with the code - the number of times I've seen VB code (mainly VB6 but the idea is the same) where variables declared like iOrderNumber weren't integers but longs - they were probably an integer originally but the declaration got updated to a new data type and the variable was never renamed for fear of breaking the code...
If the variables have a meaningful name regardless of length then I'm happy.
I personally would have written the above class definition similar to
C#:
public class Engine
{
public static Device MapPanelDevice = null;
public static Device SelectedPanelDevice = null;
public static Device GraphicsPanelDevice = null;
public static Texture tempTexture;
public static string LayerText = "BOTTOM LAYER"; //Default layer text to be shown
public static object TextColour = Color.FromArgb(0,255,0);
public static object TextShadowColour= Color.Black;
public const int DefaultScreenWidth = 1024;
public const int DefaultScreenHeight = 768;
//would use a point
public Point SelectedTilePosition;
//rather than two variables
//public static int iGMapXPos = 0; //Stores the X pos of the current selected tile in the Graphics panel
//public static int iGMapYPos = 0; //Stores the y pos of the current selected tile in the Graphics panel
//not sure of the following line so I left it alone
public static string[,] sArrGraphicsPanel = new string[1000,1000];
//private Texture spriteTexture;
//not sure of the following line so left it alone
public static Texture texDX2;
public static Texture[] DeleteTile= new Texture[5];
public static Texture[] RegisterTile = new Texture[5];