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。最后是观察者模式,实现一个股票市场监控系统,当股票价格变化时通知注册的观察者,包括邮件通知、短信通知和应用内通知。这些模式在软件架构设计中起着重要作用,帮助程序员编写可维护、可扩展的代码。
126
0
0
2025-03-14