Problem Statement
A lab to follow the SRP principle while doing your code in C#.
UserService Class:
using System;
public class UserService
{
private readonly AuthenticationService _authenticationService;
private readonly UserDataService _userDataService;
private readonly EmailNotificationService _emailNotificationService;
public UserService(AuthenticationService authenticationService, UserDataService userDataService, EmailNotificationService emailNotificationService)
{
_authenticationService = authenticationService;
_userDataService = userDataService;
_emailNotificationService = emailNotificationService;
}
public void ProcessUser(string username, string password, string emailAddress)
{
// Authenticate user
if (_authenticationService.AuthenticateUser(username, password))
{
// If authenticated, manage user data
_userDataService.ManageUserData(username);
// Send email notification
string message = "Your account has been accessed.";
_emailNotificationService.SendNotification(emailAddress, message);
}
else
{
Console.WriteLine("Authentication failed.");
}
}
}
Lab Objective:
Upon completion of this lab, you will be able to:
Prerequisites
You should install the following software on your machine: