Intentional meaning of programs

Software engineering is a quest for appropriate modeling and abstraction. Writing programs that simulate parts of the real world requires programmers to fill the conceptual gap between the domain knowledge and computer languages. As a consequence of the conceptual distance between the business domain and the general purpose programming languages, clearly identifiable concepts at the domain level are implemented delocalized in the code and interleaved with each other and with a myriad of implementation details. This results in the loss of abstract information in programs. Once the code is written, it needs to be understood and this requires programmers to go the inverse way and to bridge the source code to the domain knowledge that it implements. Without doing this, the programs are meaningless for humans and are merely content interpretable only by machines. The recovery of domain specific information from programs is in the focus of the reverse engineering and program comprehension research efforts. In this dissertation we develop a method for bridging the gap between domain knowledge and programs, by defining explicit mappings between program entities and domain concepts shared within domain ontologies. We call these mappings the intentional interpretation and they define the intentional meaning of a program. We use the intentional meaning to characterize the degree in which programs reflect the domain knowledge along four directions: the coverage of the domain in the code, the level of homomorphism between parts of the modeled domain and the code (distortion of knowledge), the distinguishability of domain concepts at the code level (diffusion of knowledge), and the logical redundancy in the implementation of domain concepts in the code. We investigate the measure in which the mismatches between the programs and the domain knowledge affect different quality attributes of programs such as: the extensibility of programs with new domain concepts, the conciseness and consistency in the implementation of domain concepts in the code and the protection against logical errors. By investigating different implementation strategies of concepts from the IEEE Suggested Upper Merged Ontology in Java programs, we show that many times mismatches originate in the limited conceptualization covered by the Java constructs and thereby they cannot be avoided at all. In order to automate the conceptual analyses, we present a technique for automatic recovery of the intentional meaning based on the similarities between the names of concepts and the program identifiers. We discuss the limitations of the usage of identifiers for recovering the intentional meaning, with focus on their meaningfulness and ambiguity. Further, we investigate possible sources of domain ontologies that contain knowledge suitable for analyzing programs. We develop a method for extracting fragments of domain ontologies by analyzing similarities of domain specific APIs that implement the same domain. We present our experience with extracting fragments of domain ontologies from well-known APIs from Java, C++, .NET, and Smalltalk. Based on several case-studies, we show that a part of the intentional meaning can be automatically recovered, that it is feasible to automate the intentional analyses, and that they are useful for characterizing the conceptual coverage of APIs, the level of logical redundancy, and the level of diffusion. We show examples of mismatches between several domain ontologies fragments and parts of the Java standard API, and present our experience with performing intentional analyses of the Java systems JHotDraw and JEdit.