When docking, keep three things always in mind: the layout of the dock and other boats, the wind, and the current. Neglecting any one of these, even for a moment, is a recipe for disaster. Plan to use the wind and current, rather than fighting it. This implies that you will generally dock by moving into the wind and/or current, not with it. Look for a flag, or the masthead wind vane on a docked boat, to judge wind speed and direction. Look for eddying around pilings to judge current.
Remember, also, that you cannot push on a line. If you are going to hit something, you must attach a line on the opposite side of the boat, where you can pull off from that object, or else deploy a fender.
Lastly but most important, when docking, as at all other times, never put any part of your body between the boat and a solid object, be it a piling, the dock, or another boat.
At a slip, you can either head in or back in. If you back in, it might be easier to board and disembark directly into or from the cockpit, and it will be easier to leave the dock later. Backing in makes the companionway clearly visible from the dock, on the other hand, reducing privacy both in the cockpit and below. Layout of the boat's dock cleats might make it difficult to tie up after backing in. Stern dock lines should cross the transom to the opposite side, and thereby place the tugging load more perpendicular to the cleat, rather than tending to pull it up out of the deck, but this might not be possible if the crossed line will chafe against the transom, rail, or fittings.