Macroscopic polarization P and magnetization M are the most fundamental concepts in any phenomenological description of condensed media. They are intensive vector quantities that intuitively carry the meaning of dipole per unit volume. But for many years both P and the orbital term in M evaded even a precise microscopic definition, and severely challenged quantum-mechanical calculations. If one reasons in terms of a finite sample, the electric (magnetic) dipole is affected in an extensive way by charges (currents) at the sample boundary, due to the presence of the unbounded position operator in the dipole definitions. Therefore P and the orbital term in M-phenomenologically known as bulk properties-apparently behave as surface properties; only spin magnetization is problemless. The field has undergone a genuine revolution since the early 1990s. Contrary to a widespread incorrect belief, P has nothing to do with the periodic charge distribution of the polarized crystal: the former is essentially a property of the phase of the electronic wavefunction, while the latter is a property of its modulus. Analogously, the orbital term in M has nothing to do with the periodic current distribution in the magnetized crystal. The modern theory of polarization, based on a Berry phase, started in the early 1990s and is now implemented in most first-principle electronic structure codes. The analogous theory for orbital magnetization started in 2005 and is partly work in progress. In the electrical case, calculations have concerned various phenomena (ferroelectricity, piezoelectricity, and lattice dynamics) in several materials, and are in spectacular agreement with experiments; they have provided thorough understanding of the behaviour of ferroelectric and piezoelectric materials. In the magnetic case the very first calculations are appearing at the time of writing (2010). Here I review both theories on a uniform ground in a density functional theory (DFT) framework, pointing out analogies and differences. Both theories are deeply rooted in geometrical concepts, elucidated in this work. The main formulae for crystalline systems express P and M in terms of Brillouin-zone integrals, discretized for numerical implementation. I also provide the corresponding formulae for disordered systems in a single k-point supercell framework. In the case of P the single-point formula has been widely used in the Car-Parrinello community to evaluate IR spectra.