SlideShare uma empresa Scribd logo
1 de 19
Baixar para ler offline
1 | SharePoint Saturday Milan – 18 May 2013
2 | SharePoint Saturday Milan – 18 May 20132 | SharePoint Saturday Milan – 18 May 2013
Grazie ai nostri Sponsor!
3 | SharePoint Saturday Milan – 18 May 2013
Salvatore Di Fazio – Technical Architect – Content and Code -
London
salvatore.difazio@gmail.com - @Salvodif – MVP SharePoint Server
http://salvatoredifaziosharepoint.blogspot.com
4 | SharePoint Saturday Milan – 18 May 20134 | SharePoint Saturday Milan – 18 May 2013
Horizontal session
5 | SharePoint Saturday Milan – 18 May 20135 | SharePoint Saturday Milan – 18 May 2013
Starter
 JavaScriptisobjectbasedlanguage
 Variablescreatedusingvar
 Youshouldalwaysusesemicolons,andanobjectisacollection ofname/value
 JavaScriptiscasesensitive
 Alwaysusestrictmode,declaredwith“usestrict”
 Restrictions
 Cannotuseavariablewithoutdeclaringit
 Cannotwritetoaread-onlyproperty
 Cannotaddpropertiestonon-extensibleobjects
 Cannotillegallydeletefunctionsandvariables
 Cannotdefineapropertymorethanonceinanobjectliteral
 Cannotuseaparameternamemorethanonceinafunction
 Cannotusereservedwords,eval,orarguments,asnamesforfunctionsandvariables
 Thevalueofthisinafunctionisnolongerthewindowobject
 Cannotdeclarefunctionsinsideofstatements
 Cannotchangethemembersoftheargumentsarray
6 | SharePoint Saturday Milan – 18 May 20136 | SharePoint Saturday Milan – 18 May 2013
Null and undefined
 NULL
 OneoftheJavaScriptprimitive types
 Representstheabsenceofvalue
 EvaluatestofalseinBooleanexpressions
 UNDEFINED
 Primitivetype
 Representsanunknownvalue
 Returnedwhenanon-existentobjectpropertyiscalled
 EvaluatestofalseinBooleanexpressions
7 | SharePoint Saturday Milan – 18 May 20137 | SharePoint Saturday Milan – 18 May 2013
Avoid coercive equality
operators
 Objectsareonlyequaltothemselves
 Primitivesareequalifthevaluesmatch(“salvo”===“salvo”)
 Twosetsofequalityoperators(==and===)
 Neveruse==or!=INSTEADof===or!==
0=='0' //true
0==='0' //false
false=='0' //true
false==='0' //false
8 | SharePoint Saturday Milan – 18 May 20138 | SharePoint Saturday Milan – 18 May 2013
Prototype
 JavaScriptdoeshaveinheritanceandusuallymakeuseofprototype
 EveryJavaScriptobjecthasaninternalpropertycalledprototype
 obj.hasOwnProperty('propName')
 Toavoidtheduplicationofeffortandsavememory,ucanaddcommonproperties
andmethodstotheprototypeproperty.
 It’sbestifyoudon’taugmentbuilt-inprototypes.Youcanmakeanexceptionwhen:
1.it’sexpectedthatfutureEMACScriptversionswhilewaitingforthebrowserto
catchup
2.Youcheckifyourcustompropertyormethoddoesn’texistalready
3.Youclearlydocumentandcommunicatethechangewiththeteam
9 | SharePoint Saturday Milan – 18 May 2013
Null, undefined, equality, prototype
10 | SharePoint Saturday Milan – 18 May 201310 | SharePoint Saturday Milan – 18 May 2013
Functions
 Afunctionstartwiththekeywordfunction
 Afunctioncanhaveanameornot
 Afunctioncanhaveparameters
 Thedelimitersofthefunctionare{}
 Afunctioncanreturnavalue,andthatvaluecanbeitself
 Cannotbeoverloaded!!!
 Parametersnotpassedaresettedundefined
 Functionwithoutparametershasadefaultparamcalled(arguments)
 It’spossibletohaveafunctioninsideafunctionClosure
 Functionshavethis
11 | SharePoint Saturday Milan – 18 May 201311 | SharePoint Saturday Milan – 18 May 2013
Closure Pattern
 Wheneveryouseethefunctionkeywordwithinanotherfunction,theinnerfunction
hasaccesstovariablesoftheouterfunction
 Whyuseit:
 itisthelocalvariablesforafunction—keptaliveafterthefunctionhasreturned
 itisastack-framewhichisnotdeallocatedwhenthefunctionreturns
12 | SharePoint Saturday Milan – 18 May 201312 | SharePoint Saturday Milan – 18 May 2013
Classes Pattern
 WecreateaclassinJavaScriptbyapattern
 Useittopreventnamecollisionsandpollutingparentnamespace
 Keepeverythingtidy
 Usethenewkeywordtoinvoketheconstructor
13 | SharePoint Saturday Milan – 18 May 201313 | SharePoint Saturday Milan – 18 May 2013
Module Pattern
 Thewindowobjectinbrowsersisaglobalnamespace
 Variablesdefinedoutsideafunctionareintheglobalnamespace
 Variablesdefinedwithoutthevarkeywordareintheglobalnamespace
 Alwayscreateyourownnamespacebyapattern
 ThemodulepatternwasmadebyEricMiragliaofYUIinthe2007
 Useittopreventnamecollisionsandpollutingparentnamespace
 Itprovidesstructureandhelpsorganizeyourcodeasitgrows
 It’sacombinationofthefollowingpatterns:
 Namespaces
 Immediatefunctions
 Privateandprivilegedmembers
 Declaringdependencies
14 | SharePoint Saturday Milan – 18 May 201314 | SharePoint Saturday Milan – 18 May 2013
Decorator Pattern
 Itsolvestheproblemofaddingorchangingfunctionalityonaclasswithoutcreatinga
subclassforeverycombinationoffunctionality
 Everytimeyouaddanewoption,youcreateonlyonemoreclass,ratherthan
doublingthenumberofclasses.
 Thedecoratorworksbywrappingthebaseobjectwithadecoratorobjectthathasthe
sameinterfaceasthebaseobject
15 | SharePoint Saturday Milan – 18 May 2013
Closure, Class, Module, Chain, Decorator
16 | SharePoint Saturday Milan – 18 May 2013
17 | SharePoint Saturday Milan – 18 May 201317 | SharePoint Saturday Milan – 18 May 2013
Some references
 Problemsaboutglobals:http://blah.winsmarts.com/2013-5-SharePoint_2013_-
_JavaScript_-and-amp;_jQuery_big_booboo_to_watch_out_for.aspx
 JavaScriptPatterns:http://www.amazon.co.uk/dp/0596806752/?tag=hydra0b-
21&hvadid=9550950789&ref=asc_df_0596806752
18 | SharePoint Saturday Milan – 18 May 201318 | SharePoint Saturday Milan – 18 May 2013
Session Feedback
JavaScript Patterns
http://www.surveymonkey.com/s/PNC3CLW
19 | SharePoint Saturday Milan – 18 May 2013
Grazie

Mais conteúdo relacionado

Destaque

Javascript fundamentals and not
Javascript fundamentals and notJavascript fundamentals and not
Javascript fundamentals and notSalvatore Fazio
 
Javascript for the c# developer
Javascript for the c# developerJavascript for the c# developer
Javascript for the c# developerSalvatore Fazio
 
El contrato de compraventa (II Bimestre - Derecho Civil IV, Obligaciones y Co...
El contrato de compraventa (II Bimestre - Derecho Civil IV, Obligaciones y Co...El contrato de compraventa (II Bimestre - Derecho Civil IV, Obligaciones y Co...
El contrato de compraventa (II Bimestre - Derecho Civil IV, Obligaciones y Co...UTPL UTPL
 
Daftar Riwayat Hidup = Nike Kusuma Wati
Daftar Riwayat Hidup = Nike Kusuma WatiDaftar Riwayat Hidup = Nike Kusuma Wati
Daftar Riwayat Hidup = Nike Kusuma Watisman1jjs
 

Destaque (6)

Javascript fundamentals and not
Javascript fundamentals and notJavascript fundamentals and not
Javascript fundamentals and not
 
Jquery fundamentals
Jquery fundamentalsJquery fundamentals
Jquery fundamentals
 
Javascript for the c# developer
Javascript for the c# developerJavascript for the c# developer
Javascript for the c# developer
 
Cv
CvCv
Cv
 
El contrato de compraventa (II Bimestre - Derecho Civil IV, Obligaciones y Co...
El contrato de compraventa (II Bimestre - Derecho Civil IV, Obligaciones y Co...El contrato de compraventa (II Bimestre - Derecho Civil IV, Obligaciones y Co...
El contrato de compraventa (II Bimestre - Derecho Civil IV, Obligaciones y Co...
 
Daftar Riwayat Hidup = Nike Kusuma Wati
Daftar Riwayat Hidup = Nike Kusuma WatiDaftar Riwayat Hidup = Nike Kusuma Wati
Daftar Riwayat Hidup = Nike Kusuma Wati
 

Semelhante a Sharepoint saturday 18 may 2013

Single page applications & SharePoint
Single page applications & SharePointSingle page applications & SharePoint
Single page applications & SharePointFabio Franzini
 
SharePoint development evolution from classic to app
SharePoint development evolution from classic to appSharePoint development evolution from classic to app
SharePoint development evolution from classic to appMarco Rizzi
 
How I ended up contributing to Magento core
How I ended up contributing to Magento coreHow I ended up contributing to Magento core
How I ended up contributing to Magento coreAlessandro Ronchi
 
How I ended up touching Magento core
How I ended up touching Magento coreHow I ended up touching Magento core
How I ended up touching Magento coreAlessandro Ronchi
 
Where i put my business logic - Greach 2014, Madrid, Spain
Where i put my business logic  - Greach 2014, Madrid, SpainWhere i put my business logic  - Greach 2014, Madrid, Spain
Where i put my business logic - Greach 2014, Madrid, SpainAntonio de la Torre Fernández
 
How to Manage Projects in SharePoint Using Out of the Box Features
How to Manage Projects in SharePoint Using Out of the Box FeaturesHow to Manage Projects in SharePoint Using Out of the Box Features
How to Manage Projects in SharePoint Using Out of the Box FeaturesGregory Zelfond
 
Bargento 2014 : conférence Smile « ElasticSearch booste la recherche Magento »
Bargento 2014 : conférence Smile « ElasticSearch booste la recherche Magento »Bargento 2014 : conférence Smile « ElasticSearch booste la recherche Magento »
Bargento 2014 : conférence Smile « ElasticSearch booste la recherche Magento »Smile I.T is open
 
Drupal 8 Desacoplar la lógica de negocio del framework
Drupal 8 Desacoplar la lógica de negocio del frameworkDrupal 8 Desacoplar la lógica de negocio del framework
Drupal 8 Desacoplar la lógica de negocio del frameworkManuel López Torrent
 
Software modularity in practice
Software modularity in practice Software modularity in practice
Software modularity in practice Iavi Rotberg
 
Spsatx slides (widescreen)
Spsatx slides (widescreen)Spsatx slides (widescreen)
Spsatx slides (widescreen)Ryan Dennis
 
Introduction to AngularJS - More Than Just Data Binding
Introduction to AngularJS - More Than Just Data BindingIntroduction to AngularJS - More Than Just Data Binding
Introduction to AngularJS - More Than Just Data BindingLogical Advantage
 
Tsvetan stoychev m_mspeakers-edited-final
Tsvetan stoychev m_mspeakers-edited-finalTsvetan stoychev m_mspeakers-edited-final
Tsvetan stoychev m_mspeakers-edited-finalceckoslab
 
Shopify SEO Principles - What You Can and Can't Work with on a Limited Platform
Shopify SEO Principles  - What You Can and Can't Work with on a Limited PlatformShopify SEO Principles  - What You Can and Can't Work with on a Limited Platform
Shopify SEO Principles - What You Can and Can't Work with on a Limited PlatformPeter Macinkovic
 
Prepararsi a spostare le proprie applicazioni share point su office 365
Prepararsi a spostare le proprie applicazioni share point su office 365Prepararsi a spostare le proprie applicazioni share point su office 365
Prepararsi a spostare le proprie applicazioni share point su office 365Giuseppe Marchi
 
Image Slider with SharePoint 2013 Search Results Web Part
Image Slider with SharePoint 2013 Search Results Web PartImage Slider with SharePoint 2013 Search Results Web Part
Image Slider with SharePoint 2013 Search Results Web PartGSoft
 
Abilitics-Microsoft Days 09-Case Study Info Path, Excel Services And Word Doc...
Abilitics-Microsoft Days 09-Case Study Info Path, Excel Services And Word Doc...Abilitics-Microsoft Days 09-Case Study Info Path, Excel Services And Word Doc...
Abilitics-Microsoft Days 09-Case Study Info Path, Excel Services And Word Doc...Martin Karaivanov
 

Semelhante a Sharepoint saturday 18 may 2013 (20)

Single page applications & SharePoint
Single page applications & SharePointSingle page applications & SharePoint
Single page applications & SharePoint
 
SharePoint development evolution from classic to app
SharePoint development evolution from classic to appSharePoint development evolution from classic to app
SharePoint development evolution from classic to app
 
How I ended up contributing to Magento core
How I ended up contributing to Magento coreHow I ended up contributing to Magento core
How I ended up contributing to Magento core
 
How I ended up touching Magento core
How I ended up touching Magento coreHow I ended up touching Magento core
How I ended up touching Magento core
 
Where i put my business logic - Greach 2014, Madrid, Spain
Where i put my business logic  - Greach 2014, Madrid, SpainWhere i put my business logic  - Greach 2014, Madrid, Spain
Where i put my business logic - Greach 2014, Madrid, Spain
 
How to Manage Projects in SharePoint Using Out of the Box Features
How to Manage Projects in SharePoint Using Out of the Box FeaturesHow to Manage Projects in SharePoint Using Out of the Box Features
How to Manage Projects in SharePoint Using Out of the Box Features
 
Bargento 2014 : conférence Smile « ElasticSearch booste la recherche Magento »
Bargento 2014 : conférence Smile « ElasticSearch booste la recherche Magento »Bargento 2014 : conférence Smile « ElasticSearch booste la recherche Magento »
Bargento 2014 : conférence Smile « ElasticSearch booste la recherche Magento »
 
Magento best practices
Magento best practicesMagento best practices
Magento best practices
 
Drupal 8 Desacoplar la lógica de negocio del framework
Drupal 8 Desacoplar la lógica de negocio del frameworkDrupal 8 Desacoplar la lógica de negocio del framework
Drupal 8 Desacoplar la lógica de negocio del framework
 
Software modularity in practice
Software modularity in practice Software modularity in practice
Software modularity in practice
 
Spsatx slides (widescreen)
Spsatx slides (widescreen)Spsatx slides (widescreen)
Spsatx slides (widescreen)
 
Introduction to AngularJS - More Than Just Data Binding
Introduction to AngularJS - More Than Just Data BindingIntroduction to AngularJS - More Than Just Data Binding
Introduction to AngularJS - More Than Just Data Binding
 
Git Perchè Usarlo
Git Perchè UsarloGit Perchè Usarlo
Git Perchè Usarlo
 
Tsvetan stoychev m_mspeakers-edited-final
Tsvetan stoychev m_mspeakers-edited-finalTsvetan stoychev m_mspeakers-edited-final
Tsvetan stoychev m_mspeakers-edited-final
 
Shopify SEO Principles - What You Can and Can't Work with on a Limited Platform
Shopify SEO Principles  - What You Can and Can't Work with on a Limited PlatformShopify SEO Principles  - What You Can and Can't Work with on a Limited Platform
Shopify SEO Principles - What You Can and Can't Work with on a Limited Platform
 
Layered Landing
Layered LandingLayered Landing
Layered Landing
 
Prepararsi a spostare le proprie applicazioni share point su office 365
Prepararsi a spostare le proprie applicazioni share point su office 365Prepararsi a spostare le proprie applicazioni share point su office 365
Prepararsi a spostare le proprie applicazioni share point su office 365
 
Get satrted angular js day 2
Get satrted angular js day 2Get satrted angular js day 2
Get satrted angular js day 2
 
Image Slider with SharePoint 2013 Search Results Web Part
Image Slider with SharePoint 2013 Search Results Web PartImage Slider with SharePoint 2013 Search Results Web Part
Image Slider with SharePoint 2013 Search Results Web Part
 
Abilitics-Microsoft Days 09-Case Study Info Path, Excel Services And Word Doc...
Abilitics-Microsoft Days 09-Case Study Info Path, Excel Services And Word Doc...Abilitics-Microsoft Days 09-Case Study Info Path, Excel Services And Word Doc...
Abilitics-Microsoft Days 09-Case Study Info Path, Excel Services And Word Doc...
 

Sharepoint saturday 18 may 2013

  • 1. 1 | SharePoint Saturday Milan – 18 May 2013
  • 2. 2 | SharePoint Saturday Milan – 18 May 20132 | SharePoint Saturday Milan – 18 May 2013 Grazie ai nostri Sponsor!
  • 3. 3 | SharePoint Saturday Milan – 18 May 2013 Salvatore Di Fazio – Technical Architect – Content and Code - London salvatore.difazio@gmail.com - @Salvodif – MVP SharePoint Server http://salvatoredifaziosharepoint.blogspot.com
  • 4. 4 | SharePoint Saturday Milan – 18 May 20134 | SharePoint Saturday Milan – 18 May 2013 Horizontal session
  • 5. 5 | SharePoint Saturday Milan – 18 May 20135 | SharePoint Saturday Milan – 18 May 2013 Starter  JavaScriptisobjectbasedlanguage  Variablescreatedusingvar  Youshouldalwaysusesemicolons,andanobjectisacollection ofname/value  JavaScriptiscasesensitive  Alwaysusestrictmode,declaredwith“usestrict”  Restrictions  Cannotuseavariablewithoutdeclaringit  Cannotwritetoaread-onlyproperty  Cannotaddpropertiestonon-extensibleobjects  Cannotillegallydeletefunctionsandvariables  Cannotdefineapropertymorethanonceinanobjectliteral  Cannotuseaparameternamemorethanonceinafunction  Cannotusereservedwords,eval,orarguments,asnamesforfunctionsandvariables  Thevalueofthisinafunctionisnolongerthewindowobject  Cannotdeclarefunctionsinsideofstatements  Cannotchangethemembersoftheargumentsarray
  • 6. 6 | SharePoint Saturday Milan – 18 May 20136 | SharePoint Saturday Milan – 18 May 2013 Null and undefined  NULL  OneoftheJavaScriptprimitive types  Representstheabsenceofvalue  EvaluatestofalseinBooleanexpressions  UNDEFINED  Primitivetype  Representsanunknownvalue  Returnedwhenanon-existentobjectpropertyiscalled  EvaluatestofalseinBooleanexpressions
  • 7. 7 | SharePoint Saturday Milan – 18 May 20137 | SharePoint Saturday Milan – 18 May 2013 Avoid coercive equality operators  Objectsareonlyequaltothemselves  Primitivesareequalifthevaluesmatch(“salvo”===“salvo”)  Twosetsofequalityoperators(==and===)  Neveruse==or!=INSTEADof===or!== 0=='0' //true 0==='0' //false false=='0' //true false==='0' //false
  • 8. 8 | SharePoint Saturday Milan – 18 May 20138 | SharePoint Saturday Milan – 18 May 2013 Prototype  JavaScriptdoeshaveinheritanceandusuallymakeuseofprototype  EveryJavaScriptobjecthasaninternalpropertycalledprototype  obj.hasOwnProperty('propName')  Toavoidtheduplicationofeffortandsavememory,ucanaddcommonproperties andmethodstotheprototypeproperty.  It’sbestifyoudon’taugmentbuilt-inprototypes.Youcanmakeanexceptionwhen: 1.it’sexpectedthatfutureEMACScriptversionswhilewaitingforthebrowserto catchup 2.Youcheckifyourcustompropertyormethoddoesn’texistalready 3.Youclearlydocumentandcommunicatethechangewiththeteam
  • 9. 9 | SharePoint Saturday Milan – 18 May 2013 Null, undefined, equality, prototype
  • 10. 10 | SharePoint Saturday Milan – 18 May 201310 | SharePoint Saturday Milan – 18 May 2013 Functions  Afunctionstartwiththekeywordfunction  Afunctioncanhaveanameornot  Afunctioncanhaveparameters  Thedelimitersofthefunctionare{}  Afunctioncanreturnavalue,andthatvaluecanbeitself  Cannotbeoverloaded!!!  Parametersnotpassedaresettedundefined  Functionwithoutparametershasadefaultparamcalled(arguments)  It’spossibletohaveafunctioninsideafunctionClosure  Functionshavethis
  • 11. 11 | SharePoint Saturday Milan – 18 May 201311 | SharePoint Saturday Milan – 18 May 2013 Closure Pattern  Wheneveryouseethefunctionkeywordwithinanotherfunction,theinnerfunction hasaccesstovariablesoftheouterfunction  Whyuseit:  itisthelocalvariablesforafunction—keptaliveafterthefunctionhasreturned  itisastack-framewhichisnotdeallocatedwhenthefunctionreturns
  • 12. 12 | SharePoint Saturday Milan – 18 May 201312 | SharePoint Saturday Milan – 18 May 2013 Classes Pattern  WecreateaclassinJavaScriptbyapattern  Useittopreventnamecollisionsandpollutingparentnamespace  Keepeverythingtidy  Usethenewkeywordtoinvoketheconstructor
  • 13. 13 | SharePoint Saturday Milan – 18 May 201313 | SharePoint Saturday Milan – 18 May 2013 Module Pattern  Thewindowobjectinbrowsersisaglobalnamespace  Variablesdefinedoutsideafunctionareintheglobalnamespace  Variablesdefinedwithoutthevarkeywordareintheglobalnamespace  Alwayscreateyourownnamespacebyapattern  ThemodulepatternwasmadebyEricMiragliaofYUIinthe2007  Useittopreventnamecollisionsandpollutingparentnamespace  Itprovidesstructureandhelpsorganizeyourcodeasitgrows  It’sacombinationofthefollowingpatterns:  Namespaces  Immediatefunctions  Privateandprivilegedmembers  Declaringdependencies
  • 14. 14 | SharePoint Saturday Milan – 18 May 201314 | SharePoint Saturday Milan – 18 May 2013 Decorator Pattern  Itsolvestheproblemofaddingorchangingfunctionalityonaclasswithoutcreatinga subclassforeverycombinationoffunctionality  Everytimeyouaddanewoption,youcreateonlyonemoreclass,ratherthan doublingthenumberofclasses.  Thedecoratorworksbywrappingthebaseobjectwithadecoratorobjectthathasthe sameinterfaceasthebaseobject
  • 15. 15 | SharePoint Saturday Milan – 18 May 2013 Closure, Class, Module, Chain, Decorator
  • 16. 16 | SharePoint Saturday Milan – 18 May 2013
  • 17. 17 | SharePoint Saturday Milan – 18 May 201317 | SharePoint Saturday Milan – 18 May 2013 Some references  Problemsaboutglobals:http://blah.winsmarts.com/2013-5-SharePoint_2013_- _JavaScript_-and-amp;_jQuery_big_booboo_to_watch_out_for.aspx  JavaScriptPatterns:http://www.amazon.co.uk/dp/0596806752/?tag=hydra0b- 21&hvadid=9550950789&ref=asc_df_0596806752
  • 18. 18 | SharePoint Saturday Milan – 18 May 201318 | SharePoint Saturday Milan – 18 May 2013 Session Feedback JavaScript Patterns http://www.surveymonkey.com/s/PNC3CLW
  • 19. 19 | SharePoint Saturday Milan – 18 May 2013 Grazie