A major unresolved problem of density functional theory is the yet unknown exchange-correlation functional, which leads to a proliferation of its less or more successful approximations. A practical implementation of these numerous functionals can present a substantial challenge particularly if the higher order functional derivatives are required. We present a systematic method of functional implementation. The method allows a clean handling of a large number of functionals in a mutually independent way. We developed an extensive set of automatic test routines to facilitate functional and derivative testing with respect to the implementation correctness and numerical stability. An integral part of the presented solution is a program for automatic code generation from analytical formulas that uses only freely available tools. Code for evaluation of functionals and their first, second, third, and fourth derivatives can be generated, which accelerates the development, implementation, and testing of new functionals.