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; |
|
} |
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.
TaskRefactoring/ClassLibrary1.cs
Lines 20 to 27 in 672599a
TaskRefactoring/ClassLibrary1.cs
Lines 113 to 118 in 672599a