Found 1000 relevant articles
-
Low Coupling and High Cohesion in Software Design: Principles and Practices
This article provides an in-depth exploration of the core concepts of low coupling and high cohesion in software engineering. By analyzing the degree of element association within modules and dependencies between modules, it explains how high cohesion improves code maintainability and how low coupling enhances system flexibility. Combining object-oriented design examples, it details coupling types and cohesion levels, and provides specific code implementations to demonstrate the application of design principles. The article also discusses the essential differences between HTML tags like <br> and characters, helping developers build more robust software architectures.
-
Software Design vs. Software Architecture: A Comprehensive Analysis
This article delves into the core distinctions between software design and software architecture, highlighting architecture as the high-level skeleton of a system and design as the detailed planning of individual modules. Through systematic analysis and code examples, it explains how architectural decisions shape data storage and module interactions, while design focuses on class responsibilities and pattern applications, providing a clear framework for developers.
-
Cohesion and Coupling in Software Design: Concepts, Differences, and Best Practices
This article provides an in-depth exploration of two fundamental concepts in software engineering: cohesion and coupling. Through detailed analysis of their definitions, types, differences, and impact on software quality, combined with concrete code examples, it elucidates how the principle of high cohesion and low coupling enhances software maintainability, scalability, and reliability. The article also discusses various types of cohesion and coupling, along with practical strategies for achieving good design in real-world development.
-
N-Tier Architecture: An In-Depth Analysis of Layered Design Patterns in Modern Software Engineering
This article explores the core concepts, implementation principles, and applications of N-tier architecture in modern software development. It distinguishes between multi-tier and layered designs, emphasizes the importance of crossing process boundaries, and illustrates data transmission mechanisms with practical examples. The discussion also covers the fundamental differences between HTML tags like <br> and character \n, as well as strategies for handling unreliable network communications in distributed environments.
-
Examples of GoF Design Patterns in Java Core Libraries
This article explores the implementation of Gang of Four (GoF) design patterns within Java's core libraries, providing detailed examples and explanations for creational, structural, and behavioral patterns to help developers understand their real-world applications in Java code.
-
Factory Pattern Distinction in Design Patterns: From Naming Confusion to Core Differences
This article deeply explores common naming confusion in design patterns, focusing on the core differences between Factory Method Pattern and Abstract Factory Pattern. By clarifying the multiple meanings of the term "factory", it systematically explains the essential distinctions in intent, structure, and application scenarios of both patterns, providing clear code examples to illustrate proper selection and usage of these creational patterns.
-
Drawbacks of Singleton Pattern: From Design Principles to Practical Challenges
This article provides an in-depth analysis of the main drawbacks of the Singleton pattern in software design, including violations of the Single Responsibility Principle, hidden dependencies, tight coupling, and testing difficulties. Through detailed technical analysis and code examples, it explains why the Singleton pattern is often considered an anti-pattern in modern software development, along with corresponding solutions and alternatives.
-
Wrapper Classes: Concepts, Applications, and Design Pattern Practices
This article provides an in-depth exploration of wrapper classes, analyzing their crucial role in software design. Through concrete code examples, it demonstrates how wrappers encapsulate underlying component functionality and simplify interface calls, while discussing their relationship with adapter and facade patterns. The paper also details the implementation mechanisms of primitive type wrappers in Java, including autoboxing principles and practical application scenarios in real-world development.
-
Dependency Injection: Principles, Benefits and Practical Implementation
This comprehensive article explores the core concepts of dependency injection, comparing traditional hard-coded dependencies with DI approaches. It details three primary implementation methods: constructor injection, setter injection, and interface injection, while emphasizing DI's significant advantages in testability improvement, coupling reduction, and system flexibility enhancement. Practical code examples demonstrate effective application across various programming scenarios.
-
In-Depth Analysis of Inversion of Control: From Concept to Practice
This article provides a comprehensive exploration of Inversion of Control (IoC) core concepts, problems it solves, and appropriate usage scenarios. By comparing traditional programming with IoC programming, it analyzes Dependency Injection (DI) as a specific implementation of IoC through three main approaches: constructor injection, setter injection, and service locator. Using code examples from text editor spell checking, it demonstrates how IoC achieves component decoupling, improves code testability and maintainability. The discussion extends to IoC applications in event-driven programming, GUI frameworks, and guidelines for when to use IoC effectively.
-
Reflections on Accessing Private Variables in JUnit Unit Testing
This paper examines the need and controversy of accessing private variables in Java unit testing. It first analyzes how testing private variables may reveal design issues, then details the technical implementation of accessing private fields via Java Reflection, including code examples and precautions. The article also discusses alternative strategies in real-world development when testers cannot modify source code, such as testing behavior through public interfaces or using test-specific methods. Finally, it emphasizes the principle that unit testing should focus on behavior rather than implementation details, providing practical advice under constraints.
-
Abstract Classes vs Interfaces in C++: Design Patterns and Implementation Strategies
This paper provides an in-depth analysis of the core distinctions between abstract classes and interfaces in C++, along with their respective application scenarios. By comparing design patterns of pure virtual functions and abstract classes, and examining practical examples from COM component and DLL development, it highlights the advantages of interfaces in achieving highly decoupled architectures. The article details the use of abstract classes in providing infrastructure code, demonstrated through an OpenGL application framework example that shows how inheritance and polymorphism enable extensible software design. Finally, it contrasts interface implementation differences between C++ and Java from a language feature perspective, offering practical programming guidance for developers.
-
Best Practices and Principles for C/C++ Header File Inclusion Order
This article delves into the core principles and best practices for header file inclusion order in C/C++ programming. Based on high-scoring Stack Overflow answers and Lakos's software design theory, we analyze why a local-to-global order is recommended and emphasize the importance of self-contained headers. Through concrete code examples, we demonstrate how to avoid implicit dependencies and improve code maintainability. The article also discusses differences among style guides and provides practical advice for building robust large-scale projects.
-
Best Practices for Text File Reading in Android Applications and Design Philosophy
This article provides an in-depth exploration of proper methods for reading text files in Android applications, focusing on the usage scenarios of assets and res/raw directories. By comparing the differences between FileInputStream, AssetManager, and Resources approaches, and combining the design evolution of text files in software development, it offers complete code examples and best practice recommendations. The article also discusses the importance of simple design from a software engineering perspective, demonstrating how proper file management can enhance application performance and maintainability.
-
Abstraction and Encapsulation in Object-Oriented Programming: Core Concepts and C# Implementation
This article delves into the core distinctions between abstraction and encapsulation in object-oriented programming, using C# code examples to illustrate their distinct roles in software design. Abstraction focuses on identifying general patterns for reusable solutions, while encapsulation emphasizes hiding implementation details and protecting object state. Based on authoritative definitions and practical cases, it helps developers clearly understand these key concepts and avoid common confusion.
-
Spring Dependency Injection: Comprehensive Analysis of Field Injection vs Constructor Injection
This article provides an in-depth examination of the core differences between field injection and constructor injection in the Spring framework. It details seven major drawbacks of field injection and five key advantages of constructor injection, supported by complete code examples. The discussion covers testing friendliness, code maintainability, and adherence to design principles, along with best practice recommendations from modern Spring versions for practical developer guidance.
-
Inversion of Control vs Dependency Injection: Conceptual Analysis and Practical Applications
This article delves into the core concepts of Inversion of Control (IoC) and Dependency Injection (DI), and their interrelationship. IoC is a programming principle that delegates control flow to external frameworks via callbacks; DI is a specific implementation of IoC, injecting dependencies through constructors, setters, or interfaces. The analysis distinguishes their differences, illustrates decoupling and testability with code examples, and discusses the advantages of IoC containers and DI frameworks in modern software development.
-
A Practical Guide to Domain-Driven Design: Core Concepts and Code Examples
This article delves into the core concepts of Domain-Driven Design (DDD), including domain models, repositories, domain/application services, value objects, and aggregate roots. By analyzing real-world code examples such as DDDSample in Java and dddps in C#, it reveals implementation details and design decisions in DDD practice. The article emphasizes that DDD is not just about code patterns but a modeling process, helping developers understand how to effectively integrate business logic with technical implementation.
-
Choosing Between Interfaces and Abstract Classes in C#: From Design Principles to Practical Applications
This article provides an in-depth exploration of the core distinctions and application scenarios between interfaces and abstract classes in C#. By analyzing their design philosophies, functional characteristics, and new features in C# 8.0, along with concrete code examples, it systematically explains how to select the appropriate abstraction mechanism in object-oriented design. The comparison covers multiple dimensions including multiple inheritance limitations, default implementation capabilities, and type semantics, offering developers a clear decision-making framework.
-
Dependency Injection in Static Classes: Method Injection Patterns and Design Analysis
This paper explores the technical challenges and solutions for implementing dependency injection in static classes. By analyzing the core principles of dependency injection, it explains why static classes cannot use constructor or property injection and highlights method injection as the only viable pattern. Using a logging service case study, the paper demonstrates how method injection enables loose coupling, while discussing design trade-offs, practical applications of the Inversion of Control principle, and identification of common anti-patterns. Finally, it provides refactoring recommendations and best practices to help developers manage dependencies effectively while maintaining testability and maintainability.