Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

private classes with in servlets

 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it a good practice to

1.)create final private classes inside servlet classes
2.)create instances of private classes inside servlets {in step 1}
3.) used insatance created in step 2 for business logic processing.



Thanks
Neeraj.
 
Ankit Garg
Sheriff
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IMHO, this depends on a lot of things. I've never came across any such situation where I need to put business logic in an inner class...
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if it helps the code in some other manner (maintainability, understandability) and should be kept private then it is a good practice. This questions applies to any class, not just servlets.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the purpose is for business logic, then I'd say no. Business logic belongs in its own layer below the servlet controller layer, and should not be embedded within the servlets.
 
Steven Zhu
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For me, it's a little bad. Firstly, serverlet should be regarded as a part of control layer, business logic might be handled in another places; secondly, a business inner class isn't general, example if another mode needs similar logic, it's difficult to reuse that inner class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic