Public, protected, private or even final?

Thanks Lisa Johnson, https://pixabay.com/users/elljay-962436/

Discount Functionality

New Feature

Changes in the System

  • All internal usages of this method (done, by the change in the Item)
  • All outside usages of this method — because it is public
  • Interface of all descendants — because the might be descendants
  • All usages in descendants— because descendant might use it

Doing Less Work

  • All internal usages of this method (yes, there is no way around)
  • A̶l̶l̶ ̶o̶u̶t̶s̶i̶d̶e̶ ̶u̶s̶a̶g̶e̶s̶ ̶o̶f̶ ̶t̶h̶i̶s̶ ̶m̶e̶t̶h̶o̶d̶ — no, it’s private
  • I̶n̶t̶e̶r̶f̶a̶c̶e̶ ̶o̶f̶ ̶a̶l̶l̶ ̶d̶e̶s̶c̶e̶n̶d̶a̶n̶t̶s̶ — no, it’s final
  • A̶l̶l̶ ̶u̶s̶a̶g̶e̶s̶ ̶i̶n̶ ̶d̶e̶s̶c̶e̶n̶d̶a̶n̶t̶s̶ — no, it’s private and final

Private and Final

Use public, protected when have a Reason

TL; DR

--

--

Carvago is a large tech company and this publication focuses on topics related to development, design, analysis and architecture of our systems.

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