目录
一、可维护性的常见度量指标
Cyclomatic Complexity 圈复杂度
Lines of Code 代码行数
Maintainability Index (MI) 可维护性指数
Depth of Inheritance 继承的层次数
Class Coupling 类之间的耦合度 (高聚合,低耦合)
Unit test coverage单元测试的覆盖度
二、聚合度与耦合度
Coupling(耦合度):
Coupling is the measure of dependency between modules. A dependency exists between two modules if a change in one could require a change in the other.
决定:
– The number of interfaces between modules (quantity), and
– Complexity of each interface (determined by the type of communication) (quality)
Cohesion(聚合度):
Cohesion is a measure of how strongly related the functions or responsibilities of a module are.
A module has high cohesion if all of its elements are working towards the same goal.
三、SOLID
1.Single Responsibility Principle(SRP)单一责任原则:
不应该有多于1个原因让你的ADT发生变化,否则就拆分开
2.Open/Closed Principle (OCP)(面向变化的)开放/封闭原则:
3.Liskov Substitution Principle (LSP) Liskov替换原则:
LSP: Subtypes must be substitutable for their base types. (子类型必须能够替换其基类型)
4.Interface Segregation Principle (ISP) 接口隔离原则:
Clients should not be forced to depend upon methods that they do not use. (客户端不应依赖于它们不需要的方法)
5.Dependency Inversion Principle (DIP) 依赖转置原则:
Abstractions should not depend upon details (抽象的模块不应依赖于具体的模块)
Details should depend upon abstractions (具体应依赖于抽象)
四、正则表达式
It is a widely-used tool for many string-processing tasks that need to disassemble a string, extract information from it, or transform it.
根据语法,开发一个它的解析器,用于后续的解析
强制元字符被视为普通字符的两种方法: