SlideShare uma empresa Scribd logo
1 de 13
Baixar para ler offline
Beautiful JavaScript
      Ürgo Ringo
If Java was written as JavaScript
 public class MyApp {

     public   static   void main(String[] args) {...}
     public   static   void submit(HtmlForm nativeForm) {...}
     public   static   void registerNewProductEventHandler() {...}
     public   static   void newProduct(DomEvent event) {...}
     public   static   void keyUp(HtmlInput input) {...}
     public   static   void addInitialValueStorage(HtmlObject obj)
     public   static   void handleFormChanged(HtmlRow row, DomEvent e)
     public   static   void calculatePrices(DomEvent e) {...}
     public   static   void hide(HtmlRow row) {...}
     public   static   void select(HtmlRow row) {...}
     public   static   void selectRow(HtmlRow row) {...}
     public   static   void handleSelectViewEvent(DomEvent event) {...}
     public   static   void selectView(String id) {...}
     public   static   void showViewColumns(String viewId) {...}
     public   static   void initColumnWidths(String viewId) {...}
     public   static   void setViewLinkSelected(String viewId) {...}
     public   static   boolean isEmpty(String str) {...}
     public   static   String findCurrentView() {...}
     public   static   boolean newProduct(DomEvent event) {...}

 }
If Java was written as JavaScript (2)
public static void submit(HtmlForm nativeForm) {
  String queryString = jQueryUtils.wrap(nativeForm).serialize();
  JForm form = jQueryUtils.wrap(nativeForm);
  Url url = form.attr("action");
  String viewId = findCurrentView();
  String oldId = form.attr("id");

    jQueryUtils.post(url, queryString, (data) -> {
      String id = form.find("input[name='id']").attr("value");
      boolean isNew = isEmpty(id);
      String newId = jQueryUtils.wrap(data).attr("id");
      if (isNew) {
        jQueryUtils.wrap("#" + oldId).replace(data);
        registerNewProductEventHandler();
        showViewColumns(viewId);
        registerRowEventHandlers(newId);
      }else{
        String dataWithCorrectView = jQueryUtils.wrap(data).find("div").each({
          if (jQueryUtils.wrap(nativeForm).attr("id").indexOf(viewId) > -1) {
             jQueryUtils.wrap(nativeForm).removeClass("hidden");
          }
        });
        jQueryUtils.wrap("#"+oldId).html(dataWithCorrectView);
        registerRowEventHandlers(oldId);
      }
      jQueryUtils("#"+oldId).removeClass("div_table_row_selected");
    }).error((data) -> {
      if (oldId == "form-new"){
        data.setResponseText(data.responseText.replace("form-", oldId));
      }
      jQueryUtils.wrap("#"+oldId).replace(data.getResponseText());
      registerRowEventHandlers(oldId);
      showViewColumns(viewId);
      selectRow(jQueryUtils.wrap("#" + oldId));
    });
    return false;
}
module pattern
var myModule = (function () {

 var myPrivateVar;
 // A private counter variable
 myPrivateVar = 0;
 // A private function which logs any arguments
 function myPrivateMethod(foo) {
     console.log( foo );
 };
 return {
    // A public variable
    myPublicVar: "foo",
    // A public function utilizing privates
    myPublicFunction: function(bar) {
    // Increment our private counter
    myPrivateVar++;
    // Call our private method using bar
    myPrivateMethod(bar);
    }
 };
})();


   http://addyosmani.com/resources/essentialjsdesignpatterns/book/#modulepatternjavascript
MVC frameworks
http://todomvc.com/

             What we compared
simple API
client side templating with binding
controller
ajax stubbing
see http://canjs.us/#why_canjs
food-app




https://github.com/ignite/food-app
sample Model
foodApp.Meal = can.Model({
     healthyLimit : {
         carbs : 15,
         fats : 20,
         proteins : 50
     }
}, {
     proteins : function() {
         var total = 0;
         this.products.each(function(el) {
             return total += el.proteins;
         });
         return total;
     },
     proteinsExceedHealthyLimit : function() {
         return this.proteins() > foodApp.Meal.healthyLimit.proteins;
     }
});
unit testing - jasmine
jasmine sample
describe("Meal", function() {

      it("calculates macronutrients using added products", function() {
          var meal = new foodApp.Meal();
          meal.products.push(new foodApp.Product({
               carbohydrates : 10,
               proteins : 25,
               fats : 30
          }));
          meal.products.push(new foodApp.Product({
               carbohydrates : 10,
               proteins : 25,
               fats : 30
          }));

            expect(meal.carbohydrates()).toEqual(20);
            expect(meal.proteins()).toEqual(50);
            expect(meal.fats()).toEqual(60);
      });

});
SVG vs Canvas for graphs
SVG
http://g.raphaeljs.com/
http://d3js.org/

Canvas
...
Other stuff
JSLint, JSHint

Underscore.js

CSS bootstraps
use Module pattern
use MVC framework
unit test JavaScript (e.g Jasmine)
use CSS bootstap
use JSHint, JSLint

Mais conteúdo relacionado

Mais procurados

Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent codeDror Helper
 
JavaScript Proven Practises
JavaScript Proven PractisesJavaScript Proven Practises
JavaScript Proven PractisesRobert MacLean
 
Basic Unit Testing with Mockito
Basic Unit Testing with MockitoBasic Unit Testing with Mockito
Basic Unit Testing with MockitoAlexander De Leon
 
Adventures In JavaScript Testing
Adventures In JavaScript TestingAdventures In JavaScript Testing
Adventures In JavaScript TestingThomas Fuchs
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good TestsTomek Kaczanowski
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good TestsTomek Kaczanowski
 
Mocking in Java with Mockito
Mocking in Java with MockitoMocking in Java with Mockito
Mocking in Java with MockitoRichard Paul
 
100% Code Coverage - TDD mit Java EE
100% Code Coverage - TDD mit Java EE100% Code Coverage - TDD mit Java EE
100% Code Coverage - TDD mit Java EEStefan Macke
 
Unit & Automation Testing in Android - Stanislav Gatsev, Melon
Unit & Automation Testing in Android - Stanislav Gatsev, MelonUnit & Automation Testing in Android - Stanislav Gatsev, Melon
Unit & Automation Testing in Android - Stanislav Gatsev, MelonbeITconference
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better codeDror Helper
 
Don't Make Android Bad... Again
Don't Make Android Bad... AgainDon't Make Android Bad... Again
Don't Make Android Bad... AgainPedro Vicente
 
Exercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera CymbronExercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera Cymbroncymbron
 
The Ring programming language version 1.10 book - Part 17 of 212
The Ring programming language version 1.10 book - Part 17 of 212The Ring programming language version 1.10 book - Part 17 of 212
The Ring programming language version 1.10 book - Part 17 of 212Mahmoud Samir Fayed
 
What the FUF?
What the FUF?What the FUF?
What the FUF?An Doan
 

Mais procurados (20)

Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent code
 
Mockito intro
Mockito introMockito intro
Mockito intro
 
JavaScript Proven Practises
JavaScript Proven PractisesJavaScript Proven Practises
JavaScript Proven Practises
 
Basic Unit Testing with Mockito
Basic Unit Testing with MockitoBasic Unit Testing with Mockito
Basic Unit Testing with Mockito
 
Adventures In JavaScript Testing
Adventures In JavaScript TestingAdventures In JavaScript Testing
Adventures In JavaScript Testing
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
 
Mocking in Java with Mockito
Mocking in Java with MockitoMocking in Java with Mockito
Mocking in Java with Mockito
 
100% Code Coverage - TDD mit Java EE
100% Code Coverage - TDD mit Java EE100% Code Coverage - TDD mit Java EE
100% Code Coverage - TDD mit Java EE
 
Mock your way with Mockito
Mock your way with MockitoMock your way with Mockito
Mock your way with Mockito
 
iOS Talks 6: Unit Testing
iOS Talks 6: Unit TestingiOS Talks 6: Unit Testing
iOS Talks 6: Unit Testing
 
Unit & Automation Testing in Android - Stanislav Gatsev, Melon
Unit & Automation Testing in Android - Stanislav Gatsev, MelonUnit & Automation Testing in Android - Stanislav Gatsev, Melon
Unit & Automation Testing in Android - Stanislav Gatsev, Melon
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better code
 
Don't Make Android Bad... Again
Don't Make Android Bad... AgainDon't Make Android Bad... Again
Don't Make Android Bad... Again
 
Exercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera CymbronExercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera Cymbron
 
The Ring programming language version 1.10 book - Part 17 of 212
The Ring programming language version 1.10 book - Part 17 of 212The Ring programming language version 1.10 book - Part 17 of 212
The Ring programming language version 1.10 book - Part 17 of 212
 
Magic methods
Magic methodsMagic methods
Magic methods
 
What the FUF?
What the FUF?What the FUF?
What the FUF?
 
Java
JavaJava
Java
 
PHP 5 Magic Methods
PHP 5 Magic MethodsPHP 5 Magic Methods
PHP 5 Magic Methods
 

Destaque

Žaizdų Kategorijos
Žaizdų KategorijosŽaizdų Kategorijos
Žaizdų Kategorijosurgo
 
RIA implementation patterns
RIA implementation patternsRIA implementation patterns
RIA implementation patternsÜrgo Ringo
 
Specificationby example
Specificationby exampleSpecificationby example
Specificationby exampleÜrgo Ringo
 
Small tools to improve your (agile) life
Small tools to improve your (agile) lifeSmall tools to improve your (agile) life
Small tools to improve your (agile) lifeÜrgo Ringo
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven DesignÜrgo Ringo
 
Executable specifiaction
Executable specifiactionExecutable specifiaction
Executable specifiactionÜrgo Ringo
 
Lunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and CapybaraLunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and CapybaraMarc Seeger
 
Automated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choiceAutomated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choicetoddbr
 
BDD testing with cucumber
BDD testing with cucumberBDD testing with cucumber
BDD testing with cucumberDaniel Kummer
 
Test automation with Cucumber-JVM
Test automation with Cucumber-JVMTest automation with Cucumber-JVM
Test automation with Cucumber-JVMAlan Parkinson
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Lars Thorup
 
Behavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using CucumberBehavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using CucumberKMS Technology
 
Behavior Driven Development with Cucumber
Behavior Driven Development with CucumberBehavior Driven Development with Cucumber
Behavior Driven Development with CucumberBrandon Keepers
 
Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with CucumberBen Mabey
 

Destaque (16)

Žaizdų Kategorijos
Žaizdų KategorijosŽaizdų Kategorijos
Žaizdų Kategorijos
 
RIA implementation patterns
RIA implementation patternsRIA implementation patterns
RIA implementation patterns
 
Specificationby example
Specificationby exampleSpecificationby example
Specificationby example
 
Small tools to improve your (agile) life
Small tools to improve your (agile) lifeSmall tools to improve your (agile) life
Small tools to improve your (agile) life
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Executable specifiaction
Executable specifiactionExecutable specifiaction
Executable specifiaction
 
Introduction to TDD and BDD
Introduction to TDD and BDDIntroduction to TDD and BDD
Introduction to TDD and BDD
 
Lunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and CapybaraLunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and Capybara
 
Automated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choiceAutomated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choice
 
BDD testing with cucumber
BDD testing with cucumberBDD testing with cucumber
BDD testing with cucumber
 
Test automation with Cucumber-JVM
Test automation with Cucumber-JVMTest automation with Cucumber-JVM
Test automation with Cucumber-JVM
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)
 
Behavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using CucumberBehavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using Cucumber
 
Behavior Driven Development with Cucumber
Behavior Driven Development with CucumberBehavior Driven Development with Cucumber
Behavior Driven Development with Cucumber
 
Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with Cucumber
 
8 Tips for an Awesome Powerpoint Presentation
8 Tips for an Awesome Powerpoint Presentation8 Tips for an Awesome Powerpoint Presentation
8 Tips for an Awesome Powerpoint Presentation
 

Semelhante a Beautiful java script

Swift Delhi: Practical POP
Swift Delhi: Practical POPSwift Delhi: Practical POP
Swift Delhi: Practical POPNatasha Murashev
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEDarwin Durand
 
Taming that client side mess with Backbone.js
Taming that client side mess with Backbone.jsTaming that client side mess with Backbone.js
Taming that client side mess with Backbone.jsJarod Ferguson
 
Aplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com BackboneAplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com BackboneRafael Felix da Silva
 
Practical Protocol-Oriented-Programming
Practical Protocol-Oriented-ProgrammingPractical Protocol-Oriented-Programming
Practical Protocol-Oriented-ProgrammingNatasha Murashev
 
Practialpop 160510130818
Practialpop 160510130818Practialpop 160510130818
Practialpop 160510130818Shahzain Saeed
 
MCE^3 - Natasha Murashev - Practical Protocol-Oriented Programming in Swift
MCE^3 - Natasha Murashev - Practical Protocol-Oriented Programming in SwiftMCE^3 - Natasha Murashev - Practical Protocol-Oriented Programming in Swift
MCE^3 - Natasha Murashev - Practical Protocol-Oriented Programming in SwiftPROIDEA
 
code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql JOYITAKUNDU1
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejsNick Lee
 
Android Design Patterns
Android Design PatternsAndroid Design Patterns
Android Design PatternsGodfrey Nolan
 
Roman iovlev. Test UI with JDI - Selenium camp
Roman iovlev. Test UI with JDI - Selenium campRoman iovlev. Test UI with JDI - Selenium camp
Roman iovlev. Test UI with JDI - Selenium campРоман Иовлев
 
Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React Robert DeLuca
 
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...탑크리에듀(구로디지털단지역3번출구 2분거리)
 

Semelhante a Beautiful java script (20)

Jason parsing
Jason parsingJason parsing
Jason parsing
 
Swift Delhi: Practical POP
Swift Delhi: Practical POPSwift Delhi: Practical POP
Swift Delhi: Practical POP
 
Griffon @ Svwjug
Griffon @ SvwjugGriffon @ Svwjug
Griffon @ Svwjug
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLE
 
Backbone Basics with Examples
Backbone Basics with ExamplesBackbone Basics with Examples
Backbone Basics with Examples
 
Taming that client side mess with Backbone.js
Taming that client side mess with Backbone.jsTaming that client side mess with Backbone.js
Taming that client side mess with Backbone.js
 
Aplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com BackboneAplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com Backbone
 
Practical Protocol-Oriented-Programming
Practical Protocol-Oriented-ProgrammingPractical Protocol-Oriented-Programming
Practical Protocol-Oriented-Programming
 
Practialpop 160510130818
Practialpop 160510130818Practialpop 160510130818
Practialpop 160510130818
 
MCE^3 - Natasha Murashev - Practical Protocol-Oriented Programming in Swift
MCE^3 - Natasha Murashev - Practical Protocol-Oriented Programming in SwiftMCE^3 - Natasha Murashev - Practical Protocol-Oriented Programming in Swift
MCE^3 - Natasha Murashev - Practical Protocol-Oriented Programming in Swift
 
code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql
 
Clean Javascript
Clean JavascriptClean Javascript
Clean Javascript
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
 
Speed up your GWT coding with gQuery
Speed up your GWT coding with gQuerySpeed up your GWT coding with gQuery
Speed up your GWT coding with gQuery
 
React 101
React 101React 101
React 101
 
Android Design Patterns
Android Design PatternsAndroid Design Patterns
Android Design Patterns
 
Vaadin7
Vaadin7Vaadin7
Vaadin7
 
Roman iovlev. Test UI with JDI - Selenium camp
Roman iovlev. Test UI with JDI - Selenium campRoman iovlev. Test UI with JDI - Selenium camp
Roman iovlev. Test UI with JDI - Selenium camp
 
Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React
 
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
 

Último

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
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 educationjfdjdjcjdnsjd
 
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 WorkerThousandEyes
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
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 RobisonAnna Loughnan Colquhoun
 
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 Takeoffsammart93
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 

Último (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Beautiful java script

  • 1. Beautiful JavaScript Ürgo Ringo
  • 2. If Java was written as JavaScript public class MyApp { public static void main(String[] args) {...} public static void submit(HtmlForm nativeForm) {...} public static void registerNewProductEventHandler() {...} public static void newProduct(DomEvent event) {...} public static void keyUp(HtmlInput input) {...} public static void addInitialValueStorage(HtmlObject obj) public static void handleFormChanged(HtmlRow row, DomEvent e) public static void calculatePrices(DomEvent e) {...} public static void hide(HtmlRow row) {...} public static void select(HtmlRow row) {...} public static void selectRow(HtmlRow row) {...} public static void handleSelectViewEvent(DomEvent event) {...} public static void selectView(String id) {...} public static void showViewColumns(String viewId) {...} public static void initColumnWidths(String viewId) {...} public static void setViewLinkSelected(String viewId) {...} public static boolean isEmpty(String str) {...} public static String findCurrentView() {...} public static boolean newProduct(DomEvent event) {...} }
  • 3. If Java was written as JavaScript (2) public static void submit(HtmlForm nativeForm) { String queryString = jQueryUtils.wrap(nativeForm).serialize(); JForm form = jQueryUtils.wrap(nativeForm); Url url = form.attr("action"); String viewId = findCurrentView(); String oldId = form.attr("id"); jQueryUtils.post(url, queryString, (data) -> { String id = form.find("input[name='id']").attr("value"); boolean isNew = isEmpty(id); String newId = jQueryUtils.wrap(data).attr("id"); if (isNew) { jQueryUtils.wrap("#" + oldId).replace(data); registerNewProductEventHandler(); showViewColumns(viewId); registerRowEventHandlers(newId); }else{ String dataWithCorrectView = jQueryUtils.wrap(data).find("div").each({ if (jQueryUtils.wrap(nativeForm).attr("id").indexOf(viewId) > -1) { jQueryUtils.wrap(nativeForm).removeClass("hidden"); } }); jQueryUtils.wrap("#"+oldId).html(dataWithCorrectView); registerRowEventHandlers(oldId); } jQueryUtils("#"+oldId).removeClass("div_table_row_selected"); }).error((data) -> { if (oldId == "form-new"){ data.setResponseText(data.responseText.replace("form-", oldId)); } jQueryUtils.wrap("#"+oldId).replace(data.getResponseText()); registerRowEventHandlers(oldId); showViewColumns(viewId); selectRow(jQueryUtils.wrap("#" + oldId)); }); return false; }
  • 4. module pattern var myModule = (function () { var myPrivateVar; // A private counter variable myPrivateVar = 0; // A private function which logs any arguments function myPrivateMethod(foo) { console.log( foo ); }; return { // A public variable myPublicVar: "foo", // A public function utilizing privates myPublicFunction: function(bar) { // Increment our private counter myPrivateVar++; // Call our private method using bar myPrivateMethod(bar); } }; })(); http://addyosmani.com/resources/essentialjsdesignpatterns/book/#modulepatternjavascript
  • 6. simple API client side templating with binding controller ajax stubbing see http://canjs.us/#why_canjs
  • 8. sample Model foodApp.Meal = can.Model({ healthyLimit : { carbs : 15, fats : 20, proteins : 50 } }, { proteins : function() { var total = 0; this.products.each(function(el) { return total += el.proteins; }); return total; }, proteinsExceedHealthyLimit : function() { return this.proteins() > foodApp.Meal.healthyLimit.proteins; } });
  • 9. unit testing - jasmine
  • 10. jasmine sample describe("Meal", function() { it("calculates macronutrients using added products", function() { var meal = new foodApp.Meal(); meal.products.push(new foodApp.Product({ carbohydrates : 10, proteins : 25, fats : 30 })); meal.products.push(new foodApp.Product({ carbohydrates : 10, proteins : 25, fats : 30 })); expect(meal.carbohydrates()).toEqual(20); expect(meal.proteins()).toEqual(50); expect(meal.fats()).toEqual(60); }); });
  • 11. SVG vs Canvas for graphs SVG http://g.raphaeljs.com/ http://d3js.org/ Canvas ...
  • 13. use Module pattern use MVC framework unit test JavaScript (e.g Jasmine) use CSS bootstap use JSHint, JSLint