Пример #1
0
        public static bool Validate(Person person)
        {
            // are names valid
            if (string.IsNullOrWhiteSpace(person.FirstName))
            {
                StandardMessages.DisplayErrorValidationError("first name");
                return(false);
            }
            if (string.IsNullOrWhiteSpace(person.LastName))
            {
                StandardMessages.DisplayErrorValidationError("last name");
                return(false);
            }

            return(true);
        }
Пример #2
0
        // A class or method should have 1 and only 1 reason to change. Bad code was amended to follow SRP!

        static void Main(string[] args)
        {
            StandardMessages.WelcomeMessage();

            Person user = PersonDataCapture.Capture(); // this is tightly coupled will be corrected in another principle

            bool isUserValid = PersonValidator.Validate(user);

            if (!isUserValid)
            {
                StandardMessages.EndApplication();
                return;
            }

            AccountGenerator.CreatAccount(user);

            StandardMessages.EndApplication();
        }