Refactoring parameters
Now that we’ve explored the basics of methods and constructors, let’s talk about managing parameters. This is important because it is possible that poorly thought-out parameters can quickly reduce the maintainability of your code.
Let’s look at a few common refactorings you’ll want to perform over the life of your methods.
Reordering parameters
Sometimes, you’ll realize that the order of parameters in a method doesn’t make as much sense as another arrangement might. At other times, you might notice that a few of your methods take in the same kinds of parameters, but with inconsistent ordering. In either case, you’ll find yourself wanting to reorder your method parameters.
Let’s look at a practical example from the various MarkX
methods we saw earlier:
FlightTracker.cs
public Flight? MarkFlightDelayed(string id, DateTime newDepartureTime) { // Details omitted... ...