• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

facade design pattern question

 
Cristian Aionesa
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all,

I have a problem regarding throwing RecordNotFoundException. My Data class is a facade and I use two other classes DataAccessManager and LockingManager for the actual work. I'm not sure if RecordNotFoundException should be thrown by the DataAccessManager object and allowed by Data to propagate on the stack, or if Data should do something like this:



I like this approach more, but I'm not sure if this design doesn't contradict the idea behind facade pattern.
Any suggestions are welcomed
 
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 Cristian,

I guess it all depends on the signature of your dataManager: i'll guess you have a seperate interface, which is implemented by the DataAccessManager class. So if you declared your readRecord-method to return null if a record is not found than your approach is just fine. If it declares to throw a RNFE (when no record is found) your code sample doesn't make any sense.
I myself did not use a facade pattern in my Data class, because in my opinion it just adds unneeded complexity. The Data class does not contain that many lines. But thinking about "high cohesion" specialised classes (one for real data access and another for locking) is

Kind regards,
Roel
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Cristian!

I like this approach more, but I'm not sure if this design doesn't contradict the idea behind facade pattern.


Hum... no. I think your approach is fine. I myself didn't use the facade pattern too; it just depends on the level of granularity you want your components to have, but both approaches are fine.
 
Cristian Aionesa
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot to you both, you are great helping people on this forum!

This facade design has caused me some problems, but I still think it is the best approach.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic