Cool terms in Dart

Some of the terms in Dart are a little confusing for newbies, myself included.

This is my understanding, but I'm not sure if this is correct or not.

  • members: variables in the class, including instance variables, static variables, constructors, static methods, and instance methods.
  • properties: instance variables among class and instance members.
  • fields: members other than methods in the class.
  • variable: designation of the name of the instance being initialized, or an instance not yet initialized but with a class definition, including dynamic.
  • functions: all terms can have more than zero parameters, including methods.
  • methods: functions defined and declared in a class, including constructors, static methods.
  • objects: all terms in Dart, except conjunctions (if, while, for ...) and adjectives (static, final ...)

Second, are there terms that highlight properties in a class (not yet initialized) and in an instance (initialized)? That is, between initialized variables and not yet initialized ones.

Third, is there a class hierarchy diagram for Dart? I found it very simple but not similar to other languages.

Fourth, I guessed that sentence (A) is derived from sentence (B). Right?

(A) int x = 1;
(B) var x = int(1); //int() is the default constructor of class int. All the same to String, double, Map, List

      

...

I want to thank all of you for learning Dart for several Korean students.

+3


source to share


1 answer


  • members: variables in the class, including instance variables, static variables, constructors, static methods, and instance methods.
    • members are: fields (non-static variables declared in a class, properties are the same as fields), methods
      (fields / properties are also often called attributes, but I think this should be avoided in web development because attributes usually refer to HTML attributes).
    • variables are not considered members, unless they are fields
    • I wouldn't consider static fields (properties / functions) in Dart (but I'm not sure about that either). They are sometimes referred to as class members or static members, but in Dart, a class is just a namespace and these variable functions do not act as members.
    • constructors are not members
  1. properties: instance variables among class and instance members.
    • As far as I know, properties are the same as fields. Often properties only refer to getters / setters, but in Dart they are the same, at least at runtime (getters / setters are automatically created for all fields)
    • I'm not sure what you mean class

      here. The class usually refers to static (see above).
    • getters / setters (functions that can be accessed as fields) are usually treated as properties
    1. fields: members other than methods in the class.
      • I would name only instance variable fields and static variables static fields
      1. variable: designation of the name of the instance being initialized, or an instance not yet initialized but with a class definition, including dynamic.
        • variable is a declared identifier that refers to a memory address no matter where (library, class, instance, function, method).
        • And the not yet initialized variable does not contain a valid memory address ('null').
        1. functions: all terms can have more than zero parameters, including methods.
          • The number of parameters does not matter.
          • The functions can be called with ()

            or(arg1, arg2, ...)

          • Non-static functions in a class are commonly referred to as a not function method.
          • Functions are outside of a class at the library level, or inside a method or function (not sure if static methods are referred to as a function or a method in Dart).
void someFunction() => doSomething();
void someFunction(int a) { doSomething(); }

class A {
  void someMethod() {
    var anonymousFunction = () {
      doSomething();
    };

    anonymousFunction();
  }
}

      

  1. methods: functions defined and declared in a class, including constructors, static methods.
    • see above about static methods
    • constructors are not methods, constructors are constructors; -)
    1. objects: all terms in Dart, except conjunctions (if, while, for ...) and adjectives (static, final ...)
      • Only instances of the class are objects


var a = new A();

      

new A();

creates an instance A

. A

refers to an instance A

(object).

var x = 5;

      

creates an instance int

and x

refers to this instance (object).

+4


source







All Articles