Pattern: Missing use of to___()
/as___()
for method name
Issue: -
PREFER naming a method to___()
if it copies the object's state to a new object.
PREFER naming a method as___()
if it returns a different representation backed by the original object.
Example of incorrect code:
class Bar {
Foo myMethod() {
return Foo.from(this);
}
}
Example of correct code:
class Bar {
Foo toFoo() {
return Foo.from(this);
}
}
Example of correct code:
class Bar {
Foo asFoo() {
return Foo.from(this);
}
}