Glass box scalability refers to a way in which a software system can be extended when the source code can be viewed without modification-it is a tradeoff between the black box design (where the extension is built, the original code is not viewed) and the Open box design (the extended code is written directly to the underlying code). Because the new extension is built directly on the original code, but does not change the original code, the glass box design is probably the most effective and safest way to extend a software system. In this part of diagnosing Java code, Eric Allen elaborates on the Glass box extensibility topics discussed last month. After reading this article, you will know when to use the glass box, and will get some tips on how to implement it.
With the increasing diversity of information processing tasks (and associated costs), it is clear that increasing the degree of code reuse is an effective design (and business) strategy in the context of a technical budget crunch. If the scalability of your system is your goal, ask yourself, "How scalable should the system be and how much scalability can I make the system?" Then consider the following facts:
The cost of increasing scalability is a reduction in performance and testability.
The most testable systems are often the simplest; increasing scalability often adds complexity.
The key to developing a successful extensible design plan is to know how you plan to extend the system in the future.
In the 1th article in this series, I outlined the various extensibility forms that the system might exhibit-black box design and two white box designs, namely, glass boxes and open boxes. Next, we will explore these forms in more depth.
We will start our journey with the scalability of the glass box.
Equivalent elements in a glass box
Earlier, I had defined the glass box extensibility as a way for software systems to be extended when the source code could be viewed without being modified. There are two main directions, the program can be in these directions into the glass box can be expanded, they are:
Extension of data
The functional extension of these data
Choosing to allow a program to extend any one dimension along this two-dimensional space will affect the result architecture of the program. In most cases, this decision will also have an impact on performance.
Data as an extensible one-dimensional
Let's first consider the dimension-data, which is most naturally contained in an object-oriented language such as Java. In object-oriented languages, some of the most essential constructs (i.e. class hierarchies, interfaces, and abstract methods) are primarily designed to allow extensibility to be included along the dimension.
To extend a composite data structure to include a new subtype, simply define a new class that is declared to inherit the root of the original composite data structure. For example, consider the following simple class hierarchy for a binary tree:
Listing 1. A simple class hierarchy for binary trees
abstract class Tree {
}
class Branch extends Tree {
private int value;
private Tree left;
private Tree right;
public Branch(int _value, Tree _left, Tree _right) {
this.value = _value;
this.left = _left;
this.right = _right;
}
public Tree getLeft() {
return this.left;
}
public Tree getRight() {
return this.right;
}
public int getValue() {
return this.value;
}
}
class Leaf extends Tree {
}