Successfully reported this slideshow.

Sharepoint saturday 18 may 2013

400 views

Published on

  • Be the first to comment

  • Be the first to like this

Sharepoint saturday 18 may 2013

  1. 1. 1 | SharePoint Saturday Milan – 18 May 2013
  2. 2. 2 | SharePoint Saturday Milan – 18 May 20132 | SharePoint Saturday Milan – 18 May 2013Grazie ai nostri Sponsor!
  3. 3. 3 | SharePoint Saturday Milan – 18 May 2013Salvatore Di Fazio – Technical Architect – Content and Code -Londonsalvatore.difazio@gmail.com - @Salvodif – MVP SharePoint Serverhttp://salvatoredifaziosharepoint.blogspot.com
  4. 4. 4 | SharePoint Saturday Milan – 18 May 20134 | SharePoint Saturday Milan – 18 May 2013Horizontal session
  5. 5. 5 | SharePoint Saturday Milan – 18 May 20135 | SharePoint Saturday Milan – 18 May 2013Starter 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. 6 | SharePoint Saturday Milan – 18 May 20136 | SharePoint Saturday Milan – 18 May 2013Null and undefined NULL OneoftheJavaScriptprimitive types Representstheabsenceofvalue EvaluatestofalseinBooleanexpressions UNDEFINED Primitivetype Representsanunknownvalue Returnedwhenanon-existentobjectpropertyiscalled EvaluatestofalseinBooleanexpressions
  7. 7. 7 | SharePoint Saturday Milan – 18 May 20137 | SharePoint Saturday Milan – 18 May 2013Avoid coercive equalityoperators Objectsareonlyequaltothemselves Primitivesareequalifthevaluesmatch(“salvo”===“salvo”) Twosetsofequalityoperators(==and===) Neveruse==or!=INSTEADof===or!==0==0 //true0===0 //falsefalse==0 //truefalse===0 //false
  8. 8. 8 | SharePoint Saturday Milan – 18 May 20138 | SharePoint Saturday Milan – 18 May 2013Prototype JavaScriptdoeshaveinheritanceandusuallymakeuseofprototype EveryJavaScriptobjecthasaninternalpropertycalledprototype obj.hasOwnProperty(propName) Toavoidtheduplicationofeffortandsavememory,ucanaddcommonpropertiesandmethodstotheprototypeproperty. It’sbestifyoudon’taugmentbuilt-inprototypes.Youcanmakeanexceptionwhen:1.it’sexpectedthatfutureEMACScriptversionswhilewaitingforthebrowsertocatchup2.Youcheckifyourcustompropertyormethoddoesn’texistalready3.Youclearlydocumentandcommunicatethechangewiththeteam
  9. 9. 9 | SharePoint Saturday Milan – 18 May 2013Null, undefined, equality, prototype
  10. 10. 10 | SharePoint Saturday Milan – 18 May 201310 | SharePoint Saturday Milan – 18 May 2013Functions Afunctionstartwiththekeywordfunction Afunctioncanhaveanameornot Afunctioncanhaveparameters Thedelimitersofthefunctionare{} Afunctioncanreturnavalue,andthatvaluecanbeitself Cannotbeoverloaded!!! Parametersnotpassedaresettedundefined Functionwithoutparametershasadefaultparamcalled(arguments) It’spossibletohaveafunctioninsideafunctionClosure Functionshavethis
  11. 11. 11 | SharePoint Saturday Milan – 18 May 201311 | SharePoint Saturday Milan – 18 May 2013Closure Pattern Wheneveryouseethefunctionkeywordwithinanotherfunction,theinnerfunctionhasaccesstovariablesoftheouterfunction Whyuseit: itisthelocalvariablesforafunction—keptaliveafterthefunctionhasreturned itisastack-framewhichisnotdeallocatedwhenthefunctionreturns
  12. 12. 12 | SharePoint Saturday Milan – 18 May 201312 | SharePoint Saturday Milan – 18 May 2013Classes Pattern WecreateaclassinJavaScriptbyapattern Useittopreventnamecollisionsandpollutingparentnamespace Keepeverythingtidy Usethenewkeywordtoinvoketheconstructor
  13. 13. 13 | SharePoint Saturday Milan – 18 May 201313 | SharePoint Saturday Milan – 18 May 2013Module Pattern Thewindowobjectinbrowsersisaglobalnamespace Variablesdefinedoutsideafunctionareintheglobalnamespace Variablesdefinedwithoutthevarkeywordareintheglobalnamespace Alwayscreateyourownnamespacebyapattern ThemodulepatternwasmadebyEricMiragliaofYUIinthe2007 Useittopreventnamecollisionsandpollutingparentnamespace Itprovidesstructureandhelpsorganizeyourcodeasitgrows It’sacombinationofthefollowingpatterns: Namespaces Immediatefunctions Privateandprivilegedmembers Declaringdependencies
  14. 14. 14 | SharePoint Saturday Milan – 18 May 201314 | SharePoint Saturday Milan – 18 May 2013Decorator Pattern Itsolvestheproblemofaddingorchangingfunctionalityonaclasswithoutcreatingasubclassforeverycombinationoffunctionality Everytimeyouaddanewoption,youcreateonlyonemoreclass,ratherthandoublingthenumberofclasses. Thedecoratorworksbywrappingthebaseobjectwithadecoratorobjectthathasthesameinterfaceasthebaseobject
  15. 15. 15 | SharePoint Saturday Milan – 18 May 2013Closure, Class, Module, Chain, Decorator
  16. 16. 16 | SharePoint Saturday Milan – 18 May 2013
  17. 17. 17 | SharePoint Saturday Milan – 18 May 201317 | SharePoint Saturday Milan – 18 May 2013Some 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. 18 | SharePoint Saturday Milan – 18 May 201318 | SharePoint Saturday Milan – 18 May 2013Session FeedbackJavaScript Patternshttp://www.surveymonkey.com/s/PNC3CLW
  19. 19. 19 | SharePoint Saturday Milan – 18 May 2013Grazie

×