A very short overview is that you are comparing two points in time, not one. The event which happens first takes the "perfect" pattern.
Past perfect (had finished, had realised, had done, etc) tells me out of two past events, this happened first. This also means I can mention this event after everything else, and it will still remain the first thing which happened.
Present perfect (have finished, have realised, have done etc) tells me that the past event is relevant to, or affecting, the present time. This is the only perfect tense where you don't need to mention a second event or time - the present time is implied. If you use past simple, you need to indicate when it happened. Also with past simple, the action is finished and no longer affects the present.
Future perfect (will have finished, will have realised, will have done etc) tells me that a future event - which hasn't happened yet - will be completed by the time the second event or time arrives: it will become a past event. Very useful for discussing future plans and deadlines.
I won't go into the perfect continuous forms, but I hope this helps. :)