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 8461933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:01:06+00:00 2026-06-10T14:01:06+00:00

I have lately been reading on the Single Responsibility Principle concept, and in theory

  • 0

I have lately been reading on the Single Responsibility Principle concept, and in theory I agree a lot with it. I am having difficulty coming to terms on which code can be exactly classified as violating the principle. I would like to implement this principle, so as to gear towards Test-Driven Development.

Take for example the code below:

public void MarkAsSuccessful(PaymentMethodSpecific paymentMethod, bool requiresManualIntervention)
    {
            this.Paid = true;
            this.PaidOn = CS.General_v3.Util.Date.Now;
            this.PaidByPaymentMethod = paymentMethod;
            this.RequiresManualIntervention = requiresManualIntervention;

            this.Update();

        this.CreateAndSendNotificationRegardingImmediatePayment();

        this.SendPaymentSuccessfulEmails();

    }

This is placed in a class called PaymentRequest, which basically is a class which handles logic related to payment in an e-commerce application. The method above marks the request as ‘successful’. This must mark the columns paid, as well as other information, as well as send a notification that this was successful, and also send emails.

For example, when it comes to unit testing – It is very difficult to unit-test this method as I have no way to know that the notification was actually created and sent, as well as the payment emails have been sent. Would like to know how more experienced people on the SRP concept would approach such an example.

  • 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-10T14:01:08+00:00Added an answer on June 10, 2026 at 2:01 pm

    My guess is that you have a PaymentProcessor class merged with/embedded in your PaymentRequest class.

    PaymentProcessor is basically a finite-state machine that a PaymentRequest travels through.

    When constructing this PaymentProcessor you would inject objects that would handle the “immediate payment notifications” and emails in general. This way you test all that states independently and the processor by injecting mock objects that assert that expected conditions occurred.

    Single responsibility by itself is a great concept but the power really comes when you start investing in SOLID as a whole.

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

Sidebar

Related Questions

Lately I have been reading a lot of blog topics about big sites(facebook, twitter,
I have been reading a lot of Javascript lately and I have been noticing
I have been reading a lot on design patterns lately and some of them
So I have been reading a lot of documentation on HRD and NDB lately,
I have been reading a lot about WCF lately and whenever the subject of
I have been reading a lot about Haskell lately, and the benefits that it
I have been reading a lot of articles lately about programming practice, design and
I have been reading about Factory pattern a lot lately. I am trying to
I have been lately reading a lot on memory allocation schemes in java, and
I have been reading a lot about Reinforcement Learning lately, and I have found

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.