Photo by Brett Jordan in Pexels

Problems

  • Mutability
  • Incomplete objects
  • Concurrency inconsistencies between creation and essence setting.
  • Setters

Solutions

  • Pass the object’s essence on creation

Examples

  • Some persistence frameworks in static typed languages require an empty constructor.

Exceptions

  • Stateless objects. Always better solution than static class methods.

Sample Code

Wrong

Right

Detection

Tags

  • Essence
  • Incomplete
  • Mutable

Conclusion


The code smells bad. Let’s see how to change the aromas.

Code Smells


Your objects are a bunch of public attributes without behavior.

Photo by Stacey Vandergriff on Unsplash

Problems

Solutions

Examples

  • DTOs

Sample Code

Wrong

Right

Detection

Also Known as

  • Data Class

Tags

  • Anemic
  • OOP as Data
  • Encapsulation
  • Setters/Getters
  • Mutability

More info


Photo by Zorik D on Unsplash

Problems

  • Unexpected side effects
  • Accidental complexity

Solutions

  1. Use better languages
  2. Use spread operator

Sample Code

Wrong

Right

Detection

Tags

  • Mutability
  • JavaScript

Conclusion

More Info

Credits


Do not perform more than requested.

Photo by Paul on Unsplash

Problems

  • Coupling
  • Single Responsibility Principle violation
  • Readability
  • Low Cohesion
  • Testability

Solutions

  1. Break the function

Sample Code

Wrong

Right

Detection

Tags

  • Readability
  • Naming

Conclusion

More Info

Credits


Bio


Bio


Bio

Talk

My Personal notes

  • TDD is not a testing strategy…


Bio

Maximiliano Contieri

I’m senior software engineer specialized in declarative designs. S.O.L.I.D. and agile methodologies fan.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store