SlideShare una empresa de Scribd logo
1 de 22
Dart

Iván Zaera Avellón
Co: izaera@gmail.com
Tw: @izaera
Table of contents
●

Language features

●

Testing

–

Data typing

–

Tests

–

Specific language constructions

–

Mocks

–

Modularity and visibility

–

Mixins

–

Arithmetic

●

More resources

Concurrency model
–

Async, Futures, Completers

–

Isolates

Development tools

–
●

–

Dart project's management

–

Libraries and APIs

–

Code example: cipher library
Introduction
Language features
Data typing
●

Optional typing

●

Dynamic keyword

●

Implicit interfaces

●

Implements and extends are interchangeable

●

Is and is! operator

●

Checked runtime mode
Specific language constructions
(1/2)
●

Cascade .. operator

●

Closures

●

One line functions (=>)

●

Optional arguments

●

Named arguments
Specific language constructions
(2/2)
●

Factory constructors

●

Named constructors

●

Initialization of fields with this. syntax

●

Getters, setters, and final

●

Const
Modularity and visibility
●

Libraries and parts

●

Visibility
–

Public

–

Library private

●

Concise private modifier: _

●

Cannot extend library private classes
Mixins
●

Orthogonal functionality

●

Used where OO is-a relation does not apply

●

Keyword: with

●

Only static mixins, not runtime (like Groovy's
metaClass, for instance)
Arithmetic
●

Base num type with double and int subtypes

●

All nums are signed

●

●
●

Integers have infinite precision (VM handles
two internal subtypes for efficiency)
Doubles are stored in IEEE format
Integers are implemented as doubles when
compiled to Javascript :-(
Concurrency model
Async, Futures, Completers
●

Async execution due to event loop (like JS)

●

Futures
–

–
●

Promise to provide a result of some computation some
time in the future
Difficult and cumbersome error handling

Completers
–

Low level construction to signal Future finalization

–

Should be used with care because makes error handling
more difficult than Futures
Isolates
●

Alternative to threads

●

Message passing paradigm
–

Shared memory not allowed

–

Use SendPort for sending messages

●

Less error prone

●

But less efficient
Testing
Tests
●

DSL: group(), test(), expect()

●

Matchers similar to Hamcrest Java library
void main() {
group( “converters:”, () {
test( "toUint32()", () {
expect( toUint32( 0x100000000 ), 0x00000000 );
expect( toUint32( -1 ), 0xFFFFFFFF );
});
});
}
Mocks
●

Mock by extending Mock class

class MockObjectory extends Mock implements Objectory {}
test( "getById() llama a Objectory.findOne() con la query correcta", () {
final id = "test_object_id";
final db = new MockObjectory();
final mockEntity = new MockEntity();
db.when( callsTo("findOne",anything) ).alwaysReturn( new Future.value(mockEntity) );
final dao = new TestObjectoryDao( "collection", db );
return dao.getById(id).then( (entity) {
var query = db.getLogs( callsTo("findOne", anything ) ).first.args[0].toString();
expect( query, equals("ObjectoryQueryBuilder(collection {_id: ObjectId(${id})})") );
});
});
More resources
Development tools
●

Dart editor
–
–

Static analyzer

–
●

Lightweight
Refactor tools

Dart Javascript compiler
–
–

●

Tree shaking
Minifying

Pub for dependency handling
Dart project's management
●

Two mailing lists:
–
–

●

misc@dartlang.org : for common questions
web@dartlang.org : for client side framework (Polymer) questions

Bugtracking
–

●

http://dartbug.com : redirects to Google Code

Version control system
–
–

●

http://github.com/...
Latest commits: https://code.google.com/p/dart/source/list

Standardization
–

ECMA is working on Dart's standard

–

http://www.ecma-international.org/memento/TC52.htm
Libraries and APIs (1/2)
●

dart:async

●

dart:chrome (client)

●

dart:collection

●

dart:core

●

dart:html (client)

●

dart:indexed_db (client)

●

dart:io (server)

●

dart:isolate

●

dart:json

●

dart:math

●

dart:mirrors

●

dart:svg (server)

●

dart:typed_data

●

dart:utf

●

dart:web_audio (client)

●

dart:web_gl (client)

●

dart:web_sql (client)
Libraries and APIs (2/2)
●

args: a library to handle command line arguments

●

crypto: a library with hash algorithms

●

fixnum: fixed size ints (32 and 64 bits)

●

intl: I18N support

●

logging: standard logging

●

meta: meta annotations library (for example: @deprecated y @override).

●

serialization: object serialization support

●

unittest: unit testing library

●

mock: mocking library for unit testing (similar to mockito)

●

matchers: matchers library for unit testing (similar to Hamcrest)
Code example: cipher library
●

Cryptography library

●

Code based on Bouncy Castle java library

●

https://github.com/izaera/cipher

Más contenido relacionado

La actualidad más candente

An Overview of the Java Programming Language
An Overview of the Java Programming LanguageAn Overview of the Java Programming Language
An Overview of the Java Programming Language
Salaam Kehinde
 
C# Starter L02-Classes and Objects
C# Starter L02-Classes and ObjectsC# Starter L02-Classes and Objects
C# Starter L02-Classes and Objects
Mohammad Shaker
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharp
hmanjarawala
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharp
Raga Vahini
 
Objective-C Survives
Objective-C SurvivesObjective-C Survives
Objective-C Survives
S Akai
 
DIDUCE: ICSE-2002 presentation
DIDUCE: ICSE-2002 presentationDIDUCE: ICSE-2002 presentation
DIDUCE: ICSE-2002 presentation
hangal
 

La actualidad más candente (19)

An Overview of the Java Programming Language
An Overview of the Java Programming LanguageAn Overview of the Java Programming Language
An Overview of the Java Programming Language
 
C# Starter L02-Classes and Objects
C# Starter L02-Classes and ObjectsC# Starter L02-Classes and Objects
C# Starter L02-Classes and Objects
 
Java Day-5
Java Day-5Java Day-5
Java Day-5
 
JavaScript Data Types
JavaScript Data TypesJavaScript Data Types
JavaScript Data Types
 
javascript objects
javascript objectsjavascript objects
javascript objects
 
JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript Objects
 
Introduction to Type Script by Sam Goldman, SmartLogic
Introduction to Type Script by Sam Goldman, SmartLogicIntroduction to Type Script by Sam Goldman, SmartLogic
Introduction to Type Script by Sam Goldman, SmartLogic
 
JavaScript Basics - GameCraft Training
JavaScript Basics - GameCraft TrainingJavaScript Basics - GameCraft Training
JavaScript Basics - GameCraft Training
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharp
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharp
 
Objective-C Survives
Objective-C SurvivesObjective-C Survives
Objective-C Survives
 
Java/Scala Lab 2016. Григорий Кравцов: Реализация и тестирование DAO слоя с н...
Java/Scala Lab 2016. Григорий Кравцов: Реализация и тестирование DAO слоя с н...Java/Scala Lab 2016. Григорий Кравцов: Реализация и тестирование DAO слоя с н...
Java/Scala Lab 2016. Григорий Кравцов: Реализация и тестирование DAO слоя с н...
 
Java
Java Java
Java
 
Session 08 - OOP with Java - continued
Session 08 - OOP with Java - continuedSession 08 - OOP with Java - continued
Session 08 - OOP with Java - continued
 
DIDUCE: ICSE-2002 presentation
DIDUCE: ICSE-2002 presentationDIDUCE: ICSE-2002 presentation
DIDUCE: ICSE-2002 presentation
 
Few simple-type-tricks in scala
Few simple-type-tricks in scalaFew simple-type-tricks in scala
Few simple-type-tricks in scala
 
JavsScript OOP
JavsScript OOPJavsScript OOP
JavsScript OOP
 
Java Advanced Features
Java Advanced FeaturesJava Advanced Features
Java Advanced Features
 

Similar a GDG Madrid - Dart Event - By Iván Zaera

JSLounge - TypeScript 소개
JSLounge - TypeScript 소개JSLounge - TypeScript 소개
JSLounge - TypeScript 소개
Reagan Hwang
 
みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」
techtalkdwango
 
第7回みゆっき☆Think 本気で学ぶ JavaScript
第7回みゆっき☆Think 本気で学ぶ JavaScript第7回みゆっき☆Think 本気で学ぶ JavaScript
第7回みゆっき☆Think 本気で学ぶ JavaScript
Takuya Fujimura
 
"Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,...
"Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,..."Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,...
"Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,...
Vladimir Ivanov
 

Similar a GDG Madrid - Dart Event - By Iván Zaera (20)

Scala for Java Developers
Scala for Java DevelopersScala for Java Developers
Scala for Java Developers
 
Mockist vs. Classicists TDD
Mockist vs. Classicists TDDMockist vs. Classicists TDD
Mockist vs. Classicists TDD
 
Awesomeness of JavaScript…almost
Awesomeness of JavaScript…almostAwesomeness of JavaScript…almost
Awesomeness of JavaScript…almost
 
JSLounge - TypeScript 소개
JSLounge - TypeScript 소개JSLounge - TypeScript 소개
JSLounge - TypeScript 소개
 
みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」
 
第7回みゆっき☆Think 本気で学ぶ JavaScript
第7回みゆっき☆Think 本気で学ぶ JavaScript第7回みゆっき☆Think 本気で学ぶ JavaScript
第7回みゆっき☆Think 本気で学ぶ JavaScript
 
C# - What's Next?
C# - What's Next?C# - What's Next?
C# - What's Next?
 
Android Development Course in HSE lecture #2
Android Development Course in HSE lecture #2Android Development Course in HSE lecture #2
Android Development Course in HSE lecture #2
 
Lightning talk: Kotlin
Lightning talk: KotlinLightning talk: Kotlin
Lightning talk: Kotlin
 
Java concurrency
Java concurrencyJava concurrency
Java concurrency
 
NLJUG University Sessie: Java Reborn, Powered by Ordina
NLJUG University Sessie: Java Reborn, Powered by OrdinaNLJUG University Sessie: Java Reborn, Powered by Ordina
NLJUG University Sessie: Java Reborn, Powered by Ordina
 
Testing in Scala. Adform Research
Testing in Scala. Adform ResearchTesting in Scala. Adform Research
Testing in Scala. Adform Research
 
Testing in Scala by Adform research
Testing in Scala by Adform researchTesting in Scala by Adform research
Testing in Scala by Adform research
 
Spark schema for free with David Szakallas
Spark schema for free with David SzakallasSpark schema for free with David Szakallas
Spark schema for free with David Szakallas
 
Module Ninja .JS
Module Ninja .JSModule Ninja .JS
Module Ninja .JS
 
Core2 Document - Java SCORE Overview.pptx.pdf
Core2 Document - Java SCORE Overview.pptx.pdfCore2 Document - Java SCORE Overview.pptx.pdf
Core2 Document - Java SCORE Overview.pptx.pdf
 
"Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,...
"Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,..."Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,...
"Formal Verification in Java" by Shura Iline, Vladimir Ivanov @ JEEConf 2013,...
 
Intro to kotlin 2018
Intro to kotlin 2018Intro to kotlin 2018
Intro to kotlin 2018
 
U-SQL Killer Scenarios: Taming the Data Science Monster with U-SQL and Big Co...
U-SQL Killer Scenarios: Taming the Data Science Monster with U-SQL and Big Co...U-SQL Killer Scenarios: Taming the Data Science Monster with U-SQL and Big Co...
U-SQL Killer Scenarios: Taming the Data Science Monster with U-SQL and Big Co...
 
Clojure intro
Clojure introClojure intro
Clojure intro
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 

GDG Madrid - Dart Event - By Iván Zaera

  • 1. Dart Iván Zaera Avellón Co: izaera@gmail.com Tw: @izaera
  • 2. Table of contents ● Language features ● Testing – Data typing – Tests – Specific language constructions – Mocks – Modularity and visibility – Mixins – Arithmetic ● More resources Concurrency model – Async, Futures, Completers – Isolates Development tools – ● – Dart project's management – Libraries and APIs – Code example: cipher library
  • 5. Data typing ● Optional typing ● Dynamic keyword ● Implicit interfaces ● Implements and extends are interchangeable ● Is and is! operator ● Checked runtime mode
  • 6. Specific language constructions (1/2) ● Cascade .. operator ● Closures ● One line functions (=>) ● Optional arguments ● Named arguments
  • 7. Specific language constructions (2/2) ● Factory constructors ● Named constructors ● Initialization of fields with this. syntax ● Getters, setters, and final ● Const
  • 8. Modularity and visibility ● Libraries and parts ● Visibility – Public – Library private ● Concise private modifier: _ ● Cannot extend library private classes
  • 9. Mixins ● Orthogonal functionality ● Used where OO is-a relation does not apply ● Keyword: with ● Only static mixins, not runtime (like Groovy's metaClass, for instance)
  • 10. Arithmetic ● Base num type with double and int subtypes ● All nums are signed ● ● ● Integers have infinite precision (VM handles two internal subtypes for efficiency) Doubles are stored in IEEE format Integers are implemented as doubles when compiled to Javascript :-(
  • 12. Async, Futures, Completers ● Async execution due to event loop (like JS) ● Futures – – ● Promise to provide a result of some computation some time in the future Difficult and cumbersome error handling Completers – Low level construction to signal Future finalization – Should be used with care because makes error handling more difficult than Futures
  • 13. Isolates ● Alternative to threads ● Message passing paradigm – Shared memory not allowed – Use SendPort for sending messages ● Less error prone ● But less efficient
  • 15. Tests ● DSL: group(), test(), expect() ● Matchers similar to Hamcrest Java library void main() { group( “converters:”, () { test( "toUint32()", () { expect( toUint32( 0x100000000 ), 0x00000000 ); expect( toUint32( -1 ), 0xFFFFFFFF ); }); }); }
  • 16. Mocks ● Mock by extending Mock class class MockObjectory extends Mock implements Objectory {} test( "getById() llama a Objectory.findOne() con la query correcta", () { final id = "test_object_id"; final db = new MockObjectory(); final mockEntity = new MockEntity(); db.when( callsTo("findOne",anything) ).alwaysReturn( new Future.value(mockEntity) ); final dao = new TestObjectoryDao( "collection", db ); return dao.getById(id).then( (entity) { var query = db.getLogs( callsTo("findOne", anything ) ).first.args[0].toString(); expect( query, equals("ObjectoryQueryBuilder(collection {_id: ObjectId(${id})})") ); }); });
  • 18. Development tools ● Dart editor – – Static analyzer – ● Lightweight Refactor tools Dart Javascript compiler – – ● Tree shaking Minifying Pub for dependency handling
  • 19. Dart project's management ● Two mailing lists: – – ● misc@dartlang.org : for common questions web@dartlang.org : for client side framework (Polymer) questions Bugtracking – ● http://dartbug.com : redirects to Google Code Version control system – – ● http://github.com/... Latest commits: https://code.google.com/p/dart/source/list Standardization – ECMA is working on Dart's standard – http://www.ecma-international.org/memento/TC52.htm
  • 20. Libraries and APIs (1/2) ● dart:async ● dart:chrome (client) ● dart:collection ● dart:core ● dart:html (client) ● dart:indexed_db (client) ● dart:io (server) ● dart:isolate ● dart:json ● dart:math ● dart:mirrors ● dart:svg (server) ● dart:typed_data ● dart:utf ● dart:web_audio (client) ● dart:web_gl (client) ● dart:web_sql (client)
  • 21. Libraries and APIs (2/2) ● args: a library to handle command line arguments ● crypto: a library with hash algorithms ● fixnum: fixed size ints (32 and 64 bits) ● intl: I18N support ● logging: standard logging ● meta: meta annotations library (for example: @deprecated y @override). ● serialization: object serialization support ● unittest: unit testing library ● mock: mocking library for unit testing (similar to mockito) ● matchers: matchers library for unit testing (similar to Hamcrest)
  • 22. Code example: cipher library ● Cryptography library ● Code based on Bouncy Castle java library ● https://github.com/izaera/cipher