It is important to have good fresh coffee to start.
Good quality means farmed and processed with care not speed. Coffee that is Shade Grown at high altitudes mature slower but develop concentrated flavors. The beans should then be profiled and roasted to accentuate all of its inate goodness. So you taste the bean - not the "roaster"
Fresh whole beans should be stored at room temperature in an airtight container out of direct sunlight. To further inhibit oxidation grind immediately before brewing. The proper grind is dictated by the brew method. Brewing is the extraction of solubles from the coffee. The process should take from 2 to 6 minutes. Too coarse a grind causes the water contact time to be too short to yield a flavorfull cup. Too fine makes it over steeped and bitter.
Water - should be clean and odor free, not too hard but not distilled or softened. If the water has too little a mineral content it tastes flat in the cup. The Specialty Coffee Association of America (SCAA) prescribes a water temperature of 195 - 205 degrees F for it to be the best solvent.