I'm looking for a name for a somewhat common refactoring I do in my Scala code. In this pattern I will "raise" a class' common method parameter up to being a member variable. For example:
\\ Original type:
trait Customer {
def name(as_at: Date): String
def address(as_at: Date): Address
//...imagine other methods with explicit "as_at: Date parameters...
}
\\ Refactored type -- the as_at: Date method parameter up to a member
trait Customer {
val as_at: Date
def name: String
def address: Address
//...other methods refer to the as_at: Date member internally
}
There's obvious inverse/dual, where you would "lower" an instance member to a method parameter. For example:
// Original type
trait Mortgage {
val interestRate: Double
def marturityDate: Date = {
//...calculation uses the interestRate val
}
}
// Refactored:
trait Mortgage {
def maturityDate(interestRate: Double): Date = ...
}
When I do this refactor, it feels lot like currying, though obviously its not the same thing as currying. I'm toying with the term "closing state over a common method parameter", but that seems a little long. And I guess I'd have to call the inverse "unclosing state to a common method parameter" if I were sticking to my terminology. Ick. No.