Skip to content

Long Constructor with Many Parameters #9

@DanielBr840

Description

@DanielBr840

Many constructors in Person and its subclasses (Student, Applicant, Professor, LibraryUser) have too many parameters. This makes them hard to read, understand, and maintain. Instead, we can use a single class for date of birth and apply named parameters or an object initializer to improve readability.

public Person(string Name, string Surname, int BirthDate, int BirthMonth, int BirthYear)
{
name = Name;
surname = Surname;
birthDay = BirthDate;
birthMonth = BirthMonth;
birthYear = BirthYear;
}

public Applicant(string Name, string Surname, int BirthDate, int BirthMonth, int BirthYear, int FinalExamGrade, double SchoolGrade, string SchoolName):base(Name, Surname, BirthDate, BirthYear, BirthMonth)
{
finalExamGrade = FinalExamGrade;
schoolGrade = SchoolGrade;
schoolName = SchoolName;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions