Services for mobile and pervasive computing should extensively exploit contextual information both to adapt to user needs and to enable autonomic behavior. This raises the problem of how to represent, organize, aggregate, and make available such data to services so as to have it become meaningful and usable knowledge. In this paper, we identify the key software engineering challenges introduced by the need of accessing and exploiting huge amount of heterogeneous contextual information. Following, we survey the relevant proposals in the area of context-aware pervasive computing, data mining and granular computing discussing their potentials and limitations with regard to their adoption in the development of context-aware pervasive services. On these bases, we propose the W4 model for contextual data and show how it can represent a simple yet effective model to enable flexible general-purpose management of contextual knowledge by pervasive services. A summarizing discussion and the iden...