Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8734867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:55:50+00:00 2026-06-13T09:55:50+00:00

What would you name a class which does only a very small part of

  • 0

What would you name a class which does only a very small part of functionality, for example taking a recurring payment profile and marking it as ‘failed’.

Is it correct to name it RecurringPaymentProfileMarkAsFailedService? I know it’s just a name, but I would like to adher to standards / convention. Is this what a ‘Service’ class should do, or is this a different design pattern? I am trying to follow up on the line of the SRP principle, and thus if I am correct one would end up with a lot of small classes, each specialised in one task. I would like to define a correct naming standard.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:55:51+00:00Added an answer on June 13, 2026 at 9:55 am

    Though I’ve never seen it strictly documented, I typically use the word ‘Service’ to indicate a class that handles some subset of related end-user functionality.

    For example, say I have a bank account system, I might have the following service:

    public class AccountService
    {
      public boolean transfer(Account src, Account dest, double amt) // ....
    
      public Account create(User user, double initAmt) // ...
    
      public void close(Account account) // ...
    }
    

    So the “high-level” functions that the user can do are encapsulated in my Services. Services will access the database, instantiate whatever helpers, do calculations, etc that it needs. But like I said, this is just what I’ve observed from my time in the industry.

    As far as SRP: SRP does not mean that you need a whole new class for each function you want to perform. You don’t need a class to mark a profile as failed and another to mark it as success and another to change the name of the profile and …

    SRP means that each class handles “one thing” but that “one thing” can be a set of closely related functions. Another important OO design principle to consider is encapsulation. That is, a class should minimize what it exposes to clients – only exposing what others need. If you are having tons of little classes that manage a PaymentProfile’s internal state, you are exposing all of the details of PaymentProfile. I’ll give you a small example:

    Let’s say your PaymentProfile object has a boolean isSuccess. Then your class RecurringPaymentProfileMarkAsFailedService does something like this:

     public class RecurringPaymentProfileMarkAsFailedService {
       public void mark(PaymentProfile profile)
       {
         profile.setSuccess(false);
       }
     }
    

    Cool – everything’s working great. Now we get a feature request that not only can a PaymentProfile have statuses ‘Success’ and ‘Failure’, but now we need to support ‘InternalError’ which means some internal system crashed during the update. We can no longer use a boolean, so we change our boolean isSuccess to an enum that can be one of: SUCCESS, FAILURE, ERROR. Now we have to refactor our MarkAsFailedService.

    This is a trivial refactor b/c it’s just one class, but for a complex class tree, these refactors could echo all across a system. It’s a sign that I’m revealing too many implementation details about my PaymentProfile. A class should be encapsulated so a change to it’s implementation has little/no impact on it’s clients.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In PHP, how can a class reference its own name? For example, what would
How would you find a particular class name inside lots of jar files? (Looking
Lets assume we have a class car. How would You name parameters of function
I have string like this : <input name=my_name id=my_id value=my_value class=my_class /> I would
How would I parse a domain name in Objective-C? For example if my string
I have an Articles class, which must store these fields: article_id name title_es title_en
For example in classic object oriented programming I might have a class School which
I have a declarative base class Entity which defines the column name as polymorphic,
I am testing the functionality of a StoreManager class which has a dependency on
I have a class LINE which contains two properties of type POINT. I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.