Code Organization In Phonegap
Posted By : Akhil Dhiman | 14-Nov-2014
A good application must have code organized in a good structured manner. While creating an PhoneGap application the developer should have to keep in mind about the folder structure of code. Generally the code must be organised by its type. The one should have to manage the files like in below Folder Structure.
- CSS/
- style.css
- i18n/
- es/
- strings.json
- en/
- strings.json
- es/
- images/
- logo.png
- JS/
- main_script.js
- global.js
- lib/
- jQuery.js
- jQueryMobile.js
- colorbox.js
- index.html
Folder Structure of application
Starting alphabetically -
- CSS
All the styling related to the applications must be places in css folder. i.e. all files with .css extention must be added in this folder and these files are to be called from inside index.html page.
- i18n (internationalization)
This folder contains subfolder named with initials of languages like "es" or "en". Inside those folders there is file names strings.json that contains all the strings based on language. In this way we can have all language specific files in i18n folder.
- images
images folder contains all images that are being used in web application. These folder have images of extention like .png,.jpg etc.
- JS
JS folder containg all the javascript files that are to be used in the project. i.e. all files with .js extention must be added in this folder. These files are to be called from index.html page via script tags.
- lib
lib folder contains all the libraries used in project. i.e. files like jquery, jquery mobile or any plugins are to be added in lib folder.
- index.html
index.html is the file that is to be loaded on the starting of application. This file contains all the layout and structure of application. Since this file starts the application this file must be placed in the root directory of application.
By following these steps code will be organized in good manner and it is also easy for other team members to understand the flow of project.
Thanks
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Akhil Dhiman
Akhil is an iPhone and Android application developer with experience in PhoneGap and Swift(Native iOS). Akhil has good experience working with JavaScript, jQuery and Underscore as well.