SlideShare a Scribd company logo
JS Best Practices
Created by Johannes Hoppe
My Goal
Higher code qualitiy. Pragmatic solutions.
             No fancy stuff.
Know Your
 MS Tools
Visual Studio 2010/2012
JScript Editor Extensions
Resharper 7.1
JSHint
Chutzpah
Firebug / F12
Know the
 pitfalls
Implied globals
               Forgetting var

vrfo=fnto( {
 a o   ucin)
   br=1
   a   ;
};
Boolean type conversion
         To Truthy or to Falsy. That is the only question!

vre =dcmn.eEeetyd'osnteit)
a l   ouetgtlmnBI(de_o_xs';

i(l= fle {
 fe = as)
   aet"hud' w seti msae!)
   lr(solnt e e hs esg?";
}
Trailing comma
            works on my machine!

vrfo={
 a o
   br "a"
   a: br,
   bz "a"
   a: bz,
};
Return undefined
             señor developers wear mustaches




                       {
vrfo=fnto( {
 a o    ucin)
   rtr
    eun
   {
      x:"ok lk C nw"
         los ie # o!
   };
}
Associative arrays
             they don't exist

vrx=[;
a    ]
x'o' ="a"
[fo]   br;
try .. catch .. finally
                 who cares about the reason?

vrfo=fnto( {
 a o     ucin)
   ty{
    r
      dCaytf;
       orzSuf
   }cth(){
      ac e
       rtr fle
       eun as;
   }
   rtr tu;
    eun re
};
for .. in
                 use a framework

vrdt ={
 a aa
   fo "h,
   o: o"
   br "y
   a: m"
}

fr(a di dt){
 o vr  n aa
   cnoelgdt[];
   osl.o(aad)
}
for .. in
           & never touch Object.prototype

 Ojc.rttp.eAohrotig=fnto( {
  betpooyeytnteTSrn  ucin)
   rtr "o"
   eun gd;
}
Hoisting
                declare upfront all variables

vrfo="lbl;
 a o goa"

vrbr=fnto( {
 a a   ucin)
   aetfo;
   lr(o)
   vrfo="oa"
   a o   lcl;
   aetfo;
   lr(o)
};
Eval
               ... and the job is done

fnto poMnJoPre(et {
 ucin orassnasrtx)
   rtr ea(( +tx +"";
   eun vl""  et   ))
}

vrtx ='{"el":"ol"}'
a et     hlo  wrd  ;
vrjo =poMnJoPre(et;
a sn  orassnasrtx)
Eval is evil!
                Never ever!

vrtx ='fnto( {aet"akd";}('
a et   ucin)   lr(hce!) ) ;
Globals
             the mother of all antipatterns

fnto fo){
 ucin o(
   rtr "a"
   eun br;
}

cnoelgti[fo]);
osl.o(hs'o'()
Every time you clutter the global namespace,
somewhere in the world a helpless kitten dies!
Pretty Code
Coding conventions
 1.   intentation (4 spaces!)
 2.   curly braces everywhere
 3.   semicolons everywhere
 4.   constructor functions: UpperCamelCase
 5.   all other: lowerCamelCase
Globals
          reduce, minimize, delete or kill them

(ucin){"t? }(;
fnto(   wf" ))
The switch-case
         syndrome
               a functional language wants functions!

sic (oehn){
wth smtig

    cs 1
    ae :
      dFrt)
       ois(;
      bek
       ra;

    cs 2
    ae :
      dScn(;
       oeod)
      bek
       ra;

    cs 3
    ae :
      dTid)
       ohr(;
      bek
       ra;
}
Lookup tables
            avoid the switch-case syndrome

vrmtos={
 a ehd
   1 dFrt
    : ois,
   2 dScn,
    : oeod
   3 dTid
    : ohr
};
i (ehd[oehn] {
 f mtossmtig)
   mtossmtig(;
    ehd[oehn])
}
Inheritance
       favour composition over inheritance (FCoI)



“ Because inheritance exposes a subclass
to details of its parent's implementation,
  it's often said that 'inheritance breaks
              encapsulation'. ”
                                                    (Gang of Four 1995:19)
Revealing Module
            Pattern
vrmRvaigoue=fnto ( {
a yeelnMdl   ucin )

    vr_ae="oans;
    a nm  Jhne"

    fnto getns){
     ucin reig(
       cnoelg"el "+_ae;
       osl.o(Hlo    nm)
    }

    fnto staenm){
     ucin eNm(ae
       _ae=nm;
       nm  ae
    }

   rtr {
    eun
      stae stae
      eNm: eNm,
      getns getns
      reig: reig
   };
})
(;

» Documentation
Modul loaders
                 use AMD (require.js)

dfn(ts' [jur',fnto( {
eie'et, 'qey] ucin)

     rtr {
      eun
        syoehn :fnto( {aet"el!) }
        aSmtig   ucin)  lr(hlo";
     }
};
)

rqie[ts',fnto(){
eur('et] ucint
   tsyoehn(;
   .aSmtig)
};
)
Events
              Publish/Subscribe Pattern

vr$vns=${)
a eet   (};

$vnsbn(smtigapn' fnto( {
eet.id'oehnHpes, ucin)
   aet"oehn hpee!)
   lr(Smtig apnd";
};
)

$vnstigr'oehnHpes)
eet.rge(smtigapn';
TDD with Jasmine
Why Jasmine?
              similar to JSpec or RSpec,
 BDD-style    created by authors of jsUnit and Screw.Unit

              from any browser, DOM,
independent   framework or host language

              into continuous build systems
integrates
Jasmine Bootstrap
<DCYEhm>
!OTP tl
<tl
hm>
<ed
ha>
  <il>amn Se Rne<tte
   tteJsie pc unr/il>

  <ikrl"tlset he=lbjsie131jsiecs /
   ln e=syehe" rf"i/amn-../amn.s" >
  <citsc"i/amn-../amn.s>/cit
   srp r=lbjsie131jsiej"<srp>
  <citsc"i/amn-../amn-tlj"<srp>
   srp r=lbjsie131jsiehm.s>/cit

  <- icuesuc flshr..->
   !- nld ore ie ee. -
  <citsc"r/lyrj"<srp>
   srp r=scPae.s>/cit
  <citsc"r/ogj"<srp>
   srp r=scSn.s>/cit

  <- icuese flshr..->
   !- nld pc ie ee. -
  <citsc"pcSeHle.s>/cit
   srp r=se/pceprj"<srp>
  <citsc"pcPaeSe.s>/cit
   srp r=se/lyrpcj"<srp>

  <cit
   srp>

    (ucin( {
     fnto )

      vrhmRpre =nwjsieHmRpre(;
       a tleotr  e amn.tleotr)
      vrjsien =jsiegtn(;
       a amnEv  amn.eEv)

      jsien.dRpre(tleotr;
       amnEvadeotrhmRpre)
      jsien.pcitr=fnto (pc {
       amnEvseFle    ucin se)
         rtr hmRpre.pcitrse)
          eun tleotrseFle(pc;
      };

      vrcretidwnod=wno.nod
       a urnWnoOla  idwola;

      wno.nod=fnto ( {
       idwola ucin )
Output
Jsie131rvso 15561
 amn .. eiin 34593                     fnse i 008
                                        iihd n .1s

•••••

Psig5ses
 asn  pc                                 N tycth
                                          o r/ac

Pae
 lyr
  sol b al t pa aSn
   hud e be o ly  og

 we sn hsbe pue
  hn og a  en asd
   sol idct ta tesn i cretypue
    hud niae ht h  og s urnl  asd
   sol b psil t rsm
    hud e osbe o eue
 tlstecretsn i teue hsmd i afvrt
  el  h  urn og f h  sr a ae t  aoie

 #eue
  rsm
   sol trwa ecpini sn i araypaig
    hud ho n xeto f og s led lyn
Hello World
vrhlool =fnto( {
 a elWrd   ucin)
   rtr "el Wrd"
   eun Hlo ol!;
};

dsrb(hlool' fnto( {
ecie'elWrd, ucin)
  i(sy hlo,fnto( {
  t'as el' ucin)

          epc(elWrd).oqa(HloWrd";
          xethlool()tEul"el ol!)
     };
     )
};
)

jsiegtn(.xct(;
amn.eEv)eeue)

                             hint: press F12 and paste this code!
Matchers
epc()tEuly;
xetx.oqa()
epc()tB()
xetx.oey;
epc()tMthpten;
xetx.oac(atr)
epc()tBDfnd)
xetx.oeeie(;
epc()tBUdfnd)
xetx.oeneie(;
epc()tBNl(;
xetx.oeul)
epc()tBTuh(;
xetx.oerty)
epc()tBFly)
xetx.oeas(;
epc()tCnany;
xetx.ooti()
epc()tBLsTa()
xetx.oeeshny;
epc()tBGetrhny;
xetx.oeraeTa()
epc(ucin)f(;)tTrwe;
xetfnto({n)}.oho()
Own matchers
bfrEc(ucin( {
eoeahfnto )
   ti.dMthr(
   hsadaces{
      iAa:fnto ( {
       sCt ucin )
        rtr ti.culiFuf( & ti.culiLz(;
         eun hsata.slfy) & hsata.say)
      }
   };
   )
};
)

dsrb(Gril' fnto ( {
ecie'afed, ucin )
   i(i act,fnto ( {
   t's   a' ucin )
      epc(e Gril()iAa(;
      xetnw afed).sCt)
   };
   )
};
)

» Documentation
Test-Driven Development
                                     1.   Write your tests
                                     2.   Watch them fail
                                     3.   Make them pass
                                     4.   Refactor
                                     5.   Repeat


 see   Growing Object-Oriented Software, Guidedorby Tests , page 6
 see   Working Effectively with Legacy Code , page 62 many other
1. Write your test
dsrb(svFra" fnto ( {
ecie"aeomt, ucin )

     vroiia ='0 -{}-{};
     a rgnl   {}  1 2'

     i(sol rpaepaeodr" fnto ( {
     t"hud elc lchles, ucin )
        vrepce =' -B-C;
        a xetd   A   '
        vrfrae =svFra(rgnl '' '' '';
        a omtd   aeomtoiia, A, B, C)
        epc(omtd.oqa(xetd;
        xetfrae)tEulepce)
     };
     )

     i(sol ecd ijce cnet,fnto ( {
     t"hud noe netd otn" ucin )
        vrepce =' -&tbg;ETl;bg;-C;
        a xetd   A  l;&tTS&t/&t   '
        vrfrae =svFra(rgnl '' 'bTS<b' '';
        a omtd   aeomtoiia, A, <>ET/>, C)
        epc(omtd.oqa(xetd;
        xetfrae)tEulepce)
     };
     )
};
)
2. Watch them fail
vrsvFra =fnto( {
 a aeomt   ucin)
   rtr "o!;
   eun bo"
};
jsiegtn(.xct(;
 amn.eEv)eeue)

Demo
3. Make them pass
vrsvFra =fnto(x){
a aeomt   ucintt

   $agmns.ahfnto (,ie){
   (ruet)ec(ucin i tm
      i ( >0 {
       f i   )
         ie =((<i/'.etie)hm()
          tm    $'dv>)tx(tm.tl);
         tt=ttrpae""+( -1 +"" ie)
          x    x.elc({   i )  }, tm;
      }
   };
   )
   rtr tt
   eun x;
};
jsiegtn(.xct(;
 amn.eEv)eeue)

Demo
4. Refactor
fnto hmEcd(nu){
 ucin tlnoeipt
   rtr ((<i/'.etipt.tl);
   eun $'dv>)tx(nu)hm()
}

vrsvFra =fnto(x){
a aeomt   ucintt

   $ec(ruet,fnto (,ie){
   .ahagmns ucin i tm
      i ( >0 {
       f i   )
         ie =hmEcd(tm;
          tm    tlnoeie)
         tt=ttrpae""+( -1 +"" ie)
          x    x.elc({   i ) }, tm;
      }
   };
   )
   rtr tt
   eun x;
};
jsiegtn(.xct(;
 amn.eEv)eeue)

Demo
5. Repeat
fnto hmEcd(nu){
 ucin tlnoeipt
   rtr ((<i/'.etipt.tl);
   eun $'dv>)tx(nu)hm()
}

vrsvFra =fnto( {
a aeomt   ucin)

   vrag =Arypooyesiecl(ruet)
   a rs   ra.rttp.lc.alagmns;
   vrtt=ag.hf(;
   a x   rssit)

   $ec(rs fnto (,ie){
   .ahag, ucin i tm
      ie =hmEcd(tm;
      tm   tlnoeie)
      tt=ttrpae""+i+"" ie)
      x   x.elc({    }, tm;
   };
   )
   rtr tt
   eun x;
};
jsiegtn(.xct(;
 amn.eEv)eeue)

Demo
Testing HTML
        Jasmine is DOM agnostic
comes without tools to set up HTML fixtures


                                                             Definition:
                              A test fixture is a fixed state of a set of
                           objects used as a baseline for running tests.
First Solution
            in memory fixture with jQuery

dsrb(tiiljur pui' fnto ( {
ecie'rva Qey lgn, ucin )

  vrfxue
  a itr;
  bfrEc(ucin( {
  eoeahfnto )
     fxue=$'dvsm HM cd hr<dv';
     itr  (<i>oe TL oe ee/i>)
  };
  )

  i(sol d smtig,fnto ( {
  t'hud o oehn' ucin )
     fxuemPui(;
     itr.ylgn)
     epc(itr)tHvCas"eCas)
     xetfxue.oaels(nwls";
  };
  )
};
)
jsiegtn(.xct(;
amn.eEv)eeue)

            ... only works for trivial plugins!
Clumsy Solution
           directly append to/remove from DOM

dsrb(m jur pui' fnto ( {
ecie'y Qey lgn, ucin )

  bfrEc(ucin( {
  eoeahfnto )
     $'fxue)rmv(;
     (#itr'.eoe)
     $'oy)apn(<i i=fxue>TL/i>)
     (bd'.ped'dv d"itr"HM<dv';
  };
  )

  i(sol d smtig,fnto ( {
  t'hud o oehn' ucin )
     $'fxue)mPui(;
     (#itr'.ylgn)
     epc((#itr')tHvCas"eCas)
     xet$'fxue).oaels(nwls";
  };
  )
};
)
jsiegtn(.xct(;
amn.eEv)eeue)
jasmine-jquery
         custom matchers , HTML/style/JSON fixtures, event spies

dsrb(m jur pui' fnto ( {
ecie'y Qey lgn, ucin )

  bfrEc(ucin){
   eoeahfnto(
     jsiegtitrs)fxuePt=j/_amn-eojur'
      amn.eFxue(.itrsah's5jsiedm_qey;
     jsiegtitrs)la(jur.ylgnse.tl)
      amn.eFxue(.od'qeymPui.pchm';
  };
   )

  i(sol d smtig,fnto( {
   t'hud o oehn' ucin)

       vr$i =$'hlool'.ylgn)
        a dv (#elWrd)mPui(;
       epc(dv.oaels(nwls";
        xet$i)tHvCas"eCas)
  };
   )
};
)
jsiegtn(.xct(;
amn.eEv)eeue)

Demo
TDD → BDD
Spies
                           test behaviour

dsrb(Gril' fnto ( {
ecie'afed, ucin )
  dsrb(we tl t b nc' fnto( {
   ecie'hn od o e ie, ucin)

       vrgril;
        a afed
       bfrEc(ucin){
        eoeahfnto(
          gril =nwGril(;
           afed  e afed)
          syngril,'oordenEtiz'.nClTruh)
           pO(afed gTFigAdaPza)adalhog(;
       };
        )

       i(sol ase wt o' fnto( {
        t'hud nwr ih k, ucin)
          vrase =gril.eie)
           a nwr  afedbNc(;
          epc(nwr.oqa(o";
           xetase)tEul"k)
       };
        )

       i(sol selpza,fnto ( {
        t'hud ta iz' ucin )
          gril.eie)
           afedbNc(;
          epc(afedgTFigAdaPza.oaeenald)
           xetgril.oordenEtiz)tHvBeCle(;
       };
        )
   };
    )
};
)
jsiegtn(.xct(;
amn.eEv)eeue)


                                 A spy can stub any function and tracks calls to it and all arguments.



Demo
Danke!

More Related Content

What's hot

How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...
How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...
How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...
Ari Lerner
 
Proxy OOP Pattern in PHP
Proxy OOP Pattern in PHPProxy OOP Pattern in PHP
Proxy OOP Pattern in PHP
Marco Pivetta
 
Javascript fundamentals for php developers
Javascript fundamentals for php developersJavascript fundamentals for php developers
Javascript fundamentals for php developers
Chris Ramakers
 
Executable documentation
Executable documentationExecutable documentation
Executable documentation
Russell Gold
 
Unit testing with PHPUnit
Unit testing with PHPUnitUnit testing with PHPUnit
Unit testing with PHPUnit
ferca_sl
 
Lisp
LispLisp
Lisp
Sam Lee
 
Something about Golang
Something about GolangSomething about Golang
Something about Golang
Anton Arhipov
 
Testing for Unicorns
Testing for UnicornsTesting for Unicorns
Testing for Unicorns
Alex Soto
 
Потоки в перле изнутри
Потоки в перле изнутриПотоки в перле изнутри
Потоки в перле изнутри
Ilya Zelenchuk
 
Hidden Gems of Ruby 1.9
Hidden Gems of Ruby 1.9Hidden Gems of Ruby 1.9
Hidden Gems of Ruby 1.9
Aaron Patterson
 
What is recursion?
What is recursion? What is recursion?
What is recursion?
AnuragSrivastava272
 
Start Writing Groovy
Start Writing GroovyStart Writing Groovy
Start Writing Groovy
Evgeny Goldin
 
start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()
Kiwamu Okabe
 
A Prettier Printer
A Prettier PrinterA Prettier Printer
A Prettier Printer
jlongster2
 
Awesomely descriptive JavaScript with monads
Awesomely descriptive JavaScript with monadsAwesomely descriptive JavaScript with monads
Awesomely descriptive JavaScript with monads
Michal Nowak
 
AngularJS Testing
AngularJS TestingAngularJS Testing
AngularJS Testing
Eyal Vardi
 
Sbaw091006
Sbaw091006Sbaw091006
Sbaw091006
Atsushi Tadokoro
 
Os Practical Assignment 1
Os Practical Assignment 1Os Practical Assignment 1
Os Practical Assignment 1
Emmanuel Garcia
 
Usp
UspUsp
The Ring programming language version 1.3 book - Part 17 of 88
The Ring programming language version 1.3 book - Part 17 of 88The Ring programming language version 1.3 book - Part 17 of 88
The Ring programming language version 1.3 book - Part 17 of 88
Mahmoud Samir Fayed
 

What's hot (20)

How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...
How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...
How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...
 
Proxy OOP Pattern in PHP
Proxy OOP Pattern in PHPProxy OOP Pattern in PHP
Proxy OOP Pattern in PHP
 
Javascript fundamentals for php developers
Javascript fundamentals for php developersJavascript fundamentals for php developers
Javascript fundamentals for php developers
 
Executable documentation
Executable documentationExecutable documentation
Executable documentation
 
Unit testing with PHPUnit
Unit testing with PHPUnitUnit testing with PHPUnit
Unit testing with PHPUnit
 
Lisp
LispLisp
Lisp
 
Something about Golang
Something about GolangSomething about Golang
Something about Golang
 
Testing for Unicorns
Testing for UnicornsTesting for Unicorns
Testing for Unicorns
 
Потоки в перле изнутри
Потоки в перле изнутриПотоки в перле изнутри
Потоки в перле изнутри
 
Hidden Gems of Ruby 1.9
Hidden Gems of Ruby 1.9Hidden Gems of Ruby 1.9
Hidden Gems of Ruby 1.9
 
What is recursion?
What is recursion? What is recursion?
What is recursion?
 
Start Writing Groovy
Start Writing GroovyStart Writing Groovy
Start Writing Groovy
 
start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()
 
A Prettier Printer
A Prettier PrinterA Prettier Printer
A Prettier Printer
 
Awesomely descriptive JavaScript with monads
Awesomely descriptive JavaScript with monadsAwesomely descriptive JavaScript with monads
Awesomely descriptive JavaScript with monads
 
AngularJS Testing
AngularJS TestingAngularJS Testing
AngularJS Testing
 
Sbaw091006
Sbaw091006Sbaw091006
Sbaw091006
 
Os Practical Assignment 1
Os Practical Assignment 1Os Practical Assignment 1
Os Practical Assignment 1
 
Usp
UspUsp
Usp
 
The Ring programming language version 1.3 book - Part 17 of 88
The Ring programming language version 1.3 book - Part 17 of 88The Ring programming language version 1.3 book - Part 17 of 88
The Ring programming language version 1.3 book - Part 17 of 88
 

Viewers also liked

Javascript best practices
Javascript best practicesJavascript best practices
Javascript best practices
Manav Gupta
 
Java Script Best Practices
Java Script Best PracticesJava Script Best Practices
Java Script Best Practices
Enrique Juan de Dios
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
Ankit Rastogi
 
Functional Programming with JavaScript
Functional Programming with JavaScriptFunctional Programming with JavaScript
Functional Programming with JavaScript
WebF
 
Predictive Modelling
Predictive ModellingPredictive Modelling
Predictive Modelling
Rajib Kumar De
 
Javascript Best Practices
Javascript Best PracticesJavascript Best Practices
Javascript Best Practices
Christian Heilmann
 

Viewers also liked (6)

Javascript best practices
Javascript best practicesJavascript best practices
Javascript best practices
 
Java Script Best Practices
Java Script Best PracticesJava Script Best Practices
Java Script Best Practices
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
 
Functional Programming with JavaScript
Functional Programming with JavaScriptFunctional Programming with JavaScript
Functional Programming with JavaScript
 
Predictive Modelling
Predictive ModellingPredictive Modelling
Predictive Modelling
 
Javascript Best Practices
Javascript Best PracticesJavascript Best Practices
Javascript Best Practices
 

Similar to 2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices

Creating windows store java script apps
Creating windows store java script appsCreating windows store java script apps
Creating windows store java script apps
Eugene Zharkov
 
Presenting Seq for Node.js
Presenting Seq for Node.jsPresenting Seq for Node.js
Presenting Seq for Node.js
Douglas Muth
 
JavaScript Design Patterns
JavaScript Design PatternsJavaScript Design Patterns
JavaScript Design Patterns
Derek Brown
 
SecureSocial - Authentication for Play Framework
SecureSocial - Authentication for Play FrameworkSecureSocial - Authentication for Play Framework
SecureSocial - Authentication for Play Framework
jaliss
 
A Backbone.js Tutorial for the Impatient - Part 1
A Backbone.js Tutorial for the Impatient - Part 1A Backbone.js Tutorial for the Impatient - Part 1
A Backbone.js Tutorial for the Impatient - Part 1
jsalonen Salonen
 
Building modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and javaBuilding modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and java
Alexander Gyoshev
 
nescala 2013
nescala 2013nescala 2013
nescala 2013
Hung Lin
 
Build a compiler in 2hrs - NCrafts Paris 2015
Build a compiler in 2hrs -  NCrafts Paris 2015Build a compiler in 2hrs -  NCrafts Paris 2015
Build a compiler in 2hrs - NCrafts Paris 2015
Phillip Trelford
 
Automated tests - facts and myths
Automated tests - facts and mythsAutomated tests - facts and myths
Automated tests - facts and myths
Wojciech Sznapka
 
PhpUnit Best Practices
PhpUnit Best PracticesPhpUnit Best Practices
PhpUnit Best Practices
Edorian
 
Music as data
Music as dataMusic as data
Music as data
John Vlachoyiannis
 
Refactoring to symfony components
Refactoring to symfony componentsRefactoring to symfony components
Refactoring to symfony components
Michael Peacock
 
Rust concurrency tutorial 2015 12-02
Rust concurrency tutorial 2015 12-02Rust concurrency tutorial 2015 12-02
Rust concurrency tutorial 2015 12-02
nikomatsakis
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
Pavlo Baron
 
Ff to-fp
Ff to-fpFf to-fp
Ff to-fp
Andy Petrella
 
Learn Frontend Testing
Learn Frontend TestingLearn Frontend Testing
Learn Frontend Testing
Ryan Roemer
 
Python and rust 2018 pythonkorea jihun
Python and rust 2018 pythonkorea jihunPython and rust 2018 pythonkorea jihun
Python and rust 2018 pythonkorea jihun
JIHUN KIM
 
Clojurescript up and running
Clojurescript up and runningClojurescript up and running
Clojurescript up and running
Timo Sulg
 
Clojure made simple - Lightning talk
Clojure made simple - Lightning talkClojure made simple - Lightning talk
Clojure made simple - Lightning talk
John Stevenson
 
Theme Development and Customization
Theme Development and CustomizationTheme Development and Customization
Theme Development and Customization
Aniket Pant
 

Similar to 2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices (20)

Creating windows store java script apps
Creating windows store java script appsCreating windows store java script apps
Creating windows store java script apps
 
Presenting Seq for Node.js
Presenting Seq for Node.jsPresenting Seq for Node.js
Presenting Seq for Node.js
 
JavaScript Design Patterns
JavaScript Design PatternsJavaScript Design Patterns
JavaScript Design Patterns
 
SecureSocial - Authentication for Play Framework
SecureSocial - Authentication for Play FrameworkSecureSocial - Authentication for Play Framework
SecureSocial - Authentication for Play Framework
 
A Backbone.js Tutorial for the Impatient - Part 1
A Backbone.js Tutorial for the Impatient - Part 1A Backbone.js Tutorial for the Impatient - Part 1
A Backbone.js Tutorial for the Impatient - Part 1
 
Building modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and javaBuilding modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and java
 
nescala 2013
nescala 2013nescala 2013
nescala 2013
 
Build a compiler in 2hrs - NCrafts Paris 2015
Build a compiler in 2hrs -  NCrafts Paris 2015Build a compiler in 2hrs -  NCrafts Paris 2015
Build a compiler in 2hrs - NCrafts Paris 2015
 
Automated tests - facts and myths
Automated tests - facts and mythsAutomated tests - facts and myths
Automated tests - facts and myths
 
PhpUnit Best Practices
PhpUnit Best PracticesPhpUnit Best Practices
PhpUnit Best Practices
 
Music as data
Music as dataMusic as data
Music as data
 
Refactoring to symfony components
Refactoring to symfony componentsRefactoring to symfony components
Refactoring to symfony components
 
Rust concurrency tutorial 2015 12-02
Rust concurrency tutorial 2015 12-02Rust concurrency tutorial 2015 12-02
Rust concurrency tutorial 2015 12-02
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
 
Ff to-fp
Ff to-fpFf to-fp
Ff to-fp
 
Learn Frontend Testing
Learn Frontend TestingLearn Frontend Testing
Learn Frontend Testing
 
Python and rust 2018 pythonkorea jihun
Python and rust 2018 pythonkorea jihunPython and rust 2018 pythonkorea jihun
Python and rust 2018 pythonkorea jihun
 
Clojurescript up and running
Clojurescript up and runningClojurescript up and running
Clojurescript up and running
 
Clojure made simple - Lightning talk
Clojure made simple - Lightning talkClojure made simple - Lightning talk
Clojure made simple - Lightning talk
 
Theme Development and Customization
Theme Development and CustomizationTheme Development and Customization
Theme Development and Customization
 

More from Johannes Hoppe

2017 - NoSQL Vorlesung Mosbach
2017 - NoSQL Vorlesung Mosbach2017 - NoSQL Vorlesung Mosbach
2017 - NoSQL Vorlesung Mosbach
Johannes Hoppe
 
NoSQL - Hands on
NoSQL - Hands onNoSQL - Hands on
NoSQL - Hands on
Johannes Hoppe
 
Einführung in Angular 2
Einführung in Angular 2Einführung in Angular 2
Einführung in Angular 2
Johannes Hoppe
 
MDC kompakt 2014: Hybride Apps mit Cordova, AngularJS und Ionic
MDC kompakt 2014: Hybride Apps mit Cordova, AngularJS und IonicMDC kompakt 2014: Hybride Apps mit Cordova, AngularJS und Ionic
MDC kompakt 2014: Hybride Apps mit Cordova, AngularJS und Ionic
Johannes Hoppe
 
2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach
Johannes Hoppe
 
2012-06-25 - MapReduce auf Azure
2012-06-25 - MapReduce auf Azure2012-06-25 - MapReduce auf Azure
2012-06-25 - MapReduce auf Azure
Johannes Hoppe
 
2013-06-25 - HTML5 & JavaScript Security
2013-06-25 - HTML5 & JavaScript Security2013-06-25 - HTML5 & JavaScript Security
2013-06-25 - HTML5 & JavaScript Security
Johannes Hoppe
 
2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript
Johannes Hoppe
 
2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript
Johannes Hoppe
 
2013 05-03 - HTML5 & JavaScript Security
2013 05-03 -  HTML5 & JavaScript Security2013 05-03 -  HTML5 & JavaScript Security
2013 05-03 - HTML5 & JavaScript Security
Johannes Hoppe
 
2013-03-23 - NoSQL Spartakiade
2013-03-23 - NoSQL Spartakiade2013-03-23 - NoSQL Spartakiade
2013-03-23 - NoSQL Spartakiade
Johannes Hoppe
 
2013 02-26 - Software Tests with Mongo db
2013 02-26 - Software Tests with Mongo db2013 02-26 - Software Tests with Mongo db
2013 02-26 - Software Tests with Mongo db
Johannes Hoppe
 
2012-10-16 - WebTechCon 2012: HTML5 & WebGL
2012-10-16 - WebTechCon 2012: HTML5 & WebGL2012-10-16 - WebTechCon 2012: HTML5 & WebGL
2012-10-16 - WebTechCon 2012: HTML5 & WebGLJohannes Hoppe
 
2012-10-12 - NoSQL in .NET - mit Redis und Mongodb
2012-10-12 - NoSQL in .NET - mit Redis und Mongodb2012-10-12 - NoSQL in .NET - mit Redis und Mongodb
2012-10-12 - NoSQL in .NET - mit Redis und MongodbJohannes Hoppe
 
2012-09-18 - HTML5 & WebGL
2012-09-18 - HTML5 & WebGL2012-09-18 - HTML5 & WebGL
2012-09-18 - HTML5 & WebGL
Johannes Hoppe
 
2012-09-17 - WDC12: Node.js & MongoDB
2012-09-17 - WDC12: Node.js & MongoDB2012-09-17 - WDC12: Node.js & MongoDB
2012-09-17 - WDC12: Node.js & MongoDB
Johannes Hoppe
 
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
Johannes Hoppe
 
2012-05-14 NoSQL in .NET - mit Redis und MongoDB
2012-05-14 NoSQL in .NET - mit Redis und MongoDB2012-05-14 NoSQL in .NET - mit Redis und MongoDB
2012-05-14 NoSQL in .NET - mit Redis und MongoDB
Johannes Hoppe
 
2012-05-10 - UG Karlsruhe: NoSQL in .NET - mit Redis und MongoDB
2012-05-10 - UG Karlsruhe: NoSQL in .NET - mit Redis und MongoDB2012-05-10 - UG Karlsruhe: NoSQL in .NET - mit Redis und MongoDB
2012-05-10 - UG Karlsruhe: NoSQL in .NET - mit Redis und MongoDBJohannes Hoppe
 
2012-04-12 - AOP .NET UserGroup Niederrhein
2012-04-12 - AOP .NET UserGroup Niederrhein2012-04-12 - AOP .NET UserGroup Niederrhein
2012-04-12 - AOP .NET UserGroup Niederrhein
Johannes Hoppe
 

More from Johannes Hoppe (20)

2017 - NoSQL Vorlesung Mosbach
2017 - NoSQL Vorlesung Mosbach2017 - NoSQL Vorlesung Mosbach
2017 - NoSQL Vorlesung Mosbach
 
NoSQL - Hands on
NoSQL - Hands onNoSQL - Hands on
NoSQL - Hands on
 
Einführung in Angular 2
Einführung in Angular 2Einführung in Angular 2
Einführung in Angular 2
 
MDC kompakt 2014: Hybride Apps mit Cordova, AngularJS und Ionic
MDC kompakt 2014: Hybride Apps mit Cordova, AngularJS und IonicMDC kompakt 2014: Hybride Apps mit Cordova, AngularJS und Ionic
MDC kompakt 2014: Hybride Apps mit Cordova, AngularJS und Ionic
 
2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach
 
2012-06-25 - MapReduce auf Azure
2012-06-25 - MapReduce auf Azure2012-06-25 - MapReduce auf Azure
2012-06-25 - MapReduce auf Azure
 
2013-06-25 - HTML5 & JavaScript Security
2013-06-25 - HTML5 & JavaScript Security2013-06-25 - HTML5 & JavaScript Security
2013-06-25 - HTML5 & JavaScript Security
 
2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript
 
2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript
 
2013 05-03 - HTML5 & JavaScript Security
2013 05-03 -  HTML5 & JavaScript Security2013 05-03 -  HTML5 & JavaScript Security
2013 05-03 - HTML5 & JavaScript Security
 
2013-03-23 - NoSQL Spartakiade
2013-03-23 - NoSQL Spartakiade2013-03-23 - NoSQL Spartakiade
2013-03-23 - NoSQL Spartakiade
 
2013 02-26 - Software Tests with Mongo db
2013 02-26 - Software Tests with Mongo db2013 02-26 - Software Tests with Mongo db
2013 02-26 - Software Tests with Mongo db
 
2012-10-16 - WebTechCon 2012: HTML5 & WebGL
2012-10-16 - WebTechCon 2012: HTML5 & WebGL2012-10-16 - WebTechCon 2012: HTML5 & WebGL
2012-10-16 - WebTechCon 2012: HTML5 & WebGL
 
2012-10-12 - NoSQL in .NET - mit Redis und Mongodb
2012-10-12 - NoSQL in .NET - mit Redis und Mongodb2012-10-12 - NoSQL in .NET - mit Redis und Mongodb
2012-10-12 - NoSQL in .NET - mit Redis und Mongodb
 
2012-09-18 - HTML5 & WebGL
2012-09-18 - HTML5 & WebGL2012-09-18 - HTML5 & WebGL
2012-09-18 - HTML5 & WebGL
 
2012-09-17 - WDC12: Node.js & MongoDB
2012-09-17 - WDC12: Node.js & MongoDB2012-09-17 - WDC12: Node.js & MongoDB
2012-09-17 - WDC12: Node.js & MongoDB
 
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
 
2012-05-14 NoSQL in .NET - mit Redis und MongoDB
2012-05-14 NoSQL in .NET - mit Redis und MongoDB2012-05-14 NoSQL in .NET - mit Redis und MongoDB
2012-05-14 NoSQL in .NET - mit Redis und MongoDB
 
2012-05-10 - UG Karlsruhe: NoSQL in .NET - mit Redis und MongoDB
2012-05-10 - UG Karlsruhe: NoSQL in .NET - mit Redis und MongoDB2012-05-10 - UG Karlsruhe: NoSQL in .NET - mit Redis und MongoDB
2012-05-10 - UG Karlsruhe: NoSQL in .NET - mit Redis und MongoDB
 
2012-04-12 - AOP .NET UserGroup Niederrhein
2012-04-12 - AOP .NET UserGroup Niederrhein2012-04-12 - AOP .NET UserGroup Niederrhein
2012-04-12 - AOP .NET UserGroup Niederrhein
 

Recently uploaded

GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Zilliz
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
TIPNGVN2
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Zilliz
 

Recently uploaded (20)

GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
 

2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices

  • 1. JS Best Practices Created by Johannes Hoppe
  • 2. My Goal Higher code qualitiy. Pragmatic solutions. No fancy stuff.
  • 3. Know Your MS Tools
  • 4. Visual Studio 2010/2012 JScript Editor Extensions Resharper 7.1 JSHint Chutzpah Firebug / F12
  • 6. Implied globals Forgetting var vrfo=fnto( { a o ucin) br=1 a ; };
  • 7. Boolean type conversion To Truthy or to Falsy. That is the only question! vre =dcmn.eEeetyd'osnteit) a l ouetgtlmnBI(de_o_xs'; i(l= fle { fe = as) aet"hud' w seti msae!) lr(solnt e e hs esg?"; }
  • 8. Trailing comma works on my machine! vrfo={ a o br "a" a: br, bz "a" a: bz, };
  • 9. Return undefined señor developers wear mustaches { vrfo=fnto( { a o ucin) rtr eun { x:"ok lk C nw" los ie # o! }; }
  • 10. Associative arrays they don't exist vrx=[; a ] x'o' ="a" [fo] br;
  • 11. try .. catch .. finally who cares about the reason? vrfo=fnto( { a o ucin) ty{ r dCaytf; orzSuf }cth(){ ac e rtr fle eun as; } rtr tu; eun re };
  • 12. for .. in use a framework vrdt ={ a aa fo "h, o: o" br "y a: m" } fr(a di dt){ o vr n aa cnoelgdt[]; osl.o(aad) }
  • 13. for .. in & never touch Object.prototype Ojc.rttp.eAohrotig=fnto( { betpooyeytnteTSrn ucin) rtr "o" eun gd; }
  • 14. Hoisting declare upfront all variables vrfo="lbl; a o goa" vrbr=fnto( { a a ucin) aetfo; lr(o) vrfo="oa" a o lcl; aetfo; lr(o) };
  • 15. Eval ... and the job is done fnto poMnJoPre(et { ucin orassnasrtx) rtr ea(( +tx +""; eun vl"" et )) } vrtx ='{"el":"ol"}' a et hlo wrd ; vrjo =poMnJoPre(et; a sn orassnasrtx)
  • 16. Eval is evil! Never ever! vrtx ='fnto( {aet"akd";}(' a et ucin) lr(hce!) ) ;
  • 17. Globals the mother of all antipatterns fnto fo){ ucin o( rtr "a" eun br; } cnoelgti[fo]); osl.o(hs'o'()
  • 18. Every time you clutter the global namespace, somewhere in the world a helpless kitten dies!
  • 20. Coding conventions 1. intentation (4 spaces!) 2. curly braces everywhere 3. semicolons everywhere 4. constructor functions: UpperCamelCase 5. all other: lowerCamelCase
  • 21. Globals reduce, minimize, delete or kill them (ucin){"t? }(; fnto( wf" ))
  • 22. The switch-case syndrome a functional language wants functions! sic (oehn){ wth smtig cs 1 ae : dFrt) ois(; bek ra; cs 2 ae : dScn(; oeod) bek ra; cs 3 ae : dTid) ohr(; bek ra; }
  • 23. Lookup tables avoid the switch-case syndrome vrmtos={ a ehd 1 dFrt : ois, 2 dScn, : oeod 3 dTid : ohr }; i (ehd[oehn] { f mtossmtig) mtossmtig(; ehd[oehn]) }
  • 24. Inheritance favour composition over inheritance (FCoI) “ Because inheritance exposes a subclass to details of its parent's implementation, it's often said that 'inheritance breaks encapsulation'. ” (Gang of Four 1995:19)
  • 25. Revealing Module Pattern vrmRvaigoue=fnto ( { a yeelnMdl ucin ) vr_ae="oans; a nm Jhne" fnto getns){ ucin reig( cnoelg"el "+_ae; osl.o(Hlo nm) } fnto staenm){ ucin eNm(ae _ae=nm; nm ae } rtr { eun stae stae eNm: eNm, getns getns reig: reig }; }) (; » Documentation
  • 26. Modul loaders use AMD (require.js) dfn(ts' [jur',fnto( { eie'et, 'qey] ucin) rtr { eun syoehn :fnto( {aet"el!) } aSmtig ucin) lr(hlo"; } }; ) rqie[ts',fnto(){ eur('et] ucint tsyoehn(; .aSmtig) }; )
  • 27. Events Publish/Subscribe Pattern vr$vns=${) a eet (}; $vnsbn(smtigapn' fnto( { eet.id'oehnHpes, ucin) aet"oehn hpee!) lr(Smtig apnd"; }; ) $vnstigr'oehnHpes) eet.rge(smtigapn';
  • 29. Why Jasmine? similar to JSpec or RSpec, BDD-style created by authors of jsUnit and Screw.Unit from any browser, DOM, independent framework or host language into continuous build systems integrates
  • 30. Jasmine Bootstrap <DCYEhm> !OTP tl <tl hm> <ed ha> <il>amn Se Rne<tte tteJsie pc unr/il> <ikrl"tlset he=lbjsie131jsiecs / ln e=syehe" rf"i/amn-../amn.s" > <citsc"i/amn-../amn.s>/cit srp r=lbjsie131jsiej"<srp> <citsc"i/amn-../amn-tlj"<srp> srp r=lbjsie131jsiehm.s>/cit <- icuesuc flshr..-> !- nld ore ie ee. - <citsc"r/lyrj"<srp> srp r=scPae.s>/cit <citsc"r/ogj"<srp> srp r=scSn.s>/cit <- icuese flshr..-> !- nld pc ie ee. - <citsc"pcSeHle.s>/cit srp r=se/pceprj"<srp> <citsc"pcPaeSe.s>/cit srp r=se/lyrpcj"<srp> <cit srp> (ucin( { fnto ) vrhmRpre =nwjsieHmRpre(; a tleotr e amn.tleotr) vrjsien =jsiegtn(; a amnEv amn.eEv) jsien.dRpre(tleotr; amnEvadeotrhmRpre) jsien.pcitr=fnto (pc { amnEvseFle ucin se) rtr hmRpre.pcitrse) eun tleotrseFle(pc; }; vrcretidwnod=wno.nod a urnWnoOla idwola; wno.nod=fnto ( { idwola ucin )
  • 31. Output Jsie131rvso 15561 amn .. eiin 34593 fnse i 008 iihd n .1s ••••• Psig5ses asn pc N tycth o r/ac Pae lyr sol b al t pa aSn hud e be o ly og we sn hsbe pue hn og a en asd sol idct ta tesn i cretypue hud niae ht h og s urnl asd sol b psil t rsm hud e osbe o eue tlstecretsn i teue hsmd i afvrt el h urn og f h sr a ae t aoie #eue rsm sol trwa ecpini sn i araypaig hud ho n xeto f og s led lyn
  • 32. Hello World vrhlool =fnto( { a elWrd ucin) rtr "el Wrd" eun Hlo ol!; }; dsrb(hlool' fnto( { ecie'elWrd, ucin) i(sy hlo,fnto( { t'as el' ucin) epc(elWrd).oqa(HloWrd"; xethlool()tEul"el ol!) }; ) }; ) jsiegtn(.xct(; amn.eEv)eeue) hint: press F12 and paste this code!
  • 34. Own matchers bfrEc(ucin( { eoeahfnto ) ti.dMthr( hsadaces{ iAa:fnto ( { sCt ucin ) rtr ti.culiFuf( & ti.culiLz(; eun hsata.slfy) & hsata.say) } }; ) }; ) dsrb(Gril' fnto ( { ecie'afed, ucin ) i(i act,fnto ( { t's a' ucin ) epc(e Gril()iAa(; xetnw afed).sCt) }; ) }; ) » Documentation
  • 35. Test-Driven Development 1. Write your tests 2. Watch them fail 3. Make them pass 4. Refactor 5. Repeat see Growing Object-Oriented Software, Guidedorby Tests , page 6 see Working Effectively with Legacy Code , page 62 many other
  • 36. 1. Write your test dsrb(svFra" fnto ( { ecie"aeomt, ucin ) vroiia ='0 -{}-{}; a rgnl {} 1 2' i(sol rpaepaeodr" fnto ( { t"hud elc lchles, ucin ) vrepce =' -B-C; a xetd A ' vrfrae =svFra(rgnl '' '' ''; a omtd aeomtoiia, A, B, C) epc(omtd.oqa(xetd; xetfrae)tEulepce) }; ) i(sol ecd ijce cnet,fnto ( { t"hud noe netd otn" ucin ) vrepce =' -&tbg;ETl;bg;-C; a xetd A l;&tTS&t/&t ' vrfrae =svFra(rgnl '' 'bTS<b' ''; a omtd aeomtoiia, A, <>ET/>, C) epc(omtd.oqa(xetd; xetfrae)tEulepce) }; ) }; )
  • 37. 2. Watch them fail vrsvFra =fnto( { a aeomt ucin) rtr "o!; eun bo" }; jsiegtn(.xct(; amn.eEv)eeue) Demo
  • 38. 3. Make them pass vrsvFra =fnto(x){ a aeomt ucintt $agmns.ahfnto (,ie){ (ruet)ec(ucin i tm i ( >0 { f i ) ie =((<i/'.etie)hm() tm $'dv>)tx(tm.tl); tt=ttrpae""+( -1 +"" ie) x x.elc({ i ) }, tm; } }; ) rtr tt eun x; }; jsiegtn(.xct(; amn.eEv)eeue) Demo
  • 39. 4. Refactor fnto hmEcd(nu){ ucin tlnoeipt rtr ((<i/'.etipt.tl); eun $'dv>)tx(nu)hm() } vrsvFra =fnto(x){ a aeomt ucintt $ec(ruet,fnto (,ie){ .ahagmns ucin i tm i ( >0 { f i ) ie =hmEcd(tm; tm tlnoeie) tt=ttrpae""+( -1 +"" ie) x x.elc({ i ) }, tm; } }; ) rtr tt eun x; }; jsiegtn(.xct(; amn.eEv)eeue) Demo
  • 40. 5. Repeat fnto hmEcd(nu){ ucin tlnoeipt rtr ((<i/'.etipt.tl); eun $'dv>)tx(nu)hm() } vrsvFra =fnto( { a aeomt ucin) vrag =Arypooyesiecl(ruet) a rs ra.rttp.lc.alagmns; vrtt=ag.hf(; a x rssit) $ec(rs fnto (,ie){ .ahag, ucin i tm ie =hmEcd(tm; tm tlnoeie) tt=ttrpae""+i+"" ie) x x.elc({ }, tm; }; ) rtr tt eun x; }; jsiegtn(.xct(; amn.eEv)eeue) Demo
  • 41. Testing HTML Jasmine is DOM agnostic comes without tools to set up HTML fixtures Definition: A test fixture is a fixed state of a set of objects used as a baseline for running tests.
  • 42. First Solution in memory fixture with jQuery dsrb(tiiljur pui' fnto ( { ecie'rva Qey lgn, ucin ) vrfxue a itr; bfrEc(ucin( { eoeahfnto ) fxue=$'dvsm HM cd hr<dv'; itr (<i>oe TL oe ee/i>) }; ) i(sol d smtig,fnto ( { t'hud o oehn' ucin ) fxuemPui(; itr.ylgn) epc(itr)tHvCas"eCas) xetfxue.oaels(nwls"; }; ) }; ) jsiegtn(.xct(; amn.eEv)eeue) ... only works for trivial plugins!
  • 43. Clumsy Solution directly append to/remove from DOM dsrb(m jur pui' fnto ( { ecie'y Qey lgn, ucin ) bfrEc(ucin( { eoeahfnto ) $'fxue)rmv(; (#itr'.eoe) $'oy)apn(<i i=fxue>TL/i>) (bd'.ped'dv d"itr"HM<dv'; }; ) i(sol d smtig,fnto ( { t'hud o oehn' ucin ) $'fxue)mPui(; (#itr'.ylgn) epc((#itr')tHvCas"eCas) xet$'fxue).oaels(nwls"; }; ) }; ) jsiegtn(.xct(; amn.eEv)eeue)
  • 44. jasmine-jquery custom matchers , HTML/style/JSON fixtures, event spies dsrb(m jur pui' fnto ( { ecie'y Qey lgn, ucin ) bfrEc(ucin){ eoeahfnto( jsiegtitrs)fxuePt=j/_amn-eojur' amn.eFxue(.itrsah's5jsiedm_qey; jsiegtitrs)la(jur.ylgnse.tl) amn.eFxue(.od'qeymPui.pchm'; }; ) i(sol d smtig,fnto( { t'hud o oehn' ucin) vr$i =$'hlool'.ylgn) a dv (#elWrd)mPui(; epc(dv.oaels(nwls"; xet$i)tHvCas"eCas) }; ) }; ) jsiegtn(.xct(; amn.eEv)eeue) Demo
  • 46. Spies test behaviour dsrb(Gril' fnto ( { ecie'afed, ucin ) dsrb(we tl t b nc' fnto( { ecie'hn od o e ie, ucin) vrgril; a afed bfrEc(ucin){ eoeahfnto( gril =nwGril(; afed e afed) syngril,'oordenEtiz'.nClTruh) pO(afed gTFigAdaPza)adalhog(; }; ) i(sol ase wt o' fnto( { t'hud nwr ih k, ucin) vrase =gril.eie) a nwr afedbNc(; epc(nwr.oqa(o"; xetase)tEul"k) }; ) i(sol selpza,fnto ( { t'hud ta iz' ucin ) gril.eie) afedbNc(; epc(afedgTFigAdaPza.oaeenald) xetgril.oordenEtiz)tHvBeCle(; }; ) }; ) }; ) jsiegtn(.xct(; amn.eEv)eeue) A spy can stub any function and tracks calls to it and all arguments. Demo