a. Rule of 8(2):
required for C, N, O and F
required for all terminal atoms
preferred for all others
b. When there are too many electrons for the rule of 8(2):
Possibility of 10 and 12 for n > 2 
(Do not use with double or triple bonding.)
c. When there are too few electrons to fulfill the rule of 8(2):
Possibility of 6 (electron deficient) for B
d. When there are too few electrons to fulfill the rule of 8(2):
Possibility to use double bonding for C, O, N and S  (rule b and d mutually exclusive.)
e. When there are too few electrons:
Possibility to use triple for C and N (and rarely O.)   (rule c and d mutually exclusive.)
f. Use and designate Resonance Structures.

* Using the d and f electrons is an advanced subject.  It is best reserved for an advanced inorganic course or possibly a quantum mechanical course.