Git is the father of Linux Linus another masterpiece, the design is too handsome, is worthy of world-class products, let people worship.
There are several features:
Compact and restrained function design
The function design of software system needs to think clearly what can do, at the same time, must think clearly, do not do what.
It is often more important to think clearly about what not to do.
Experienced experts dare to decide what not to do, not reckless, but thoughtful.
After careful consideration of the experience and intuition basis, it is confirmed that there will be no problem with functional implementation, performance, security, concurrency. At the same time, the shortcomings of trade-offs are well known and judged harmless.
layered design, layered protocol refreshing
Kernel, function, interactive layered design, between the layers only through the agreed protocol communication.
The more inward, the more concise and stable the focus. The kernel is extremely simple
The kernel of Git consists of blob, tree, commit, and three kinds of objects.
The three types of objects are clear and clear, and the association between objects is simple enough to be simple.
Simple enough, but also stable to no longer stable.
Blob storage data, tree structure, commit history.
The blob and tree are associated with a hash key as the only protocol.
Tree and Blob or own association.
Commit and tree associations, and blobs are not directly associated.
Only three objects, too handsome.
If you change the designer around, first of all, the micro-core can be so extreme is a challenge, just do the kernel may have more than 10 concepts out. What sync, trans, log, audit will come out.
It is more important to be able to determine what not to do.
The functional layer communicates only with the kernel through simple protocols
HEAD, Tag, branch several reference objects, as a version-controlled business domain concept, belong to the functional layer, or the business layer.
is directly associated with commit only.
Hash key as a reference pointer algorithm, is the only protocol, but also simple to no longer simple protocol, no protocol instruction manual, no need for interface description, really do a sentence can be said clearly. world-Class object naming
Naming the object is a top priority, which directly affects the quality of the design of the software system, as well as the quality of development, the cost of promotion and the cost of maintenance.
Blob, tree, commit several names are too handsome.
It can be called file, dir, his, but this is directly related to physics, the level of abstraction is not enough, the cost of the lack of abstraction will be extremely painful.
and naming meanings can cause confusion, and no one can figure out what the software is all about.
If change personal design, will be called Datanode, Storagenode, DirectoryEntry, Historyversionentry?
Called SJJD, Mljd also possible, pinyin initials, can read it.
effectively isolate concerns
Today's software products are complex and difficult to put all the attention to the human brain at the same time.
When designing and developing software, it is necessary to isolate the focus effectively in order to ensure the quality of design and development.
Let's consider the process of git development:
When implementing a blob, it is OK to just think about how the file is stored, how it is extracted, how the disk data is managed, and other concepts that have nothing to do with it.
When implementing a tree, consider only the upper API of the BLOB and the part of the function that you want to implement.
And so on: Git through a good design to effectively separate the focus, although in the design of a complex software system, but in the framework of the work, only need to consider the partition of the module and communication protocol, the design of the implementation of specific modules, due to set up a good protocol and functional specifications, only the module of things.
Break up the big, complicated stuff into cool, simple things. The developer just made the bricks, the project manager just did the transportation organization, the designer just did the site construction, the Great Wall was built.
The relationship between the ordinary and the great is so connected.
Hierarchical, modular, minimalist protocol, high cohesion, low-coupling these words have been hanging in the mouth, the separation of attention is also the designer's attempt, but who really do it. management of the State
Think about how the status of files and various operations in a file system (or version control system) is handled. Especially when they visit each other through the Internet.
Do you begin to draw complex and complex state diagrams in your mind, consider the processing efficiency of various concurrency models, the condition of deadlock, the processing mechanism after failure of various reasons, the conflict handling mechanism of text files, and the conflict handling mechanism of binary files.
What does git do with it?
A few core objects in Git, blob, tree, commit, are never changed after they are created.
Think about it, too. Key is the world's only code, it must be.
Still, it's easy to decide what to do, and it's hard to decide what to do. Never change, regardless of state is the decision of the kernel layer of git.
With the decision of the core layer, the direction is indicated.
The responsibility for change is handled by the business layer, where the core object of the business layer is three pointers, pointers and so on, so it's natural to respond to changes.
Implement the file comparison. There are also efficient treatment options. And feel more efficient than CVS or anything.
performance, distributed, concurrency considerations
Is there a software system that does not need to consider performance?
Is there any software that does not need to consider the distribution and concurrency now?
Architectural design and core layer design need to be thoughtful, considering all aspects of the matter, every detail should be considered, not to mention performance, distributed and concurrency.
Since the core object is created forever, performance, distributed, and concurrency considerations are suddenly simple.
And by sharing files over the network, the higher the probability that the same file will appear (with a small probability), the more efficient the storage is (theoretically).
In summary, God-level design, worship.