Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Incorrect statement on page 552, Chapter 10 (K&B7)

 
C Selberg
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currently:
If getInstance() weren't public, we would still have a singleton. However, it wouldn't be as useful because only static methods of the class Show would be able to use the singleton.
Correct:
If getInstance() weren't public, we would still have a singleton. However, it wouldn't be as useful because only static methods of the package would be able to use the singleton.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi C Selberg,

First of all, a warm welcome to CodeRanch!

C Selberg wrote:Currently:
If getInstance() weren't public, we would still have a singleton. However, it wouldn't be as useful because only static methods of the class Show would be able to use the singleton.

That's indeed an incorrect statement and should be added to the errata overview.

C Selberg wrote:Correct:
If getInstance() weren't public, we would still have a singleton. However, it wouldn't be as useful because only static methods of the package would be able to use the singleton.

But that statement is incorrect as well I think the correct statement should be: If getInstance() weren't public, we would still have a singleton. However, it wouldn't be as useful because only methods of the package would be able to use the singleton.

Because instance methods can access static methods without any problem. So every method (instance or static) in the same package will be able to access the getInstance() method.

Hope it helps!
Kind regards,
Roel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic