// ReSharper disable SuggestBaseTypeForParameter /// <summary> /// /// </summary> /// <param name="trip"></param> /// <param name="patron"></param> /// <param name="constraint"></param> /// <returns></returns> /// <remarks>This was another impacted area where not only calculating the desired /// departure time, but also knowing about the associated constraint, was desirable.</remarks> private int? GetNextDepartureTimeMinutes(Trip trip, Patron patron, out TripConstraint constraint) { // Should work for both Northbound (true/false), inverse of which is Southbound. constraint = Constraints.Single(t => t.IsNorthbound == patron.IsNorthbound); if (trip == null) return constraint.FirstDepartureTimeMinutes; var dtm = trip.DepartureTimeMinutes; // Which closing the loop the refactor should be relatively painless after all. var result = dtm + constraint.Frequencies.GetWaitTimeMinutes(dtm); return result > constraint.MaxAllowableDepartureTimeMinutes ? (int?) null : result; }
/// <summary> /// /// </summary> /// <param name="constraint"></param> /// <param name="departureTimeMinutes"></param> /// <remarks>Constraints are another area that I was dubious about. However, it makes /// sense for the trip to know about its constraint, especially so that subsequent /// calculations may be properly normalized and denormalized when performing calculations /// and making reports, respectively.</remarks> public Trip(TripConstraint constraint, int departureTimeMinutes) { Constraint = constraint; DepartureTimeMinutes = departureTimeMinutes; }