A Cyber-physical system (CPS) is a system made of computational components, i.e. cyber elements, and physical elements, that are connected by a communication network. CPSs have become larger, more complicated, more interconnected, and more heterogeneous. In addition, CPSs have inevitably interweaved and integrated with new technologies like Internet of Things, cloud computing, ubiquitous computing, and big data processing. With these new developments, handling complexity has become the key of CPS design. A novel declarative computing model is proposed in our previous paper to unify the design and analysis of both cyber and physical components in CPSs. In this paper, the concepts and principles of the declarative modeling are discussed in details. In addition, declarative computing techniques are depicted for declarative networking and declarative control along with concrete simulation examples.