Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Impl Classes Are Meaningless
Tristan Elliott
Tristan Elliott

Posted on

     

Impl Classes Are Meaningless

Resources

  • I have copied and pasted this opinion fromGrowing object oriented software guided by tests bySteve Freeman, Nat Pryce
  • I agree with this opinion but I am curious about what other people think

Impl Classes Are Meaningless

  • Sometimes we see code with classes named by addingImpl to the single interface they implement. This is better than leaving the class name unchanged and prefixing anI to the interface, but not by much. A name likeBookingImpl is duplication; it says exactly the same asimplements Booking, which is acode smell. We would not be happy with such obvious duplication elsewhere in our code, so we ought to refactor it away.

  • It might just be a naming problem. There’s always something specific about an implementation that can be included in the class name: it might use a bounded collection, communicate over HTTP, use a database for persistence, and so on. A bridging class is even easier to name, since it will belong in one domain but implement interfaces in another.

  • If there really isn’t a good implementation name, it might mean that the interface is poorly named or designed. Perhaps it’s unfocused because it has too many responsibilities; or it’s named after its implementation rather than its role in the client;
    or it’s a value, not an object—this discrepancy sometimes turns up when writing unit tests

Conclusion

  • Do you agree or disagree with this opinion? All of the classes in my current app follow theImpl naming convention. However, after reading this I will be refactoring them

  • Thank you for taking the time out of your day to read this blog post of mine. If you have any questions or concerns please comment below or reach out to me onTwitter.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

I will no longer be posting. I have gone back to school for mine engineering. Thank you to every follower and reader of my blogs || 我学中文
  • Location
    Canada,NB
  • Work
    Unemployed
  • Joined

More fromTristan Elliott

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp