an introduction to the programming best practices for javascript and Titanium mobile
(cross platform programming seminar at university of pisa, july 2012)
TiConnect: Memory Management in Titanium appsTim Poulsen
Slides from my presentation at the 2014 ConnectJS / TiConnect conference in Atlanta. I cover tips and background info on managing memory and performance in your Titanium apps.
Rick Blalock: Your Apps are Leaking - Controlling Memory LeaksAxway Appcelerator
Developing large-scale Titanium apps can be tricky. Although Titanium manages memory on the native level for developers, care and attention on memory management and profiling techniques must be used in order to ensure their javascript is optimial. Attendees will learn how to detect memory leak / retention issues caused by client-side code. They will learn how to utilize tools and techniques such as Instruments / DDMS, proper architectural patterns, and more to produce performant apps.
Appcelerator's Rick Blalock leads this session for developers who have a a strong grasp of Titanium but want to learn how to profile and improve the apps they build.
Titanium - Making the most of your single threadRonald Treur
The native app development environments support multiple threads. Titanium however does not (out of the box), it only supports a single thread. In this presentaton, Ronald Treur will shortly explain how threading works and why this knowledge matters. But more important, he will show you how to keep heavy duty processes from blocking others.
Mobile Web Test Automation: to the Desktop! - Alexander Bayandin - Mobile Tes...Badoo
What does it usually look like when people do Mobile Web Test Automation? They write a couple of tests, run them on different desktop browsers, and then only after that, try to run on emulators/simulators. The final step is adapting and fixing the tests for browsers on real devices.
Luckily, we developed our tests for Mobile Web on real devices. But some time ago we decided to run on Desktop as well.
Why? What were the benefits for us? How do we have both Appium and Selenium tests in one repository? And what challenges did we face? I'll discuss this, as well as many other things, in my talk.
iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...Badoo
iOS Automation rapidly changed due to the evolution of Apple automation frameworks and Calabash community support. One year ago, we parallelised our iOS testing with multiple desktops – a large improvement in performance. Here is an account of the subsequent changes, including the removal of multiple desktops and the adoption of Apple’s new XCTest framework.
The automation community (Appium, Calabash etc.) faced a new challenge: how could we create iOS Automation Infrastructure with the new XCTest Framework?
I adopted Facebook solution (FBSimCtl and WebAgentDriver) into the multi-simulators approach. In this talk, I will discuss the full evolution path to Facebash Approach based on multi-simulators, Calabash server and Facebook Web Driver Agent.
iOS Parallel Automation - Viktar Karanevich - Mobile Test Automation Meetup (...Badoo
iOS Automation rapidly changed due to the evolution of Apple automation frameworks and Calabash community support. One year ago, we parallelised our iOS testing with multiple desktops - a large improvement in performance. Here is an account of the subsequent changes, including the removal of multiple desktops and the adoption of Apple's new XCTest framework.
The automation community (Appium, Calabash etc.) were faced with a new challenge: how could we create iOS Automation Infrastructure with the new XCTest Framework?
I adopted Facebook solution (FBSimCtl and WebAgentDriver) into the multi-simulators approach. In this talk, I will discuss the full evolution path to Hybrid Approach based on multi-simulators and XCTest framework, using Facebook open-source tools.
TiConnect: Memory Management in Titanium appsTim Poulsen
Slides from my presentation at the 2014 ConnectJS / TiConnect conference in Atlanta. I cover tips and background info on managing memory and performance in your Titanium apps.
Rick Blalock: Your Apps are Leaking - Controlling Memory LeaksAxway Appcelerator
Developing large-scale Titanium apps can be tricky. Although Titanium manages memory on the native level for developers, care and attention on memory management and profiling techniques must be used in order to ensure their javascript is optimial. Attendees will learn how to detect memory leak / retention issues caused by client-side code. They will learn how to utilize tools and techniques such as Instruments / DDMS, proper architectural patterns, and more to produce performant apps.
Appcelerator's Rick Blalock leads this session for developers who have a a strong grasp of Titanium but want to learn how to profile and improve the apps they build.
Titanium - Making the most of your single threadRonald Treur
The native app development environments support multiple threads. Titanium however does not (out of the box), it only supports a single thread. In this presentaton, Ronald Treur will shortly explain how threading works and why this knowledge matters. But more important, he will show you how to keep heavy duty processes from blocking others.
Mobile Web Test Automation: to the Desktop! - Alexander Bayandin - Mobile Tes...Badoo
What does it usually look like when people do Mobile Web Test Automation? They write a couple of tests, run them on different desktop browsers, and then only after that, try to run on emulators/simulators. The final step is adapting and fixing the tests for browsers on real devices.
Luckily, we developed our tests for Mobile Web on real devices. But some time ago we decided to run on Desktop as well.
Why? What were the benefits for us? How do we have both Appium and Selenium tests in one repository? And what challenges did we face? I'll discuss this, as well as many other things, in my talk.
iOS Parallel Automation: run faster than fast — Viktar Karanevich — SeleniumC...Badoo
iOS Automation rapidly changed due to the evolution of Apple automation frameworks and Calabash community support. One year ago, we parallelised our iOS testing with multiple desktops – a large improvement in performance. Here is an account of the subsequent changes, including the removal of multiple desktops and the adoption of Apple’s new XCTest framework.
The automation community (Appium, Calabash etc.) faced a new challenge: how could we create iOS Automation Infrastructure with the new XCTest Framework?
I adopted Facebook solution (FBSimCtl and WebAgentDriver) into the multi-simulators approach. In this talk, I will discuss the full evolution path to Facebash Approach based on multi-simulators, Calabash server and Facebook Web Driver Agent.
iOS Parallel Automation - Viktar Karanevich - Mobile Test Automation Meetup (...Badoo
iOS Automation rapidly changed due to the evolution of Apple automation frameworks and Calabash community support. One year ago, we parallelised our iOS testing with multiple desktops - a large improvement in performance. Here is an account of the subsequent changes, including the removal of multiple desktops and the adoption of Apple's new XCTest framework.
The automation community (Appium, Calabash etc.) were faced with a new challenge: how could we create iOS Automation Infrastructure with the new XCTest Framework?
I adopted Facebook solution (FBSimCtl and WebAgentDriver) into the multi-simulators approach. In this talk, I will discuss the full evolution path to Hybrid Approach based on multi-simulators and XCTest framework, using Facebook open-source tools.
How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...Wim Selles
This presentation is about the things I did to test the Tele2 React Native app with Appium. I'll explain the journey we've taken and some best practices which you can use with React Native and Appium
Get that Corner Office with Angular 2 and ElectronLukas Ruebbelke
These are the slides from my workshop at ng-conf 2016 on Angular 2 and Electron. Pull down the demo repository and work through the branches. Check out http://onehungrymind.com/ for additional resources.
Chrome Extensions are fun to build and very powerful, thanks to the expansive API Google provides. This talk will explore techniques for structuring and testing your extension projects, using tools such as Grunt, Browserify and Venus.js. A quick refresher of major extension development concepts will be also be reviewed.
With third party clients connecting to your service you may find that the assumptions or opinions of a typical rails application are not robust enough. We'll run through some key considerations when building an API that will be consumed by a mobile app.
Anadea Inc. internal mini-conference on November 5th, 2015.
Calabash Android + Calabash iOS | Kirill Machuhin | Slides
A brief report about the conference:
https://anadea.info/blog/november-5th-2015-mini-conference
Web and mobile development have always been separate worlds. Sure there have been tools like PhoneGap but it never matched the performance of native apps. React Native is here to change all that by using React to render native components for both iOS and Android. This talk will give an introduction to React Native though the eyes of a web developer.
Electron is an open-source framework developed by GitHub. It allows for the development of desktop GUI applications using the popular Node.js runtime. Electron is the main framework behind two notable open-source source code editors: GitHub's Atom and Microsoft's Visual Studio Code.
Talk given on Hoppinger's Drupal deployment automation tool (named Voiture) at the Drupal Tech Talk, 19th May 2011.
Please note the references to all things that 'suck' ... the point was not to complain about the software or issues in question but to raise awareness to the fact that nothing is perfect, that 'good' developers should be critical thinkers and that when you think something 'sucks' it's an opportunity to improve on it somehow :)
How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...Wim Selles
This presentation is about the things I did to test the Tele2 React Native app with Appium. I'll explain the journey we've taken and some best practices which you can use with React Native and Appium
Get that Corner Office with Angular 2 and ElectronLukas Ruebbelke
These are the slides from my workshop at ng-conf 2016 on Angular 2 and Electron. Pull down the demo repository and work through the branches. Check out http://onehungrymind.com/ for additional resources.
Chrome Extensions are fun to build and very powerful, thanks to the expansive API Google provides. This talk will explore techniques for structuring and testing your extension projects, using tools such as Grunt, Browserify and Venus.js. A quick refresher of major extension development concepts will be also be reviewed.
With third party clients connecting to your service you may find that the assumptions or opinions of a typical rails application are not robust enough. We'll run through some key considerations when building an API that will be consumed by a mobile app.
Anadea Inc. internal mini-conference on November 5th, 2015.
Calabash Android + Calabash iOS | Kirill Machuhin | Slides
A brief report about the conference:
https://anadea.info/blog/november-5th-2015-mini-conference
Web and mobile development have always been separate worlds. Sure there have been tools like PhoneGap but it never matched the performance of native apps. React Native is here to change all that by using React to render native components for both iOS and Android. This talk will give an introduction to React Native though the eyes of a web developer.
Electron is an open-source framework developed by GitHub. It allows for the development of desktop GUI applications using the popular Node.js runtime. Electron is the main framework behind two notable open-source source code editors: GitHub's Atom and Microsoft's Visual Studio Code.
Talk given on Hoppinger's Drupal deployment automation tool (named Voiture) at the Drupal Tech Talk, 19th May 2011.
Please note the references to all things that 'suck' ... the point was not to complain about the software or issues in question but to raise awareness to the fact that nothing is perfect, that 'good' developers should be critical thinkers and that when you think something 'sucks' it's an opportunity to improve on it somehow :)
Android Classes In Mumbai
best android classes in mumbai with job assistance.
our features are:
expert guidance by it industry professionals
lowest fees of 5000
practical exposure to handle projects
well equiped lab
after course resume writing guidance
A broad introduction to Java.
What is Java and where is it used
Programming Languages in the web development
What is Java and where is it used
OOP PRINCIPLES
JAVA SE, JRE, JDK
IDE’s
Where Java used in the “Real World”
This Presentation will give u information about Android :
1. UI design Components and layouts- Frame Layout,
2. Linear Layout,
3. Relative Layout Write the XML
4. Load the XML Resource Attributes- ID,
5. Layout Parameters,
6. Position,
7. Size,
8. Padding and Margins
This is a presentation I prepared for a local meetup. The audience is a mix of web designers and developers who have a wide range of development experience.
The Cordova framework
Recurrent app architecture
Cordova CLI
Debugging Cordova applications
My development environment
This presentation has been developed in the context of the Mobile Applications Development course, DISIM, University of L'Aquila (Italy), Spring 2016.
http://www.ivanomalavolta.com
This Presentation will give u information about Android :
1. Creating an Activity Declaring the activity in the manifest
2. Starting an Activity Starting an activity for a result Shutting
3. Down an Activity Managing the Activity Lifecycle Implementing the lifecycle callbacks Saving
4. activity state Handling configuration changes
AMD (Asynchronous Module Definition) is JavaScript's missing module system for the browser. It's a cosmos of interoperability, efficient loading, dependency resolution, code optimization, etc.
At excentos we're using it as part of the Dojo Toolkit to organize our single-page product advisor web apps.
I will give a short introduction to the concept and some tools and I'm going to explain why everyone with a reasonably-sized code base should adopt it.
Similar to Titanium appcelerator best practices (20)
Fifty shades of Alloy - tips and tools for a great Titanium Mobile developmentAlessio Ricco
tips and tools for a great Titanium Mobile development using community tools and resources.
dedicated to: https://www.facebook.com/groups/TitaniumMobileItaly/
Il lato oscuro della forza - L'eterna lotta tra progettisti e team di sviluppoAlessio Ricco
L'eterna lotta tra progettisti e team di sviluppo. Quali sono i principali motivi per cui spesso, in una azienda, i dipartimenti IT sono considerati un problema da gestire e non un prezioso asset strategico?
Firefox OS is a new mobile operating system, developed by Mozilla,which lets users install and run open web applications created using HTML, CSS, and JavaScript.We'll explain the best practices for a cross platform porting to Titanium Mobile Web and the guidelines for the deployment on this new cool platform.
Writing videogames with titanium appceleratorAlessio Ricco
Creating a simple videogame is a fun way to start learning the titanium appcelerator APIs.
this talk by alessio ricco was presented at the Mobile Developer Conference WHYMCA in Milan May 20th 20011
You're in trouble!!
You don't know who can help you!
You can call ALFRED, our call center, it will find the superhero who can solve your problem.
ALFRED knows plenty of superheroes, normal people like you who has a special gift/skill and wants to serve his community in a no-profit way; they have a mission: make our district a better place to live.
So, you need a babysitter? a clown? a great lasagna chef for your first date dinner?
Call "My Personal SuperHero".
It's free, It's for you!
http://planet.globalservicejam.org/content/my-personal-hero
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Welcome to the first live UiPath Community Day Dubai! Join us for this unique occasion to meet our local and global UiPath Community and leaders. You will get a full view of the MEA region's automation landscape and the AI Powered automation technology capabilities of UiPath. Also, hosted by our local partners Marc Ellis, you will enjoy a half-day packed with industry insights and automation peers networking.
📕 Curious on our agenda? Wait no more!
10:00 Welcome note - UiPath Community in Dubai
Lovely Sinha, UiPath Community Chapter Leader, UiPath MVPx3, Hyper-automation Consultant, First Abu Dhabi Bank
10:20 A UiPath cross-region MEA overview
Ashraf El Zarka, VP and Managing Director MEA, UiPath
10:35: Customer Success Journey
Deepthi Deepak, Head of Intelligent Automation CoE, First Abu Dhabi Bank
11:15 The UiPath approach to GenAI with our three principles: improve accuracy, supercharge productivity, and automate more
Boris Krumrey, Global VP, Automation Innovation, UiPath
12:15 To discover how Marc Ellis leverages tech-driven solutions in recruitment and managed services.
Brendan Lingam, Director of Sales and Business Development, Marc Ellis
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofsAlex Pruden
This paper presents Reef, a system for generating publicly verifiable succinct non-interactive zero-knowledge proofs that a committed document matches or does not match a regular expression. We describe applications such as proving the strength of passwords, the provenance of email despite redactions, the validity of oblivious DNS queries, and the existence of mutations in DNA. Reef supports the Perl Compatible Regular Expression syntax, including wildcards, alternation, ranges, capture groups, Kleene star, negations, and lookarounds. Reef introduces a new type of automata, Skipping Alternating Finite Automata (SAFA), that skips irrelevant parts of a document when producing proofs without undermining soundness, and instantiates SAFA with a lookup argument. Our experimental evaluation confirms that Reef can generate proofs for documents with 32M characters; the proofs are small and cheap to verify (under a second).
Paper: https://eprint.iacr.org/2023/1886
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
1. BEST PRACTICES
in apps development using
TITANIUM APPCELERATOR
Alessio Ricco
@alessioricco
1
2. Software Quality characteristic
(user point of view)
• Adaptability: is the app able to run in different environments ?
• Accuracy: how well does your app do the job ?
• Correctness: is your app able to do the job ?
• Efficiency: minimizing system resources
• Integrity: is your app secure ?
• Reliability: does it crash ?
• Robustness: does your app handle invalid inputs ?
• Usability: is it easy to learn how to use it ?
USERS notice STABILITY and PERFORMANCE
2
3. Software Quality characteristic
(developer point of view)
• Flexibility: can you adapt the app for other uses ?
• Maintanability: debug, improve, modify the app
• Portability: adapting the app for other platforms
• Readability: source code is easy to understand
• Reusability: using parts of your code in other apps
• Testability: the degree to which you can test the app
• Understandability: can you understand what the app does and how it
does it ?
DEVELOPERS needs RAPIDITY and READABILITY
3
4. Software Quality characteristic
User side:
STABLE
(applications must have a predictive behaviour)
PERFORMANT (speed must approach the speed of cpu)
Developer side:
RAPID
(development must be fast)
READABLE
(code must be easy to understand)
4
6. Avoid the global scope
• NO GARBAGE COLLECTION
In the global scope not null objects cannot be collected
• SCOPE IS NOT ACCESSIBLE FROM MODULES
app.js is not accessible within CommonJS modules
app.js is not accessible within other contexts (windows)
• Always declare variables
• Always declare variables inside modules or functions
• Assign global objects to null after the use
6
7. Nulling out object references
// create ui objects
var window = Ti.UI.createWindow();
var myView = myLibrary.createMyView();
win.add(myView);
win.open();
// remove objects and release memory
win.remove(myView);
myView = null;
// the view could be removed by the GC
7
8. Keep local your temp var
// immediate functions help us to avoid
// global scope pollution
var sum = (function() {
var tmpValue = 0; // local scope
for (var i = 0; i < 100; i++) {
tmpValue += i;
}
return tmpValue;
})();
// i, tmpValue are ready for GC !
8
9. Use self calling functions
// self calling function
(
function()
{
var priv = 'I'm local!';
}
)();
//undefined in the global scope
alert(priv);
9
10. Use namespaces
Enclose your application's API functions and properties into a
single variable (namespace). This prevent the global scope
pollution- this protect your code from colliding with other
code or libraries
// declare it in the global scope
var mynamespace = {};
mynamespace.myvar = “hello”;
mynamespace.myfunc = function(param) {}
10
11. Namespaces are extendable
// extend and encapsulate by using self-calling functions
(function() {
function helper() {
// this is a private function not directly accessible
! ! // from the global scope
}
myapp.info = function(msg) {
// added to the app's namespace, so a public function
helper(msg);
Ti.API.info(msg)
};
})();
// you could then call your function with
myapp.info('Hello World');
DON'T EXTEND TITANIUM NAMESPACES !!!!!
11
12. Understanding the closures
A closure is a function together with a referencing environment for the
non local variables of that function
// Return a function that approximates the
derivative of f
// using an interval of dx, which should be
appropriately small.
function derivative(f, dx) {
return function (x) {
return (f(x + dx) - f(x)) / dx;
};
}
the variable f, dx lives after the function derivative returns.Variables must
continue to exist as long as any existing closures have references to them
12
13. Avoid memory leaks in global event
listeners
function badLocal() {
// local variables
var table = Ti.UI.createTableView();
var view = Ti.UI.createView();
// global event listener
Ti.App.addEventListener('myevent', function(e) {
// table is local but not locally scoped
table.setData(e.data);
});
view.add(table);
return view;
};
Consider to use callback functions instead of custom global events
Place global event handlers in app.js
Rule : global events handle global objects
13
14. Lazy script loading
Load scripts only when they are needed
JavaScript evaluation is slow, so avoid loading scripts if they are not necessary
// load immediately
var _window1 = require('lib/window1').getWindow;
var win1 = new _window1();
win1.open()
win1.addEventListener('click', function(){
! // load when needed
! var _window2 = require('lib/window2').getWindow;
! var win2 = new _window2();
! win2.open()
})
BE AWARE: Some bugs could not be discovered until you load the script...
14
15. Cross Platform
BRANCHING
useful when your code is mostly the same across platforms but vary in some points
// Query the platform just once
var osname = Ti.Platform.osname;var isAndroid = (osname ==
'android') ? true : false;var isIPhone = (osname ==
'iphone') ? true : false;
// branch the code
if (isAndroid) {
// do Android code
...
} else {
// do code for other platforms (iOS not guaranteed)
...
};
// branch the values
var myValue = (isAndroid) ? 100 : 150;
15
16. Cross Platform: branch
// Query the platform just once
var osname = (Ti.Platform.osname == 'ipod') ? 'iphone' :
Ti.Platform.osname;
os = function(/*Object*/ map) {
var def = map.def||null; //default function or value
if (map[osname]) {
if (typeof map[osname] == 'function') { return
map[osname](); }
else { return map[osname]; }
}
else {
if (typeof def == 'function') { return def(); }
else { return def; }
}
};
// better than if statement and ternary operator.
var myValue = os({ android: 100, ipad: 90, iphone: 50 });
16
17. Cross Platform: JSS
PLATFORM-SPECIFIC JS STYLE SHEETS (JSS)
JSS separate presentation and code.
module.js
var myLabel = Ti.UI.createLabel({
! text:'this is the text',
! id:'myLabel'
});
module.jss
#myLabel {
! width:149;
! text-align:'right';
! color:'#909';
}
for platform specific stylesheets you can use module.android.jss and
module.iphone.jss, but module.jss have the precedence.
17
18. Images
Minimize memory footprint
Image files are decompressed in memory to be converted in
bitmap when they are displayed.
No matter the .png or .JPG original file size
Width Height Colors Footprint
320 480 24bit 450KB
640 960 24bit 1800KB
1024 768 24bit 2304KB
2304KB
2048 1536 24bit 9216
18
19. Image optimization
• use JPG for displaying photos- use PNG for displaying icons, line-art, text
• use remove() when the image is not visible on screen
• set image views to null once no longer need those objs
• resize and crops images to the dimensions you need
• resize images to minimize file storage and network usage
• cache remote images (https://gist.github.com/1901680)
19
21. Database
Close the database connection after insert and update
var db = Ti.Database.open('myDatabase');
try{
! db.execute('BEGIN'); // begin the transaction
! for(var i=0, var j=playlist.length; i < j; i++) {
! var item = playlist[i];
!
! db.execute('INSERT INTO albums (disc, artist, rating) VALUES
!
(?, ?, ?)', !! item.disc, item.artist, item.comment);
!
! }
! db.execute('COMMIT');
}
catch (e){
! Ti.API.info( "SCORE: error retrieving score [2]" );
}
finally {
! db.close();
}
21
22. Database
Minimize your database size
• Big Databases increases your app package file size
• The database is duplicated on your device because is copied to the
ApplicationDataDirectory
• On some Android releases the installer cannot uncompress assets over 1MB (if
you have a 2MB database you need some workarounds)
Keep your db small and populate it on the 1st run !
read sql-lite FAQ:
http://web.utk.edu/~jplyon/sqlite/SQLite_optimization_FAQ.html
22
23. Style and convention
Learn and follow language rules, styles and paradigms
javascript
isn't c# or java or php
titanium appcelerator is not just javascript
Follow coding style best practices
Naming Conventions
Indentation
Comments Style
Follow language related communities and forums
don't reinvent the wheel
learn community best practices
23
24. Language Rules
Learn and follow language rules, styles and paradigms
javascript
isn't c# or java or php
titanium appcelerator is not just javascript
Follow coding style best practices
Naming Conventions
Indentation
Comments Style
Follow language related communities and forums
don't reinvent the wheel
learn community best practices
24
25. Language Rules
Always declare the variables
When you fail to specify var, the variable gets placed in the
global context, potentially clobbering existing values. Also, if
there's no declaration, it's hard to tell in what scope a variable
lives.
So always declare with var.
25
26. Language Best Practices
Use the Exactly Equal operator (===)
comparing two operands of the same type is, most of the
time, what we need
var testme = '1';
if(testme == 1) // '1' is converted to 1
{
! // this will be executed
}
var testme = '1';
if(testme === 1) {
! // this will not be executed
}
26
27. Language Best Practices
Is better wrap self functions with parenthesis
var myValue = function() {
//do stuff
return someValue;
}();
// the same code, but it's clear that
myValue is not a function
var myValue = (function() {
//do stuff
return someValue;
})();
27
28. References
Titanium Appcelerator online documentation
http://docs.appcelerator.com/
Code Complete 2nd Edition – Steven C. McConnell - Microsoft Press
http://www.cc2e.com/Default.aspx
SQLite Optimization FAQ
http://web.utk.edu/~jplyon/sqlite/SQLite_optimization_FAQ.html
Douglas Crockford
http://javascript.crockford.com/
Google Javascript Style Guide
http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml
TwinsMatcher
http://itunes.apple.com/app/twinsmatcher/id429890747?mt=8
@alessioricco
http://www.linkedin.com/in/alessioricco
28