Titanium Second Look and Finished Calculator


In the first part of this series I started working on the calculator. Now that I have had a taste of Titanium, it was time to dig in and make the calculator functional.

The KeyPad
I began by looking at the KeyPad. Currently it only returns a view. What I really need is too pass an object back since I have no way to communicate to the keypad. While looking into that problem, I also realized that I had some replication of code going on. Each version of ApplicationWindow.js had its own copy of the KeyPad. So I moved keypad from there to app.js.



Next up, is the implementation of the calculator's logic function. I have decided to use events to communicate between different components. I like events since they promote loose coupling. The high level diagram is like this: the KeyPad communicates key presses to any one listening and listens for display updates from any one sending them. The logic function contained within the calc.js module has no UI. It simply performs the work and sends display events to anyone listening. In theory, it can be tested, but I haven't looked into unit testing in Titanium yet.


Things I Didn't Like
Overall I enjoyed developing this small project in Titanium. The environment is more solid than working in the browser, with no global space to muck things up. It almost seemed magical when I pushed the code to both Android and iPhone. This was a lot more pleasant than my experience using PhoneGap. There you work from different environments. But it isn't perfect. There are two things I didn't like, one minor, one major.

Refactoring
Titanium doesn't seem to have any way to refactor code. In other major development environments, like Visual Studio, Eclipse, and Intellij-IDEA, being able to refactor has now become a mandatory feature. It makes it easier to improve your design, make your code clearer, and play well with others. Not having this is irritating.

Internet Required
The more major pain is that Titanium requires Internet access in order to function. No Internet, no Titanium and that sucks. I have Internet access at home, work and most other places I go, but occasionally I am some where where it ain't. It may be an airport, a hotel room, or some other boring place where the best way to get through it is by writing code.

Summary
The calculator is now functional. I have posted it to my GitHub account. I am looking for to continuing my exploration into Titanium. Next up one of Titanium's newest features: Alloy.

Here is the link to the first part of this post: Titanium First Look.

Calculator on GitHub

Popular Posts