KEMBAR78
Javascript Best Practices and Intro to Titanium | PPTX
Javascript
DEVELOPER’S LIFE
Who am I?


•   Ramkumar Murugadoss
•   @rampicos
•   facebook.com/raamkumar.m
•   Code
What is JavaScript


• Javascript is the Programming language, first emerged to
  make dynamic scripts for Web pages
• What do you think about Javascript?
Why Javascript




• What we use for: Programming Language for Web Pages
• How it was in current: Programming Language for Server-side too
• In near future: It is most wanted huge Programming Language for all
Best Practices


• All we know Javascript
• Everyone can code in Javascript
• All we want to know, how efficiently we will write JS
About GC


• GC is automatic
• Objects are collected there is no references longer
• Javascript Uses Mark and Sweep GC method
Avoid the global scope


• In the Global scope the Object never null, so never garbage
  collected
• It’s time taking and trivial process to get the reference of
  global scope
• If need to use global scope assign yourself null after the use
Use var


• Don’t forget to use var for all your variables
• The Variables without var may considered to global
• You are making javascript to struggle for finding the scope of
  your variable
Get Use of Self-Calling Functions


• Have any one noticied jQuery using self calling functions
What will be the result?
Make your loops more efficient
Conditional Branching
Creating Arrays and Objects


• Use [] instead of Array
   • Use arrayVariable[length] = value instead of
     arrayVariable.push(value)
• Use {} instead of Object
Closures


• A closure is a special kind of object that combines two
  things: a function, and the environment in which that function
  was created
• The environment consists of any local variables that were in-
  scope at the time that the closure was created
Closures Cond…
Closures Cond…
Namespaces


 • this prevent the global scope pollution
 • this protect your code from colliding with other code or libraries
Building String in Loops
Small Intro to OOPs




• Everything in Javascript is Object based, (note there is no keyword called class in
  JS)
• Now the question is then how can I create the Objects and its functions?
OOPs cond


• Creating functions in JS is considered to the Object, using prototypes you can
  define methods for that
Any Guess




• What is the difference between this two codes
Don’t D.R.Y




• Make the reusability
• Make use of Namespace
Cross Platform Mobile Applications



• What are Cross Platform Mobile Applications ?

•   Why build Cross Platform ?

•   What are the most popular development framework available ?

•   Which framework should I use?
Why Titanium


• Code Once Build Everywhere
• Native look and feel
• Has more than 5,500+ device level APIs for iOS and Android
• Object based Javascript only
• In build Analytics
• In build Cloud integration support (ACS)
• Much more
What to do to start with Titanium today?



Signup and download http://my.appcelerator.com




Follow the “Quick Start” https://wiki.appcelerator.org/display/guides/home




You’re ready to be a Titanium      developer!
CommonJS



• The Biggest feature introduced from Node.js for reusability is CommonJS
• Make your functions as unique namespaced modules and get to use of that
• We have exports.yourfunction and module.exports as 2 ways to create
  CommonJS modules
• Woow now browsers support CommonJS with some libraries
exports.your function
module.exports
Javascript Best Practices and Intro to Titanium

Javascript Best Practices and Intro to Titanium

  • 1.
  • 2.
    Who am I? • Ramkumar Murugadoss • @rampicos • facebook.com/raamkumar.m • Code
  • 3.
    What is JavaScript •Javascript is the Programming language, first emerged to make dynamic scripts for Web pages • What do you think about Javascript?
  • 4.
    Why Javascript • Whatwe use for: Programming Language for Web Pages • How it was in current: Programming Language for Server-side too • In near future: It is most wanted huge Programming Language for all
  • 5.
    Best Practices • Allwe know Javascript • Everyone can code in Javascript • All we want to know, how efficiently we will write JS
  • 6.
    About GC • GCis automatic • Objects are collected there is no references longer • Javascript Uses Mark and Sweep GC method
  • 7.
    Avoid the globalscope • In the Global scope the Object never null, so never garbage collected • It’s time taking and trivial process to get the reference of global scope • If need to use global scope assign yourself null after the use
  • 8.
    Use var • Don’tforget to use var for all your variables • The Variables without var may considered to global • You are making javascript to struggle for finding the scope of your variable
  • 9.
    Get Use ofSelf-Calling Functions • Have any one noticied jQuery using self calling functions
  • 10.
    What will bethe result?
  • 11.
    Make your loopsmore efficient
  • 12.
  • 13.
    Creating Arrays andObjects • Use [] instead of Array • Use arrayVariable[length] = value instead of arrayVariable.push(value) • Use {} instead of Object
  • 14.
    Closures • A closureis a special kind of object that combines two things: a function, and the environment in which that function was created • The environment consists of any local variables that were in- scope at the time that the closure was created
  • 15.
  • 16.
  • 17.
    Namespaces • thisprevent the global scope pollution • this protect your code from colliding with other code or libraries
  • 18.
  • 19.
    Small Intro toOOPs • Everything in Javascript is Object based, (note there is no keyword called class in JS) • Now the question is then how can I create the Objects and its functions?
  • 20.
    OOPs cond • Creatingfunctions in JS is considered to the Object, using prototypes you can define methods for that
  • 21.
    Any Guess • Whatis the difference between this two codes
  • 22.
    Don’t D.R.Y • Makethe reusability • Make use of Namespace
  • 24.
    Cross Platform MobileApplications • What are Cross Platform Mobile Applications ? • Why build Cross Platform ? • What are the most popular development framework available ? • Which framework should I use?
  • 25.
    Why Titanium • CodeOnce Build Everywhere • Native look and feel • Has more than 5,500+ device level APIs for iOS and Android • Object based Javascript only • In build Analytics • In build Cloud integration support (ACS) • Much more
  • 26.
    What to doto start with Titanium today? Signup and download http://my.appcelerator.com Follow the “Quick Start” https://wiki.appcelerator.org/display/guides/home You’re ready to be a Titanium developer!
  • 27.
    CommonJS • The Biggestfeature introduced from Node.js for reusability is CommonJS • Make your functions as unique namespaced modules and get to use of that • We have exports.yourfunction and module.exports as 2 ways to create CommonJS modules • Woow now browsers support CommonJS with some libraries
  • 28.
  • 29.