0
Отвечено
Temporary field - example
I might not get the temporary field definition right. As far as I understood, if there is a class User, defined as below, where fullName is passed in the constructor of the class, while lastName and firstName are only used internally, both firstName and lastName are temporary fields.
class User {
private String fullName; private String lastName; private String firstName; ... }
Is this a good definition of temporary fields?
Сервис поддержки клиентов работает на платформе UserEcho
Hi!
If first & last names are used internally, that doesn't mean that they would be temporary. Imagine a local variable in a method, say you keep some intermediary value in that variable between the method start and finish. If you convert that variable into a field, that would be a 100% temporary field. Of course, there's no reason to make such a conversion intentionally. However, such a field may be created after several iterations of changes to a method, for example, when the field value becomes no longer relevant in other methods of the class.
Hello! Thank you for your response, I understand your example.
So in this class
and
are considered temporary fields because they are used in the
method?