Giter VIP home page Giter VIP logo

ember-object's Issues

Remove all naked access, assignment, and execution

The principle driving this issue is called "The Principle of Uniform Access".

It helps that adhering to this principal will avoid bugs, and that breaking this principle in Ember will break your application code in odd and hard-to-debug ways.

// GIVEN
const Person = Ember.Object.extend({
  givenName: null,
  familyName: null,
});

const Developer = Person.extend({
  jobTitle: 'Developer',
  doJob () {
    return 'Computering';
  },
});

let jeff = Developer.create({
  givenName: 'Jeffrey',
  familyName: 'Horn',
});

// BAD
jeff.givenName; // some Ember junk
// GOOD
jeff.get('givenName'); // "Jeffrey"

// BAD
jeff.givenName = 'J-Rizzle' // let's break Ember
// GOOD
jeff.set('givenName', 'J-Rizzle'); // "J-Rizzle"

// BAD
jeff.doJob(); // 'Computering'
// GOOD
jeff.get('doJob')(); // 'Computering'

As a specific example for execution done wrong in this talk:

const Person = Ember.Object.extend({
  fullName: function(){
    return `${this.get('givenName')} ${this.get('surname')}`;
  }
});

let bob = Person.create({
  givenName: 'Bob',
  surname: 'Belcher'
})

-bob.fullName(); // 'Bob Belcher'
+bob.get('fullName')(); // 'Bob Belcher'

Use consistent strategy for template strings

Template strings are used in introductory examples. Code examples like the following:

const Person = Ember.Object.extend({
  sayHello: function(){
    return "Hi, my name is " + this.get('name');
  }
});

Should become:

const Person = Ember.Object.extend({
  sayHello: function(){
-    return "Hi, my name is " + this.get('name');
+    return `Hi, my name is ${this.get('name')}`;
  }
});

Gender!

This is an entire repo that has a lot of people's names in it, and none of them are female or even androgynous. Inclusivity in examples is important!

Find better way to run custom scripts

We need to be able to write scripts in order to create and muck around with arbitrary Ember Objects. However, copying and pasting scripts into the console is awkward. It would be great if we could find a better way to do it.

See #4

Change Ember.Object.create to Person.create

The code example has

Person.create({
...
  kids: [
-    Ember.Object.create({ name: 'Tina', age: 13 }),
-    Person.create({ name: 'Tina', age: 13 }),
  ...
  ]
})

Can you call Person.create inside Person.create? I don't see why not, but someone should test this and then change it in the README if ๐Ÿ‘

Move to study?

Can we move some, or all of this into a study? To me, this lesson feels a little lack-luster during our Ember unit, and the end game is:

  • Use .get and .set
  • There are computeds
  • "binding" ...kind of

Consider replacing last computed properties example with "Bob's Burgers" one?

var Person = Ember.Object.extend({
  fullName: Ember.computed('givenName', 'surname', function(){
    return this.get('givenName') + ' ' + this.get('surname');
  }),
  isOverFifty: Ember.computed.gte('age', 50),
  isABelcher: Ember.computed.equal('surname', 'Belcher'),
  hasNickname: Ember.computed.notEmpty('nickname'),
  kidsWithLongerNames: Ember.computed.filter('[email protected]', function(kid){
    return kid.get('name').length > 4;
  })
});

var gene = Ember.Object.create({
  name: 'Gene',
  age: 9
});
var tina = Ember.Object.create({
  name: 'Tina',
  age: 14
});
var louise = Ember.Object.create({
  name: 'Louise',
  age: 7
})

var bob = Person.create({
  givenName: 'Bob',
  surname: 'Belcher',
  age: 45,
  kids: [gene, tina, louise]
})

Add Return Values for logs to show point for both examples

console.log(`X: ${objX.get()}`);
objX.set(10);
console.log(`X: ${objX.get()}`);
console.log(`Y: ${objY.get()}`);
objY.set(100);
console.log(`Y: ${objY.get()}`);
console.log(`X: ${objX.get()}`);

Should be:

console.log(`X: ${objX.get()}`);
objX.set(10);
console.log(`X: ${objX.get()}`);
//=> 10
console.log(`Y: ${objY.get()}`);
//=> 5
objY.set(100);
console.log(`X: ${objX.get()}`);
//=> 10
console.log(`Y: ${objY.get()}`);
//=> 100

Computed Properties code missing call

In the Bob Belcher Computed Properties example, the 'call' reads bob.get and I believe it should be bob.get('fullName').

Please disregard if wrong and let me know.

Incorrect Instructions in Lab

Lab says to run the server using --proxy which in class we were told not to use. It also says to point to http://localhost:4200/ when we should be going to http://localhost:7165/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.