Beautiful architecture Leading thinkers reveal the hidden beauty in Software Design
-
By
- Diomidis SPINELLIS, Georgios gousios
Http://oreilly.com/catalog/9780596517984
Architecture is part of the system design. It highlights some details and omitting other details through abstraction. The architecture of the software system includes behavior and structure. The External Action description shows how the software interacts with users, other devices, and external devices, that is, the requirement. The structure description shows how the software is divided into multiple parts and the relationship between these parts.
The design of the architecture is constrained by many factors. The architecture is good, bad, and there is no unified standard. This depends on people's needs for the software, the environment where the software is built and run, and the characteristics of the software team. There are many indicators for evaluating the quality of software, such as performance, security, and scalability. In general, these indicators are difficult to fully satisfy, and attempts to improve one of them often have a negative impact on other indicators. So in a sense, software architecture is a compromise game. There is no unique and correct architecture for a set of functional and quality requirements.
The beauty of architecture does not have many empty concepts and discussions, but rather presents multiple practical projects. Through the analysis of the advantages and disadvantages of their architecture and related ideas, it provides readers with useful inspiration. Here I will briefly introduce several examples.
"Chaotic Metropolis" and "design City"
One example is two similar projects with different fate: "chaotic Metropolis" and "City of design ".
The "chaotic Metropolis" came from a very short company. Software delays are intolerable, so software engineers are forced to do their best to deliver quickly.CodeA series of crazy sprints are stacked together, which makes the "chaotic Metropolis" lacks planning from the very beginning, leading to a series of adverse consequences. It is hard to understand the structure confusion, there is no clear hierarchy, and the dependencies between modules are complicated. The Role Definition of components is vague, and the tasks of this component should be implemented in another component; the entire project is completely mixed by the tape, shell script, Perl glue, makefile, and Visual Studio projects.
It is difficult for new users to quickly familiarize themselves with this project, and even the veterans do not know the full view of the entire project. Everyone spent a lot of energy to get a "Structural Diagram", which looks like a London metro diagram, and even a loop:
In the end, the company gave up the "chaotic Metropolis" project and organized a team to rewrite it. Good luck to them ......
Similar to the chaotic metropolis, the city of design is audio software written in C ++. From the very beginning, the project has a clear goal: a specific roadmap for the first product and future features, and the Code must support these features and future changes.
The Team adopted the eXtreme Programming Method and specified many project concerns. For example, Unified File structure, naming rules, and coding conventions. In addition, it took a lot of time to design the core of the system and finally gained a "filter and pipeline" Architecture:
When this book was written, the city of design was still in use and some successful products were expanded. In fact, the code of "City of Design" is not perfect, and there are technical disputes in some places. However, in the clean background, these problems are particularly prominent and will be solved in the future.
GNU Emacs
Another example is GNU Emacs.
Emacs is one of the popular text editors. Emacs was developed in the middle of the 1970s S. It has been around for more than 30 years, but its architecture has not changed. In addition, the features of Emacs are constantly increasing.
Emacs uses interactive applicationsProgram"Model-View-controller" mode is widely used. The model is the underlying description of the data operated by the program. The view shows the data method to the user. The Controller is responsible for implementing the interaction between the user and the view and updating the model.
- In the Emacs model, the buffer zone is a simple string. Each buffer zone has a mode to specify the behavior when editing specific types of text. The buffer also maintains an UNDO log to remember the boundary between user commands; in addition, the buffer zone also provides support for text locating in the buffer zone. Each character in the buffer zone has its own attributes, including how to display and how to handle mouse operations.
- The Emacs view automatically updates the display results and updates only when the user inputs the results. For example, the current web browser uses this method for reference.
- The Controller of Emacs is developed in its own standalone Emacs LISP Language. Almost all Emacs functions are implemented by Emacs lisp. You can compile Emacs LISP programs to expand Emacs functions. In fact, the general Emacs release contains many popular Emacs lisp packages.
As software features grow, user interfaces become complex and programs become difficult to maintain. Evaluate the complexity of a program's user interface. There are two common dimensions: the complexity of the model to be maintained, and the complexity of operating the model command set.
Emacs model, that is, the buffer zone is only a string, and the changes in the buffer zone are always visible. emacs has many commands, but a new user can use Emacs like other basic text editors, emacs also provides many tools for discovering and understanding new features. Emacs is more like a package combinationCommunityIs maintained by many people. The LISP Language plays an important role in abstract boundary.
There are also two similar architectures: Eclipse and Firefox
Eclipse
Eclipse is actually a Development Environment Framework, which does not provide any related functions. Through Java development tools and other types of plug-ins, eclipse can provide a lot of extensive support for software development, which is what Emacs lacks.
Eclipse provides very underlying support for input and display of each plug-in, which allows the plug-in to implement more complex functions, but also brings about the following problems:
Eclipse plug-in development is insecure, and this is exactly what Emacs has. A bug-filled plug-in will crash eclispe. In Emacs, users can terminate such plug-ins and their data will not be damaged.
The structure between Eclipse plug-ins is complicated, which is a challenge for plug-in authors.
The plug-in requires sufficient sample file code. Eclipse has a plug-in Eclipse plug-in development environment that helps you write plug-ins. However, this does not reduce the complexity of the underlying interfaces.
This leads to some thoughts. What interfaces should I use in the plug-in? What abstract level should plug-in developers develop? Is it closer to the problem? What if the protection data is not damaged by bug-filled plug-ins?
Firefox
As a modern browser, Firefox supports JavaScript dynamic page modification, which is similar to lisp and buffer in Emacs. However, Firefox allows its user interface more thoroughly and many built-in functions to be implemented using JavaScript.
This also caused some thinking. In all programs using plug-ins, is the development language of plug-ins the best way to add functions to programs? If not, why?
Feelings
Reference what William J. Mitchell wrote for this bookArticle:
"Good architects do not construct their designs in a casual and vigorous manner, and they will certainly avoid clumsy practices ." "Behind the differences and complexity of beautiful architectural works, you will often find some simple and elegant principles about functional organization and normative order. Discovering these principles requires thinking, and thinking is the key part of building happiness and experience ."
"If you can understand these principles, you can use certain standards.Programming LanguageSeveral lines of code in the same elegance to construct the models of these works; but if you cannot understand these principles, you must write code that is longer and does not contain so many insights ."
"Architects will admire those architectures that use simple and elegant principles to achieve the beauty of a lot of complexity. Similarly, software architects and programmers may admire the beauty of code that clearly and accurately executes many complex tasks. Scientists will admire the beauty of simple rules that describe various phenomena and their interpretation capabilities ."
The beauty of the architecture lies in its concise and profound description and Solution to practical software design problems, whether it is to reduce the trouble for software developers, or its own form of harmony and uniformity, is enough to make people look pleasing to the eye.
By Hao Fu