Better way to clean this messy bool method
- by Luís Custódio
I'm reading Fowler Clean Code book and I think that my code is a little messy, I want some suggestions:
I have a simple business requirement that is return the date of new execution of my Thread.
I've two class fields: _hour and _day.
If actual day is higher than my _day field I must return true, so I'll add a month to "executionDate"
If the day is the same, but the actual hour is higher than _hour I should return true too.
So I did this simple method:
private bool ScheduledDateGreaterThanCurrentDate (DateTime dataAtual) {
if (dateActual.Day > _day) {
return true;
}
if (dateActual.Day == _day && dateActual.Hour > _hour) {
return true;
}
if (dateActual.Day == _day && dateActual.Hour == _hour)
if (dateActual.Minute>0 || dateActual.Second>0)
return true;
return false;
}
I'm programming with TDD, so I know that the return is correct, but this is bad maintain code right?