Jump to content

Design smell

From Wikipedia, the free encyclopedia
(Redirected from Design Smell)

In computer programming, a design smell is a structure in a design that indicates a violation of fundamental design principles, and which can negatively impact the project's quality.[1] The origin of the term can be traced to the term "code smell" which was featured in the book Refactoring: Improving the Design of Existing Code by Martin Fowler.[2]

Details

[edit]

Different authors have defined the word "smell" in different ways:

  • N. Moha et al.: "Code and design smells are poor solutions to recurring implementation and design problems."[3]
  • R. C. Martin: "Design smells are the odors of rotting software."[4]
  • Fowler: "Smells are certain structures in the code that suggest (sometimes they scream for) the possibility of refactoring."[2]

Design smells indicate the accumulated design debt (one of the prominent dimensions of technical debt). Bugs or unimplemented features are not accounted as design smells. Design smells arise from the poor design decisions that make the design fragile and difficult to maintain. It is a good practice to identify design smells in a software system and apply appropriate refactoring to eliminate it to avoid accumulation of technical debt.

The context (characterized by various factors such as the problem at hand, design eco-system, and platform) plays an important role to decide whether a certain structure or decision should be considered as a design smell. Generally, it is appropriate to live with design smells due to constraints imposed by the context. Nevertheless, design smells should be tracked and managed as technical debt because they degrade the overall system quality over time.

Common design smells

[edit]
  • Missing abstraction[1] when clumps of data or encoded strings are used instead of creating an abstraction. Also known as "primitive obsession" [2] and "data clumps".[2]
  • Multifaceted abstraction[1] when an abstraction has multiple responsibilities assigned to it. Also known as "conceptualization abuse".[5]
  • Duplicate abstraction[1] when two or more abstractions have identical names or implementation or both. Also known as "alternative classes with different interfaces"[2] and "duplicate design artifacts".[6]
  • Deficient encapsulation[1] when the declared accessibility of one or more members of an abstraction is more permissive than actually required.
  • Unexploited encapsulation[1] when client code uses explicit type checks (using chained if-else or switch statements that check for the type of the object) instead of exploiting the variation in types already encapsulated within a hierarchy.
  • Broken modularization[1] when data and/or methods that ideally should have been localized into a single abstraction are separated and spread across multiple abstractions.
  • Insufficient modularization[1] when an abstraction exists that has not been completely decomposed, and a further decomposition could reduce its size, implementation complexity, or both.
  • Circular dependency. Cyclically dependent modularization[1] when two or more abstractions depend on each other directly or indirectly (creating a tight coupling between the abstractions). Also known as "cyclic dependencies".[7]
  • Cyclic hierarchy [1] when a supertype in a hierarchy depends on any of its subtypes. Also known as "inheritance/reference cycles".[8]
  • Unfactored hierarchy[1] when there is unnecessary duplication among types in a hierarchy.
  • Broken hierarchy[1] when a supertype and its subtype conceptually do not share an “IS-A” relationship resulting in broken substitutability. Also known as "inappropriate use of inheritance"[9] and "misapplying IS A".[10]

See also

[edit]

References

[edit]
  1. ^ a b c d e f g h i j k l Girish Suryanarayana, Ganesh SG, Tushar Sharma (2014). "Refactoring for software design smells: Managing technical debt". Morgan Kaufmann. ISBN 978-0128013977
  2. ^ a b c d e Fowler, Martin (1999). Refactoring. Improving the Design of Existing Code. Addison-Wesley. ISBN 0-201-48567-2.
  3. ^ N. Moha, Y. Gueheneuc, L. Duchien, and A. Le Meur. "Decor: A method for the specification and detection of code and design smells". IEEE Trans. Softw. Eng., 36(1):20–36, January 2010.
  4. ^ R. C. Martin. Agile Software Development, Principles, Patterns, and Practices. Addison-Wesley, 2003.
  5. ^ Trifu A. "Automated strategy based restructuring of object oriented code". In Proceedings of the 7th German workshop on software-reengineering (WSR); 2005.
  6. ^ Stal M. "Software architecture refactoring". Tutorial in The international conference on object oriented programming, systems, languages and applications (OOPSLA); 2007.
  7. ^ Page-Jones M. "The practical guide to structured systems design". 2nd ed. Prentice Hall; 1988.
  8. ^ Sefika M, Sane A, Campbell RH. "Monitoring compliance of a software system with its high-level design models". In Proceedings of the 18th international conference on software engineering, ICSE ‘96, Washington, DC; 1996. p. 387–96.
  9. ^ Budd T. "An introduction to object-oriented programming". 3rd ed. Addison Wesley; 2001.
  10. ^ Page-Jones M. "Fundamentals of object-oriented design in UML". Addison-Wesley Professional; 1999.