Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Step 5 #33

Open
sethladd opened this issue Jan 29, 2014 · 2 comments
Open

Simplify Step 5 #33

sethladd opened this issue Jan 29, 2014 · 2 comments

Comments

@sethladd
Copy link
Contributor

Can we simplify and not use getters and setters from PirateName to the controller fields?

class BadgesController {
  // ...
  String get name => _name._firstName;
  set name(String value) {
    _name = new PirateName(firstName: value);
  }

  String get pirateName => _name.pirateName;
  // ...
}

could just be:

class BadgesController {
  PirateName pirateName;
}

The version in the code lab looks too verbose :(

Thoughts?

@a14n
Copy link
Contributor

a14n commented Jan 29, 2014

I just tried to change this but this implies some modifications in PirateName ( a firstName getter and a firstName setter ) and in the binding in the html file that do not really simplify :

     <div class="widgets">
       <div>
-        <input type="text" id="inputName" maxlength="15" ng-model="ctrl.name">
+        <input type="text" id="inputName" maxlength="15" ng-model="ctrl.pirateName.firstName">
       </div>
       <div>
         <button ng-click="ctrl.generateName()" ng-disabled="ctrl.inputIsNotEmpty">{{ctrl.label}}</button>
       </div>
     </div>
-    <badge name="{{ctrl.pirateName}}" style='float: left; margin-left: 20px;'></badge>
+    <badge name="{{ctrl.pirateName.name}}" style='float: left; margin-left: 20px;'></badge>
     <script type="application/dart" src="piratebadge.dart"></script>
     <script src="packages/browser/dart.js"></script>
   </body>

My goal was to keep the code of PirateName almost the same as the darrrt version. So I would prefer to not change this code.

@sethladd
Copy link
Contributor Author

I think it's OK to differ from the original, if it makes sense. I'm worried that we made a controller that is also acting like a model. I think it's ok to have a binding expression like ctrl.pirateName.firstName

I'm also worried people will think we built a system like Java, with all the getters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants