Gonzalo Chumillas
2016-06-23 16:08:49 UTC
What do you think about getters and setters? I'm not talking about
traditional getters/setters methods (getXxx() and setXxx()). I'm talking
about the language construction. For example:
class MyClass {
String _str;
String get str => _str;
void set str(String value) {
_str = value;
}
}
I think they are "evil". The reason is why they are hiding valuable
information to the user. Specifically: information related to performance.
That is, let's consider the following innocuous code:
myVar.driveCpu = 100;
It actually calls the following method:
myVar.setMyDriveHardAndMyCpuHot(100);
Obviously, you don't want to call the previous method frequently. It may
compromise the system.
What do you think about this transcendental question? I'm not sure if using
accessor methods are good idea.
Thanks and sorry my awful English.
traditional getters/setters methods (getXxx() and setXxx()). I'm talking
about the language construction. For example:
class MyClass {
String _str;
String get str => _str;
void set str(String value) {
_str = value;
}
}
I think they are "evil". The reason is why they are hiding valuable
information to the user. Specifically: information related to performance.
That is, let's consider the following innocuous code:
myVar.driveCpu = 100;
It actually calls the following method:
myVar.setMyDriveHardAndMyCpuHot(100);
Obviously, you don't want to call the previous method frequently. It may
compromise the system.
What do you think about this transcendental question? I'm not sure if using
accessor methods are good idea.
Thanks and sorry my awful English.
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.