We review a theory of freezing based on the density-functional approach andcompare a variety of its versions. The application of the theory to the freezing of various simple and complex fluids is discussed. The theory has demonstrated that classical fluids freeze when they are strongly correlated, as evidenced by the pair correlation function. In the freezing of quantum fluids, the self-correlation function is found to play an important role. Some of the transitions discussed in this article are sensitive to the form of the direct correlation functions of the co-existing or effective liquid, which is used as input information in the theory. The need for knowing these correlations accurately, particularly in the case of molecular fluids, is emphasized. The application of the density-functional formulation to the general situation where the density is neither uniform, as in a liquid, nor periodic, as in the crystal, is discussed. The problems discussed are the solid-melt interface, nucleation of a solid in a supercoo melt and dislocations. The importance of the density-functional in describing properties of crystals and liquid crystals including elasticity, flexoelectricity, surface layering and wetting transitions have been shown. The application of the theory to the description of isotropic liquid-glass and isotropic liquid-icosahedral crystal is also given.