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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:30:29+00:00 2026-06-14T06:30:29+00:00

I want to build a Register class for a website. Here are my use

  • 0

I want to build a Register class for a website. Here are my use cases —

  1. User will provide email id & password for registration
  2. If email id already exist then Register class will send an error message that this email already exist in our system
  3. If email doesn’t exist in our syetem then Register class will send an activation email in user email id and show message to user that — one activation email already sent to his/ser email

Here is the design that I thought about

Interface IRegister
{
 string RegisterUser(string email, string password);
}

public class Register:IRegister
{        
    public string RegisterUser(string email, string password)
    {
        //Call IsUserExist and SentActivationEmail method internally
    }

    private bool IsUserExist()
    {            
    }

    private void SendActivationEmail()
    {
    }
}

I don’t want to mention IsUserExist and SendActivationEmail method in IRegister so that it remains simple. Now how I can enforce a developer who will implement the Register class that he/she should use IsUserExist and SendActivationEmail method and do all operations as mentioned in use case. And does this design violate SRP principle?

  • 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-14T06:30:30+00:00Added an answer on June 14, 2026 at 6:30 am

    If you want to enforce that developers use those methods then you should be declaring an abstract class with protected abstract methods rather than an interface. Then the definition enforces the methods, but the developer is free to implement them however they need.

    public abstract class Register:IRegister
    {        
        public string RegisterUser(string email, string password)
        {
            //Call IsUserExist and SentActivationEmail method internally
        }
    
        protected abstract bool IsUserExist();
    
        protected abstract void SendActivationEmail();
    }
    

    That being said, to keep with the SRP principle I would pull the email part of it out into a dependent IActivationEmailer interface. Emailing and registering are really two different actions and should be kept separate.

    public interface IActivationEmailer {
        void SendActivationEmail();
    }
    
    public abstract class Register:IRegister
    {        
        private IActivationEmailer m_emailer;
        protected Register(IActivationEmailer emailer){
           // store emailer to field
           m_emailer = emailer;
        }
    
        public string RegisterUser(string email, string password)
        {
            //Call IsUserExist and m_emailer.SentActivationEmail method internally
        }
    
        protected abstract bool IsUserExist();
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to build a SIP client in java. A java class that will
I want to build a DLL Class Library use COM Interop, with C#, target
I want to build a web application where users can register and have a
i want to build a screen for user to get his marks on competitions,
I want to build flash application that can detect the user eyes color and
I want to build a form_tag that will allow me to post a new
I am working on an email validation link for a website. When a user
I want to build a website to allow users exchange clothes with each other.The
After reading the answer here, I understand that, if I register a user control
i want to build a website using codeigniter. The website is look like a

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.