Best way to develop service layer in java [closed]

本小妞迷上赌 提交于 2019-12-03 21:29:54

It's hard to say with so few details, and without even knowing what you'll use to access the database (JDBC? JPA? Hibernate?). But

  • the service layer and the persistence layer are not the same thing. To ease decoupling and testability, I prefer having a pure service layer and a data access layer
  • inheritance is generally not the best way to reuse code. Use a well-design API, and prefer delegation over inheritance.

Also, don't reinvent the wheel. EJB3, Spring and other frameworks have good support to develop services and expose them as web services.

You should consider using some framework, which will help you with routine. E.g. Spring or Java EE. Those frameworks can offer you many built-in solutions like IoC, declarative transactions, declarative security etc.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!