The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

ravivasamsetty (1) [Avatar] Offline
#1
Hi All,

I started reading Java persistence with Hibernate and one particular side bar in chapter 3 made me think a bit.
That particular Side bar talks about attribute and method visibility.

Author criticized the use of package visibility and I for one thought package visibility has a place.
Some external dependencies like EntityManager (EM) in a dao should be declared package visible so that while testing it would be easier to replace it with whatever I want. (Mock or use EntityManagerFactory to get EM)

My question is, Did author meant package visibility is bad within an Entity? or Was my understanding of testability improvement with usage of package visible dependencies off?
Christian Bauer (56) [Avatar] Offline
#2
Package visibility is bad, period, unless your system must enforce security policies. I don't understand what you are saying about testing and package visibility and I'm not sure I want to discuss this any further.