Split a method into sub methods whenever it is getting lengthy. AS a rule of thumb, one should always be able to view the code of each method as a whole on the screen without having to scroll. if it gets longer, split it and give descriptive names to the sub methods.
Aim to write generic submethods, so that they may be reused somewhere else.
Do not rely on global variables (with the exception of mathematical constants). Each method should only need its input arguments for computation.