Classes may be useful at times, but they are also among the most misused constructs in modern software engineering. Classes are frequently too long and, therefore, hard to understand. While it is widely understood that global variables should be avoided, the member variables of a class often behave like mini-globals, accessible throughout the entire class. This practice is only justifiable if the class is very short; otherwise, the member variables serve no better purpose than global variables.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Classes

  • Marco Gähler

摘要

Classes may be useful at times, but they are also among the most misused constructs in modern software engineering. Classes are frequently too long and, therefore, hard to understand. While it is widely understood that global variables should be avoided, the member variables of a class often behave like mini-globals, accessible throughout the entire class. This practice is only justifiable if the class is very short; otherwise, the member variables serve no better purpose than global variables.