Skip to content

Remove need to bloat code by setters and getters, support get/set like in C# instead #72

@DartBot

Description

@DartBot

This issue was originally filed by [email protected]


Following the Total example code at https://code.google.com/p/dart/source/browse/branches/bleeding_edge/dart/client/samples/total/src/Cell.dart you need to code a lot of setters and getters, which is a pain and bad practice:

class Cell {
  CellContent _content;
  Set<CellLocation> _dependents;
  bool _isStyleDirty;
  Style _style;

  // the following code should make you cry:

  CellContent get content() {
    return _content;
  }

  Set<CellLocation> get dependents() {
    return _dependents;
  }

  Style get style() {
    return _style;
  }

Have a look at the keywords 'get' and 'set' in C#. For instance getters could be created like this:

  CellContent _content { get; };
  Set<CellLocation> _dependents { get; };
  bool _isStyleDirty { get; };
  Style _style { get; }
      

Metadata

Metadata

Assignees

Labels

area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).closed-duplicateClosed in favor of an existing reporttype-enhancementA request for a change that isn't a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions