||We show that flat bands can be categorized into two distinct classes, that is, singular and nonsingular flat bands, by exploiting the singular behavior of their Bloch wave functions in momentum space. In the case of a singular flat band, its Bloch wave function possesses irremovable discontinuities generated by the band crossing with other bands. This singularity precludes the compact localized states from forming a complete set spanning the flat band. Once the degeneracy at the band crossing point is lifted, the singular flat band becomes dispersive and can acquire a finite Chern number in general, suggesting a new route for obtaining a nearly flat Chern band. On the other hand, the Bloch wave function of a non-singular flat band has no singularity, and thus it can be completely isolated from other bands while preserving the perfect flatness. All one dimensional flat bands belong to the non-singular class. We show that a singular flat band displays a novel bulk-boundary correspondence such that the presence of the robust boundary mode is guaranteed by the singularity of the Bloch wave function. Moreover, we develop a general scheme to construct a flat band model Hamiltonian in which one can freely design its singular or non-singular nature. Finally, we propose a general formula for the compact localized state spanning the flat band, which can be easily implemented in numerics and offer a basis set useful in analyzing correlation effects in flat bands.