Last week Appcelerator provided a series of Web Casts showing some of the new features available in Titanium and the latest release of their Studio product and SDK.
With seven days of the web casts and so much information coming out they recorded them and are now available here.
I was fortunate to be able to have the time to watch these live, and I have to say that with the exception of the information on the Nook, (I’m based in the UK and we don’t have it) everything else was really well presented, relevant and informative.
It is an exciting time to be using Titanium as a development platform. Having seen what is now available and potentially coming the framework is going from strength to strength.
I hope you get chance to watch the recordings (available here) as they are well worth it. Especially check out and follow the new example app they are creating and blogging.
TRAINING COURSE POSTPONED:
Unfortunately due to technical reasons I have had to postpone this course. Keep an eye on the site for when it is being rescheduled for.
Over the last few weeks I have been talking with Appcelerator about providing a training course in Sheffield in the UK.
I have now got to a position where this may be possible. I am hoping for full confirmation of this by the 22nd January.
The proposed course will be run over 3 days and be as the schedule below culminating in taking the Titanium TCAD Exam.
If you are interested in this course please leave a comment on this post. You will be contacted in the next two weeks with more information.
Dates: 21st – 23rd March 2012
Location: Sheffield (UK)
Cost: £750
Places: 15 (max)
Requirements: You will need to bring a Laptop setup with Titanium studio and preferably a test device either Android or iPhone. You will also need to have undertaken the Zero – App Training from Appcelerator.
Course Schedule
Monday 21st March 2012
8 am Registration Opens
8.15 am Refreshments Served (Provided)
9.00 am Session 1
10.30 am Break Refreshments Served (Provided)
11.00 am Session 2
12.30 pm Lunch (Provided)
1.30 pm Session 3
3.00 pm Break Refreshments Served (Provided)
3.30 pm Session 4
5.00 pm End of Sessions
5.00 pm – 6.30 pm Attendees are available to use the facilities to continue self study. The course tutor will be around during this period.
6.30 pm – 10.00 pm Attendees are invited to a local hostelry (Pub) where they will be able to obtain food and liquid refreshment, continue discussing the course and asking questions of the tutor and support team.
Tuesday 22nd March 2012
8 am Facilities Open
8.15 am Refreshments Served (Provided)
9.00 am Session 5
10.30 am Break Refreshments Served (Provided)
11.00 am Session 6
12.30 pm Lunch (Provided)
1.30 pm Session 7
3.00 pm Break Refreshments Served (Provided)
3.30 pm Session 8
5.00 pm End of Sessions
5.00 pm – 6.30 pm Attendees are available to use the facilities to continue self study. The course tutor will be around during this period.
6.30 pm – 10.00 pm Attendees are invited to a local hostelry (Pub) where they will be able to obtain food and liquid refreshment, continue discussing the course and asking questions of the tutor and support team.
Wednesday 23rd March 2012
8 am Facilities Open
8.15 am Refreshments Served (Provided)
9.00 am Session 9
10.30 am Break Refreshments Served (Provided)
11.00 am Session 10
12.30 pm Lunch (Provided)
1.30 pm Session 11
3.00 pm Break Refreshments Served (Provided)
3.30 pm Session 12
5.00 pm Break Refreshments Served (Provided)
5.30 pm – 7.00 pm TCAD Exam.
The content of the course will follow the Appcelerator official course which can be found here. A summary is below broken down by session (subject to change)
Session 1: Welcome and Introduction, Introduction to Titanium, The Tool Chain, Titanium Studio, Labs.
Session 2: Cross Platform Javascript Applications
Session 3: CommonJS Architecture, Labs
Session 4: UI Fundamentals
Session 5: More on CommonJS, Labs
Session 6: Working with Local Data, Labs
Session 7: Working with Remote Data, Labs
Session 8: Media & the Filesystem, Labs
Session 9: Using Location Services, Labs
Session 10: Integrating Contacts and Social API’s, Labs
Session 11: Integrating Web Content, Labs
Session 12: Deployment & Distribution, Exam preperation.
(Labs are hands on practical working tasks).
Appcelerator have released a new version of their Titanium mobile development framework SDK (1.8.0.1), and there are some major changes taking place. I will say here that although these have caused me a lot of extra work these changes are a good thing, and going forwards will make coding even more fun.
If you have been keeping track of Titanium version 1.8.0 RC3 you wil be aware of the major change in moving from a global namespace architecture to commonJS. You may not be aware of the implications this raises.
The major issue I hit when refactoring a 10000+ line code base from global namespace to commonJS, was that in commonJS there is no global space. Although you can declare an application level variable that is really not good practice. I had to have global variables which were static and maintainable or I would have to completely rewrite my app.
A few discussion with people at Appcelerator ensued around this topic, and a big thanks goes out to Matt Apperson, Paul Dowsett and Kevin Whinnery for there help and guidance in solving these issues.
So to start. To obtain a global variable you need to create a commonJS module, this is a very simple architecture and you can create as many as you require to keep your code base abstracted out into a good architecture.
I created a file in a sub directory ‘common’ called globals.js
// My common global variables.
exports.GV =
{
variable1: 'This is a static variable',
variable2: 'This is another static variable',
variable3: 'http://www.thewarpedcoder.net'
};
exports.GVUpdate = function(inValue, inName)
{
this.GV[inName] = inValue;
};
The following code snippet shows how to use this within any other module, in this case I used a file I created “control.js” in a sub directory control.
var VARS = require('/common/globals);
alert(VARS.GV.variable1);
alert(VARS.GV.variable3);
VARS.GVUpdate('www.thewarpedcoder.net', 'variable3');
alert(VARS.GV.variable3);
The exports.GV is fairly obvious this just makes the objects available. The exports.GVUpdate enables the values to be updated. When including these files in any other file (module) then the variables with the new values are available.
A gotcha which may be a bug, If you update the value in a sub module and then fire an event into a parent module, the value in the parent module does not get updated. So until this is either established as a bug and fixed or deemed the way it works, try and always update the values in the parent module. (I hope this makes sense!!!!).
UPDATE after looking into this further the above GOTCHA is not a bug, it works as it should, the issue I had was with a specific variable which wasn’t updating due to another completely independent issue.
Well thats it for now. Hopefully this will help a few people resolve the global space issue when refactoring their code.
some useful links……
Forging Titanium commonJS Modules
Titanium Best Practices
commonJS
We are setting up a Sheffield Mobile User Group us being Ian @ianibbo , Joe @jdreimann and me @thewarpedcoder,
The group will be based at the gist lab on the third Wednesday of the month and will follow a format of speakers, show and tells and hack evenings. We have an idea for an app which the group will develop going forward and the first three speakers are booked.
The normal meeting format will be either a speaker followed by a Q & A and or a show and tell, or a hack evening where the main app or one you want to do will be worked on, with people around to guide and advise.
To get the group off the ground we are having a hello meeting in the Rutland Arms from 7pm on Wednesday 21st December. If your interested either comment her, ping one of us or just turn up. The evening will be totally informal and will give everybody a chance to have their say about the group going forward and who and what sort of speakers they would like.
See you There
T…
I mentioned a few weeks ago that I had been invited by appceleraotor to help them man their stand at Apps World Europe. Well this occurred on the 29th and 30th November at the Olympia conference centre in London.
The week started well, with a train ride to London and a quick tube to the B & B. Then a short wait for Paul Dowsett from appcelerator and Ketan Majmudar a fellow Titan, before we went out for food. I had met Ket a few times before, the first was in April on our Titanium training course. I was a little nervous about meeting Paul, but a really pleasant evening was had by all.
Tuesday started early and we found an excellent cafe for breakfast, before going onto the exhibition.
This was going to be interesting…..
Doug Norton-Bilsby who is starting as the head of EMEA in January joined us, a few last minute tweaks to the stand, Boydlee another Titan arrived and we were ready for business.
The day started slowly but only the first 30 minutes or so and for want of a better description somebody opened the flood gates, the rest of the day was full on. We had hundreds of people visit the stand on the first day, and the types of people were from start ups looking for solutions to coders coming to say hi.
A lot of talking walking and demoing later, the exhibition closed for the day and we still had people on the stand. Then we went off to the London Titanium Group meetup. That deserves a post on its own, what a fantastic group, great people and excellent talks. So another late night and yep up early for the off to the expo, we did stop at the excellent cafe again.
If we thought that most of the people came through on the first day boy were we wrong. It was another full on day, which involved my current employers coming down to say hi and Ubuntu to name just a few.
In summary I have to say a really big thank you to appcelerator for a fantastic two days, ask a geek to talk to other geeks about the stuff the technology can do and we really are happy. It was a lot of fun and a pleasure to meet and work with the guys from appcelerator and the other titans.
It was nice to see how many people were already aware of Titanium and how well suited it was for most of the requirements people had. The only slight disappointment was not having a lot of time to go round the rest of the exhibition. Would I do it again, simple answer if asked I would love to.
With commonJS now being included in the appcelerator titanium framework and the issue with loading files for Android. I decided that a bit of refactoring was required on one of my apps.
The Issues.
I have recently started taking the iPhone code and making it work on Android. One of the first issues I faced was to do with file loading. I have a routine which loads the abstracted code files at time of requirement instead of loading all the files in the app.js file, and when run on Android issues occurred with functions not being found. This turned out to be due to the files being lazy loaded into memory on the Android platform.
The application itself had been written using the namespace architecture and the only solution without using commonJS was to load all the files at run time in the app.js file. This meant that the app took way to long to load.
The Potential Solution.
CommonJS appeared to offer a solution to this and after investigation of the implementation within titanium I set about refactoring the code. This was not straight forward nor did it work on IOS and Android immediately.
Namespaces.
An application using the namespace architecture, basically enables code abstraction by making available functions across the whole application without the need to continually use event handlers.
The full commonJS solution enables the use of functions across the application by using event handlers. My solution combines this and the namespace architecture enabling me to have a common code base for multiple platforms.
The Process.
Firstly I read up on the Titanium commonJS implementation. Then I sat down and considered the best way to implement it. One decision I made very early on was that the common global reference files and tools I would include using Ti.include in the app.js file as these were already included here.
This didn’t break any rules as I was doing a direct include and the files had namespace variables and functions which were used across the whole application and didn’t have any dependencies on other files.
This being done I then had to implement the commonJS require into my file load function. I had an advantage; I didn’t include sub files in my files so this made it easy. A full commonJS implementation would have required me to code sub files for the major functions, but I was refactoring and this was a step to far.
The actual rewrite of the load function was pretty easy and I already had the calling code and the files loaded in the correct order. So I switched the Ti.include to be a require statement. Now because of the architecture of the app, which uses namespace functions loaded using anonymous functions, this meant that the required files had to be modified.
I already had the namespaces declared in my app.js file and I modified this to have a namespace for each file type, screen, tool, data model etc, and then created sub namespaces for each file. This meant within the files themselves I changed.
FSAP.CTL.FF.startfunction = function () { ……. } to exports.startfunction () { …… }
and this I did to all the functions within the files. I then loaded them as the .FF of the namespace was specific to the file name and I had been consistent with the namespace naming quite easily.
FSAP.CTL[param] = require(‘FSAP.CTL’ + param);
And this worked great as all the functions through out the application could still be accessed by there original namespace reference, without having to rename them or code a load of event handler solutions. I then hit various issues….
I had been a good coder with naming conventions and where I set values or got values I had called them set…. and get…. and a third one init….. YOU CANNOT DO THIS. commonJS will fall over if you have these three words in the name of functions. But studio came to my rescue with its global search and replace.
So I replaced set with load, get with retrieve and init with create in all function names. I made the mistake of doing this globally without checking each one individually.
What did get me was that in a couple of instances I couldn’t find certain variables when the application ran but this was due to me not loading a couple of critical files at run time, worked great on IOS but Android objected, so I switched the files to load in the app.js and this resolved all loading issues.
Now the app didn’t work properly and just kept hanging with no real errors. TIME TO DEBUG.. but how as it was virtually impossible to try to fix a debug point for studio to stop at. Well again studio came to my rescue, if you run an application through the debugger the app will stop at the offending line of code. A little trick, make sure you have the debugger view in studio displaying and just run your app. Works for both IOS and Android. So a couple of hours later I had a working IOS and Android version with the same code base, architecture and structure.
It is vital if you are going to do something similar to allow time, this took me 3days but I have an app with over 10000 lines of code. Also make sure your current architecture can handle the changes and finally ONLY DO IT IF YOU NEED TO. I had to or our Android version would have been unusable.
Summary.
In conclusion I have found that the Titanium installation of commonJS is pretty good and stable, there are differences between IOS and Android, well in my case because I refactored. I will certainly be using this going forward and implementing a much more structured solution, although I think I will still use it in conjunction with the namespace architecture. Beware this is new and as yet not fully tried out, so you will hit unexpected and undocumented issues which will need some careful debugging and maybe a creative solution or two. But it works and works well.
Do not unless you have to refactor your current apps over too commonJS it can be just to much work, but DO implement it going forward for new apps.
The second post in the series is going to layout what is to come. Covering the processes and terminology that will be used.
MVC.
MVC stands for Model View Controller. This is best explained by somebody other than me so here is a link to Wikipedia.
To firstly understand the code architecture is a must. Reading up on MVC will enable you to see how I have implemented it and either see flaws or find a way which better suits you.
Abstraction.
I can best describe abstraction as writing a chunk of code in a procedural manner, realising that this code can be used elsewhere and then creating a common function to enable reuse. Sounds simple and in reality it is, the hardest part is deciding where to put this new function in the code architecture.
And wikipedia once again explains it far better than me.
Refactoring.
A term used to describe the way you change code. My take on this is it refers to either changing names of functions or variables to better fit the naming convention of the application and moving code into different sections (files) as it is more appropriate in that place. Again a nice simplistic description but the hard part is naming and placing.
And yes were off to wikipedia again.
When you have the application code architecture then the naming conventions and function locations becomes apparent.
CommonJS.
Titanium has an implementation of commonJS and I have just refactored my code architecture to use this. It wasn’t implemented when the project was developed using these principles but it will be used in the example code.
Oh not wikipedia, this time CommonJS site. To see how it is used within titanium visit the appcelerator wiki page
What else should you know before reading the next posts.
Well an understanding of coding and the Titanium framework would help. If you have not used Titanium before please go to the appcelerator wiki and read the Quick start guide. This wiki is also essential reading and reference material going forward. If you get stuck or just want clarification there is a really good, friendly and experienced community, ready and willing to help at the appcelerator Q & A forum.
In the next post we will start to get into the code structure.
Articles in this series:
Part 1
Part 2
Today I had the privilege of being invited to chair a round table discussion at the SVC2UK Masterclass.
This event was put on in conjunction with The Sheffield Universities and enable a coming together of Students and Business experts. This involved a few talks and a series of open round table discussions about various subjects, where the students could decide where their interests lie.
It started with a talk by Robin Camp of Mobile Manifest titled “The State of the Mobile and App Landscape”, which gave an insight into the current trends and fads of this market. An observation Adobe really have not handled their press well over the last two weeks, there were some very misinterpreted comments made, but it was a really good talk and very informative.
Then onto the round table discussions.
“Mobile Development: Native v Cross-Platform” Hosted by me …. this was a really good discussion and had some excellent content from the students.
“The Business Of Games Apps” hosted by Russ Stearman of Team Cooper.
“From Idea to Investment” hosted by Michael Dimelow of ARM and Ben Hookway of Vidiactive.
“The Great Divide between Business and the Customer” hosted by Lee Strafford formerly of Plusnet.
“To App or Not to App” hosted by Steve Dupree of Diva Creative.
“Apps for Specialist Markets” hosted by Chris Murray of epiGenesys.
Being involved in my own group I didn’t have the opportunity to attend the other groups but the feed back from the students afterwards was really positive and impressive.
Finally we had the pleasure of Joel Gasgoine from buffer joining us over tech video feed from Silicon Valley to talk about “From Idea to Paying Customers in 7 Weeks”.
The whole afternoon was finished off not surprisingly by going to the pub…
Thanks to all that organised this it was a really superb afternoon and a privilege to have been asked to attend.
As an opener I have been developing mobile apps using Apccelrator Titanium for the last 6 months and I am TCAD qualified and a community Titan. Prior to this I have been coding business applications for the last 20 years.
Well the intro over what is the purpose of this post.
As I was developing a rather large application, it became apparent that a code structure was required to remove duplication of code, reduce application size and increase the speed. So I looked around and found nothing.
We had already started the project by thinking about data transfer size, processing speed and usability so planning a code architecture was the next obvious step. Having been coding in flex for a while I had already used puremvc and applied various code architectures. But this was for mobile, where space, memory and speed are all critical factors so my thought process went down this route.
If I add a framework on top of a framework then I would be adding complexity and code for no real reason, I understand code abstraction so if I set it up right at the start I should be able to accomplish the goal. So this is what happened.
This series of blogs is to explain how I implemented an MVC architecture using code abstraction to develop an Augmented reality application within the Appcelerator Titanium Framework.
Articles in this series:
Part 1
Part 2
A strange thing happened as I was working yesterday.
I was contacted by Paul Dowsett from Appcelerator asking what I was doing on the 29th and 30th of November. Well I was planning on attending this …. London Titanium Group. Still am in fact
Paul asked if I would like to attend the Apps World in London on those days, as they have a stand and would like it if I would help them man it…
So my response was Awesome. If your planning on coming to the Apps World come say hi to the Appcelerator folks, and get some info on an excellent cross platform mobile and desktop development framework.