Mastering Dart (Reading notes)-The interesting part is its future, isolates and zones

Source: Internet
Author: User

Mastering DartDirectory
  • 1 Basic
  • 2 Advanced Technology/Reflection
  • 3 Object Creation
  • 4 Asynchronous Programming
  • 5 Stream Frame
  • 6 Collection Frame
  • 7 Dart and JavaScript interoperate
  • 8 Internationalization and Localization
  • 9 c/S communication
  • Ten Premium Storage
  • One supports other HTML5 features
  • A Safety
Basic
    1. Modular
      1. Pubspec.yaml
      2. Import ' dart:html ' as DOM;
    2. Custom: _ prefix stands for private
    3. Import ' Animation.dart ' as animation hide animation; Does it seem that the code directly affects the IDE's autocomplete?
    4. The DART function can be thought of as JS minus the useless function keyword?
      1. void Main () {...}
    5. Introduced a PHP string template: Print ("Result=#{result}");
    6. Function Shorthand: Sub (A, b) = A-A; ES6 Direct support?
    7. Class and Mixin
      1. Strange constructor parameter notation: Car (This.color, this.carrying);
      2. Abstract (abstraction base class is interface)
      3. Extends/implements
      4. Mixin is a special class that uses the WITH keyword to mix with the target class, conditions:
        1. No (declared) constructor
        2. No super Class (or object).
        3. Does not contain a call to Super
      5. static const List L = const [' A ', ' B ', ' C '];
Advanced Technology/Reflection
  1. Generic type
  2. Function: Defines the class of the Call method (vs C + + functions object?). )
  3. Error vs Exception (recoverable)
    1. try {...} on Error catch (ex) {...}
  4. Annotations
    1. @deprecated
    2. @override
    3. @proxy
      1. Proxy class: @override Nosuchmethod (invocation invo) {...}//borrowed the idea of Ruby?
    4. Customization: (eh?) It seems to be the normal class)
  5. Reflection
    1. Mirrors:classmirror Methodmirror
      1. 3 main methods: Reflect Reflectclass Reflecttype
      2. Dynamic invocation: Class MethodInvoker implements Function {call
        (Methodmirror method) {
        Cl Assmirror C = Method.owner as Classmirror;
        Instancemirror Inst = c.newinstance (new Symbol ( ), []);
        Inst.invoke (Method.simplename, []);//syntax for reference to Java;
Object Creation
    1. Optional {position, name} parameter: Car ([this.color= ' W ', this.weight=1000]); /Car ({this.color: ' W ', this.weight:1000});
    2. Named construct: Car.fromiem (String Item) {...}//actually not the factory method in C + +
    3. REDIRECT Construction (inexplicably, it's not just the implementation of the constructor calling another constructor)
      1. Does dart draw on the member initialization list syntax of C + +?
    4. Private construction: Car._ ();
    5. Factory Construction: The abstract factory design pattern is actually used here
      1. abstract class Log { factory log () {return new ConsoleLog ();} ...}
    6. Constant Construction: const-Qualified, enum-class?
    7. Variables must be initialized before they are used? Type ' Null ' is not a subtype of type ' Boolean expression '.
      1. Is the assignment null?
    8. Cascading calls:. (This syntax is ugly, I can't stand it)
Asynchronous Programming
    1. Call stack vs event driver
    2. future
      1. new File (' A.txt '). Open (). then (processfile);
      2. processfile (randomaccessfile file) {file.length (). then (int len) {file.read (len). Then (ReadFile). Whencomplete ( ... ) }); }
      3. catcherror
      4. mirotask: Precedence over event is Event-loop execution
      5. deferred: New future.delayed (New Duration (seconds : 1), computation). Then (ret) =>print (ret));
    3. Zones
      1. A configurable execution context for handling asynchronous tasks and Uncaught Exceptions: runzoned (() {...}, OnError: (e) {...});
        1. zonevalues: ...
        2. zonespecification: ...
        3. overload run to track the execution of the zone:
          1. Print: (zone self, zonedelegate parent, Zone Zone, String msg) {...}, run: (Zone Self, zonedelegate Parent, Zone zone, f) = = run (parent, Zone, F, timer)//The code here is a bit hard to understand, like the difference between self and Zone?
    4. isolates: Can be thought of as a separate process (no data sharing, only message communication via replication)
      1. code slightly ... Concurrent: 24000 requests per second??
Stream Frame
    1. New File (). OpenRead (). pipe (Request.response);
    2. Single subscription vs broadcast
    3. Stream class (a bit of LINQ flavor)
      1. Verification method: Any every contains
      2. Search: Firstwhere lastwhere singlewhere
      3. Filter: Where Skip Skipwhere take Takewhere

Next (stream is nothing more than the application of inert sequences in FP)

Collection Frame
    1. The Lazy iterable (This example seems inappropriate?) )
    2. Splaytreeset? (Heck, TreeSet in Java is also implemented with splay trees)
    3. Unmodifiable collection: Not a immutable collection in Scala, just a run-time system at the API level
Dart and JavaScript interoperate
    1. With Jquery:jproxy
    2. Dart:js
      1. The example of performance testing is very lame, and I seriously doubt the true implementation of the following statement: container.appendhtml (' Test ');
Internationalization and Localization
    1. Intl Library
c/S communication
    1. Dart:io HttpClient
    2. Dart:html divelement?
    3. Ajax polling (this is a bit outdated, not directly with WebSocket?)
    4. SSE (Tooold)
    5. WebSocket (TCP-based, but using HTTP to complete the handshake)
Premium Storage
    1. Cookies
    2. Web Storage
    3. Web SQL
    4. Indexddb
supports other HTML5 features
    1. Notice
    2. Native drag and drop
    3. Geolocation
      1. Yes, why not let the user directly specify the location as input, depends on what GPS
    4. Canvas
Safety
    1. Tls
    2. CAPTCHA

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Mastering Dart (Reading notes)-The interesting part is its future, isolates and zones

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.