In the present work, we propose an alternative approach for deriving the free energy formulation of a non-uniform system. Compared with the work of Cahn and Hilliard (1958 J.Chem. Phys.28258-67), our approach provides a more comprehensive explanation for the individual energy contribution in a non-uniform system, including entropy, interaction energy, and internal energy. By employing a fundamental mathematical calculus, we reformulate the local composition within the interface region. Utilizing the reformulated local composition as well as classic thermodynamic principles, we establish formal expressions for entropy, interaction energy, and the internal energy, which are functions of both composition and composition gradients. We obtain a comprehensive free energy expression for a non-uniform system by integrating these energy density formulations. The obtained free energy expression is consistent with the formula type of Cahn and Hilliard and prodives more deeper physical interpretation. Moreover, using the same approach, we derive formulations for elastic energy and electric potential energy in a non-uniform system. However, the proposed approach encounters a limitation in the special case of a non-uniform fluid contacting a solid substrate. Due to the significant difference in the length scales between the solid-fluid and fluid-fluid interfaces, the wall free energy formulation based on the aforementioned concept is unsuitable for this multi-scale system. To address this limitation, we reformulate the wall free energy as a function of the average composition over the solid-fluid interface. Additionally, the previous derivation relies on an artificial treatment of describing the composition variation across the interface by a smooth monotone function, while the true nature of this variation remains unclear. By utilizing the concept of average composition, we circumvent the open question of how the composition varies across the interface region. Our work provides a thorough understanding for the construction of free energy formulations for a non-uniform system in condensed matter physics.