Mkdir700's Note

Mkdir700's Note

架构设计

SOLID 原则详解

SOLID principles, including Single Responsibility Principle, Open/Closed Principle, Liskov Substitution Principle, Interface Segregation Principle, and Dependency Inversion Principle, aim to improve software design flexibility, maintainability, and scalability. Each principle is detailed with core concepts, explanations, examples, and benefits. By adhering to these principles, code becomes clearer, easier to test and maintain, with reduced coupling between classes, increased reusability, extensibility, and system stability. The principles promote single responsibility, open for extension but closed for modification, substitution without affecting correctness, interface segregation to avoid unnecessary methods, and dependency inversion through abstraction and decoupling.
153
0
0
2025-03-14

常见设计模式 Python 实现

本文介绍了三种常见的设计模式在 Python 中的实现:单例模式、工厂模式和观察者模式。在单例模式中,实现了一个数据库连接池管理器,确保系统中只有一个连接池实例;在工厂模式中,设计了支持多种数据格式解析的文件处理系统,包括实现了 CSV、JSON、XML 和 YAML 文件格式的解析器;在观察者模式中,实现了一个股票市场监控系统,支持多种类型的观察者,如邮件通知、短信通知和应用内通知。这些设计模式为软件架构提供了灵活性和可扩展性。
127
0
0
2025-03-14