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

  • Home
  • SEARCH
  • 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 7564007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:48:29+00:00 2026-05-30T13:48:29+00:00

I have to implement classes that work with payment system (let’s call it PaymentSystem)

  • 0

I have to implement classes that work with payment system (let’s call it PaymentSystem) API that allow operations listed below:

  • Issue an invoice to the user
  • Check the invoice
  • Get users balance
  • Check payee existence

What I’ve got now is:

abstract class PaymentSystemBase where all the settings are remain (security token, password, RESTful APIs URL, etc.)

a class for each API entry:

  • PaymentSystemIssueInvoice
  • PaymentSystemCheckInvoice
  • PaymentSystemGetBalance
  • PaymentSystemCheckUser

each of this classes are inherited from PaymentSystemAPI with methods (inherited from PaymentSystemBase, of course):

  • request – performs request over HTTP
  • parseResponse to parse response from API (basically tells whether request was successful or we’ve got an error)

So my question is: would it be convenient to use some creation design pattern for the APIs (IssueInvoice, CheckInvoice, GetBalance, CheckUser)?

If you have suggestion for me how I should’ve implemented the API in the another way, please feel free to answer/comment the question.

Thank you.

  • 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-05-30T13:48:30+00:00Added an answer on May 30, 2026 at 1:48 pm

    This may be similar to command (noted by Irfy).

    If you have complex logic that determines which subclass of a base class to use (i.e. more than is reasonable to do with a few constructor params), then you can use the factory pattern.

    I’ll throw strategy out there as well, but we may be getting off-track.

    As a general note on design patterns, you should use them with a purpose. Typically patterns are used to:

    1. Increase code readability
    2. Increase code reusability.
    3. Separate what may change from what will not change.

    In particular, if the subclasses you are choosing may change in the future, it is good to abstract the code that decided which one to use. The factory pattern does this by encapsulating this logic in a single class.

    I strikes me as odd that you are using a handful of classes to represent what looks like methods. But, it sounds like you’re working with another API, so I’d need more info to advise further.

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

Sidebar

Related Questions

If I have interface IFoo, and have several classes that implement it, what is
If have a set of classes that all implement an interface. interface IMyinterface<T> {
I have a data access library that has a few classes that all implement
I have a virtual base class and two classes that implement the various methods.
The situation is this: You have two classes that both implement the same interface
Let's suppose I have an interface named Controller. Several classes implement this interface and
I have a managed c++ dll with few managed classes that in turn call
If I have some classes that implement the same interface, so they all contain
We have an interface which will be implemented by classes that take care of
I have written a set of classes and interfaces that are implemented in Moose

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.