Software objects are the de facto programming paradigm for engineering intelligence into modern computer systems. Objects' labyrinth of inheritance, polymorphism, and encapsulated data, intermeshed with ifs, whiles, and for loops, are the basis for flying airplanes, producing health diagnoses, and surfing the Web. Sometimes we escape this rigid paradigm and place the program intelligence elsewhere, such as databases and files. In most cases, knowledge solutions are a hybrid of approaches. Each method has its advantages and disadvantages. An alternative approachgraphsoffers a contrast to these traditional holders of programming intelligence. Graphs have improved significantly with the coming of the Semantic Web, where graphs are a key tenet. In this article, we introduce graphs through a comparison with objects. This approach illustrates some key advantages while stirring up a little controversy. Some would say we should start with comparing graphs to databases and other similar approaches, but this would constrain graphs to a more traditional role. Graphs, as you will see, can help in all areas of knowledge management, including Web 2.0 and beyond.
What do we mean by "programming intelligence" and what are its key attributes? Programming intelligence is not of the sentient, human kind. We mean the intelligence that represents sequences, relationships, algorithms, and the like. As the developer, you must constantly choose between the trade-offs of the various methods, such as programming steps themselves, databases, and files. Here are some key concepts to consider:
- Expressiveness. Represent the degree of complexity captured by the chosen method. Complexity includes types of facts such as numbers and strings, relationships such as inheritance, containership, aggregation, peer, and constraints such as less than 10.
- Integration. This drives the useful expansion of knowledge. Impedance mismatches caused by a different syntax and/or different semantics force you to create cumbersome translation routines or just not integrate at all.
- Resource Use. Programming complex knowledge runs within hardware and hardware has real-world constraints. Resources consist of network bandwidth, processor cycles, memory locations, and/or disk locations. The approach must balance the knowledge requirements with the available resources.
- Scalability. The approach must be able to expand and contract in several dimensions such as size, complexity, and performance.
- Interrogation. The ability to ask the right question and receive the right answer significantly increases the value of the programming intelligence. This extends to answering ad-hoc questions not originally planned.
- Flexibility. Escaping the speciousness of the waterfall process, modern development processes, especially complex, intelligence-based systems, must absorb change throughout many incremental, interactive deployments.
- Integrity. The intelligence must maintain its consistency and correctness. This is especially important as an application moves data around. If there is minimal integrity, many programming steps are repeated to ensure that a float remains a float, a string remains a string, a specific integer never exceeds 100, and so on.
How does Web 2.0 impact these attributes? Web 2.0 represents three significant trends: scale, change, and integration. Web 2.0 has evolved the emphasis on systemsthey must scale rapidly, quickly adapt to new possibilities, and easily integrate with others. Thus to be Web 2.0 enabled, you must carefully consider how your development choices incorporate these Web 2.0 trends. Additionally, the intelligence of your program becomes even more of a key assetyou no longer must do everything from moving data bits to a fancy GUI. If you can incorporate the trends into your solution, many Web 2.0 possibilities are already there for your integration. You can then focus on what you do bestyour smarts.
Now let's examine some code examples that highlight the differences between objects and graphs. The complete code example is available online at SemWebCentral (www.SemWebCentral.org) and from DDJ; see www.ddj.com/code/. We selected a well-understood and completely original programming applicationthe digital marketplace. We also introduce changes as we build out the application. Two complete solutions are presented: object based and graph based. We start with the object based.
The code highlights five major aspects, such as how to:
- Represent knowledge
- Create instances of knowledge
- Integrate knowledge
- Interrogate knowledge
- Change the representation
The better the representation, the better the semantics, but it must be able to work efficiently within the real-world constraints.