Coder Social home page Coder Social logo

Comments (4)

ondrej-smola avatar ondrej-smola commented on August 14, 2024 1

OK, so your services act as facade/adapter for repository.

from ppj_project.

Tmthetom avatar Tmthetom commented on August 14, 2024

Please provide more informations. Only thing i found is this difference in every pair of classes:
findByImage -> CommentRepository
getByImage -> CommentService
...
But this is based on Example: Lecture8_SpringDataJPAWithSpringBoot

from ppj_project.

ondrej-smola avatar ondrej-smola commented on August 14, 2024

Another way: Is AService needed when i have ARepository ? When i need to add some functionality, for example listing most upvoted or downvoted comments, should this functionality be implemented in CommentService or CommentRepository?

from ppj_project.

Tmthetom avatar Tmthetom commented on August 14, 2024

When i have Repository, i dont need Service, because Repository implements all functionality. To answer your second question, functionality will be implemented in CommentRepository.

But Service layer gives you additional level of abstraction over data access from Repository. Service is kind of API and should transform input or output data somehow, call Repository and return expected result. To answer your first question, i will give you some example. My Repositories not always accepts objects, sometimes they need only ID, or some column from object. Thanks to my Services, i can always call service.method and pass object. When ID, or some column is required, i will extract from object in Service, so i dont need to call like repository.method1(object), repository.method2(object.column2), repository.method3(object), but i can call service.method1(object), service.method2(object), service.method3(object). Also when return value need to be changed, i can also do it in Service.

from ppj_project.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.