iPhone hacks

Well, it looks like hackers have been hard at work on the iPhone since it came out and have managed to hack the iPhone to gain access to the filesystem, alter the iPhone’s internals, and to launch custom programs. This has in turn been used to enable people to install custom ring tones and sounds, use the EDGE network from a laptop, and install and run a simple program on the iPhone. It’s unclear whether Apple can/will disable some of these hacks in the future. These hacks are still really only for techies and you may be voiding your warranty. Also, it looks like some of these hacks break visual voicemail and EDGE network access.

Meanwhile, there are already hundreds of web-based iPhone applications using the web-based development model Apple supports. I’m still hoping Apple will open up the SDK for custom applications.

Posted in General | Leave a comment

Web development for iPhone

Apple has posted guidelines for developing web applications for the iPhone. Apple has not provided an SDK for developing applications, so for now this is the only way to create applications for the iPhone.

The guidelines tell us how to best construct web pages for Safari on the iPhone, how to optimize media served up to the iPhone, what technologies are in (JavaScript, AJAX, most rich media formats), and what technologies are out (Flash, Java applets, plugins). They also tell us how to create links in web pages to the phone, mail, and Google maps applications so that phone numbers in applications can automatically dial a phone number, etc.

I actually think this is a pretty good development model for many types of applications. Since everything is using standard web technologies (XHTML, JavaScript, DHTML, AJAX), there’s an army of developers that already have the necessary skills, and adapting an existing web application to work well on the iPhone will be much less work than rebuilding it for a custom SDK. Due to AJAX and frameworks such as GWT, the usability gap between desktop UIs and web application UIs has narrowed considerably.

To me, the one big missing piece in this model is the ability to store data offline, along the lines of Google Gears. Google Gears is a browser plugin and includes SQLite, a very capable embedded RDBMS. This would allow applications to be delivered to the iPhone that can work online or offline, storing their data locally on the iPhone, and syncing up with servers when connected. I want my applications to work when there isn’t good EDGE nor WiFI network coverage. I would think twice about choosing the iPhone as the platform for that new sales team application if I knew it would only work if the sales guy was in an EDGE-covered area. I would like to be able to use Google reader to catch up on my RSS feeds even if I’m on the train and I keep losing my net connection. The only downside that comes to mind is storing application data in this manner will tend to use up the iPhone’s flash memory (4 GB or 8 GB).

Although I like the idea of developing applications for the iPhone using standard web technologies, I hope Apple will make an iPhone SDK available soon so developers can create applications that can take fuller advantage of the iPhone’s resources. I can’t create a voice memo application as a webapp.

Posted in General | Tagged | Leave a comment

What MDA needs: a user’s perspective

One of my areas of interest in software development is model driven architecture and model driven software development. I’ve successfully applied MDA to software projects and have seen the benefits first hand. Although MDA/MDSD tools and techniques can bring several benefits to software projects, including improving developer productivity, following are some features that I think would greatly increase the adoption of MDA/MDSD in the industry:

Make it easy to write and customize code generation cartridges

After working with MDA/MDSD tools for a while, it’s common to need to customize the code generation cartridges and/or write entirely new ones. The MDA/MDSD tool should make it easy to do so. The model transformation and code generation process should be easy to understand and creating new transformations/generators should be straightforward. Creating new cartridges for AndroMDA 3 is fairly involved and not easy to get up to speed with. The process involves creating UML meta-models, using AndroMDA to generate code from the meta-models, then writing Java code to implement the model to model transformations. AndroMDA 4 looks to be simplifying the process greatly; you still define your meta-models, but the ATL language is used for model to model transformations rather than running generators and writing Java code. openArchitectureWare uses a similar process to AndroMDA 4.

Fast transformation/code generation cycles

Developers rightly don’t have much patience for anything that significantly slows down the code-compile-test cycle. Agile development and refactoring techniques call for continuous code-compile-test cycles. Because in an MDA approach, the model (expressed as UML or some other form) is part of the code, the model will be updated and transformed to code frequently. Practically, this means that MDA tools should support running transformation directly in the modeling tool and IDE, and should support incremental transformations, so the entire application does not have to be regenerated for small changes.

Capable open source UML tools

I’ll happily fork over money for a commercial product that works well and is reasonably priced, but there are many people and software development groups that will be much less likely to try something out if there’s a significant price tag involved, especially when you’re not even sure it’ll work for you long term. There’s also a subset of open source developers for whom relying on a commercial tool, regardless of the price, is a non-starter. For MDA to gain wider adoption, a capable open source UML 2.0 tool is needed. That’s not to say there shouldn’t be commercial offerings, just that at least one viable open source option is needed. ArgoUML is the closest candidate I’ve seen.

Support for textual models

Some types of models don’t lend themselves to expression via UML. For these cases, the MDA tool should support models expressed via other formats, such as text-based models (e.g. a declarative language). The MDA tool should be able to combine information from multiple models, some in UML, and some in other formats, during a transformation cycle. The MDA developer can then use the format that best fits the model to be expressed. openArchitectureWare supports non-UML models, including text-based languages. It looks like AndroMDA 4 utilizes EMF, which supports models in various formats.

Standardized meta-models

A meta-model defines the language that is used to model a particular domain. In UML terms, it defines the stereotypes that may be attached to the various classes, attributes, associations, and other elements, as well as the tags that may be used to provide additional information to the MDA transformations. Currently, each MDA tool defines its own, different, meta-model. So although modeling an Entity class for one MDA tool may be very similar to modeling an Entity class for another MDA tool, they are incompatible. Wherever possible, MDA tools should start supporting each other’s meta-models, creating de-facto standards over time. Where an existing meta-model doesn’t meet their needs, MDA tools should attempt to extend an existing meta-model rather than creating a new one. This would allow development teams to more easily port a model from one MDA tool to another and would reassure teams their investment in a model will not be wasted.

Intelligent refactoring

Refactoring refers to techniques for making improvements to code without altering its behavior. “Improving the Design of Existing Code” as Kent Beck’s seminal book puts it. In an MDA-based system, refactorings frequently span both the model as well as the hand-written code. A simple example of this is the “Rename method” refactoring. If a method is renamed in a UML model, when the model-to-code transformation occurs, there very well may be hand-written subclasses that must also rename the method, and other classes that invoke the renamed method that need to be updated. Modern IDEs have built in support for the most common refactorings, and will apply those related changes for you. MDA tools should be able to detect the change in the model (the refactoring), and allow the developer to automatically apply the corresponding refactoring changes in their IDE. For this to work, MDA tools will likely have to be integrated more closely with IDEs such as Eclipse and NetBeans via plugins.

Finally, one thing MDA tools do not need:

Round tripping

When introducing MDA tools, I frequently get the remark “you know, I wish tool X would support round-tripping”. Round tripping is a feature found in many modelling tools since the early 90’s, where code could be generated from the UML model, then the code could be modified, and those changes could be synchronized back into the model. Round-tripping and reverse-engineering largely do not apply to MDA. Round-tripping is really only practical if there’s a very close correspondence between the classes being modelled and the code being generated. In UML tools that generate code, there is frequently a single source module that is generated for each class that is modeled. In an MDA transformation, a single class in a UML model may result in several files being generated; a DAO interface, a DAO implementation class, a domain object interface, a domain object implementation class, a hibernate mapping file, and an SQL DDL file. In this case, how should changes to source code map back to the UML model? What if an attribute is added to the domain interface and class but not to the HBM file? What if an attribute is renamed in one but not the others? I think the request for this feature is really a band-aid for some other problem, such as: being too restrictive in who can update the model, code generation cycles that take too long, or unfamiliarity with UML and modeling.

Posted in MDSD | Tagged | Leave a comment

AndroMDA: customizing code generation templates

AndroMDA is a model driven architecture tool. Model driven architecture tools generate code based on UML models, which UML tools such as Rational Rose have been doing for a long time. The main differences between MDA tools and UML tools with code generation are the sophistication of the code generators and the MDA focus on platform independent models. When using an MDA approach, you typically create models that are not specific to any particular technology or platform (platform independent model). The idea being that you can then plug in different code generators that are specific to the technology platform you want to generate for (e.g. J2EE EJBs, Spring services, or .NET).

There are several MDA tools available, including open source tools AndroMDA and openArchitectureWare. AndroMDA probably has the richest set of cartridges of any MDA tool, commercial or open source.

UML models in AndroMDA are translated into code in two phases. First the input UML model, a platform-independent model, is translated into a platform specific model (e.g. classes representing Hibernate DAOs, Spring service classes). This translation occurs internally within the cartridge, implemented in Java code. In the second phase, the platform specific model is then translated into code (Java code, hibernate configurations, Spring configurations, etc) via velocity templates.

After working with MDA tools for a while, it’s common to want to customize the code generation process. In AndroMDA, simple customizations can be made by modifying the velocity templates that generate the code from the platform specific model. Following is how it’s done in AndroMDA 3.2:

Find the right template
AndroMDA is distributed as a set of plugins that run within Maven, and the code generation cartridges are also Maven plugins. The easiest way to find the template to customize is to open the cartridge jar where the templates are stored. For me, the cartridge jars are all in /Users/ron/.m2/repository/org/andromda/cartridges/. Open one of the cartridge jars, such as andromda-spring-cartridge/3.2/andromda-spring-cartridge-3.2.jar, using a zip tool or jar to find the template you wish to customize. The velocity templates end in .vsl.

Create a directory for the customized templates within your AndroMDA project.
Next, create a directory within your AndroMDA project for any templates you’ll customize. In my case I created the directory mda/src/main/config/custom/spring for any custom Spring templates. Later on we’ll point the code generation cartridges at this directory in order for them to use our customized templates ahead of the templates found in the cartridge jar files.

Extract the templates you want to customize from the jar file onto the created directory.
Extract the template(s) you wish to customize onto the just created directory. Be sure to keep the same directory structure as in the jar file. For instance, if customizing SpringService.vsl, in my example you’d extract this template file onto mda/src/main/config/custom/spring/templates/spring/SpringService.vsl.

Edit andromda.xml and insert a merge location pointing to the directory where you’re storing your customized templates
The merge location tells AndroMDA where to look for customized templates or other code generation files. Edit the section of the mda/mda/src/main/config/andromda.xml file corresponding to the specific cartridge you are customizing (spring, hibernate, etc). In my case, I insert the following line into the spring section:

<property name=”mergeLocation”>${conf.dir}/custom/spring</property>

Edit your copy of the template, making whatever changes you want

Run the AndroMDA code generation process
Go to your project directory and execute ‘mvn install’.
AndroMDA will look in your directory first for any templates before the looking inside the cartridge zip files.

Posted in MDSD | Tagged | 2 Comments

Mac software I use

For fellow Mac users I know (actually, some of these are cross-platform so apply to Linux and Windows too), here is a list of software I frequently use and would recommend:

  • iTerm – Open source tabbed terminal client (Mac only)
  • Ecto – Blogging client (Mac and Windows versions)
  • Firefox – Open source browser. Fast, full featured, and lots of great plugins (love the web developer tools). Cross-platform.
  • Freemind – Open source mind mapping software. Pure Java so it runs on all major platforms.
  • MacPorts (formerly darwin ports) – This is a collection of open source Unix/Linux software ported to Mac OSX/Darwin as well as a packaging system for easily installing the ports. I’ve used it to install Python 2.5, memcached, MySQL, PostgreSQL, and many more packages.
  • Adium – Open source multi-protocol IM client. Adium uses the Gaim libraries for the multi-protocol stuff. (Mac only)
  • Colloquy – Open source IRC client. I don’t use IRC that much, but when I do, this is the client. (Mac only)
  • Quicksilver – Quicksilver lets you carry out many tasks using a few keystrokes – launch applications, find and open files, send an email to someone in your address book, etc. (Mac only)
  • Growl – An open source notification system for Mac programs – get unobtrusive notifications of chat messages, received emails, finished downloads, etc. (Mac only)
  • NeoOffice – A port of OpenOffice for the Mac.
  • MyEclipse – A commercial distribution of the open source Eclipse IDE with additional plugins.
Posted in Mac | Tagged | Leave a comment

New version of Freemind

I installed a new version of Freemind recently. Freemind is a great program for mind-mapping. I use it for organizing thoughts (papers, project plans, etc.) as well as for keeping notes. One thing I particularly like about Freemind is that you can easily navigate around and author maps using the keyboard – much faster than switching back and forth to the mouse and easier on the wrist.

Mind Manager from Mindjet is also a great piece of software for mind-mapping. It does what it does very well, is intuitive, and doesn’t get in your way. Unfortunately, Mind Manager was a Windows-only program at the time (although they now have a Mac version). When I switched back to Linux and then Mac OSX, I had to find a cross-platform alternative, which is where Freemind comes in.

One thing I noticed with this version (0.9.0 beta9a) of Freemind is that Mac OSX Spotlight is able to find search results in Freemind files. Maybe this isn’t the first version in which this works, but I know I tried it out in a 0.8 release. At any rate, I was glad to see it working because Freemind doesn’t currently have a feature to search across multiple maps – one of the few features of Mind Manager I missed.

Posted in Mac | Tagged | Leave a comment

pyAntTasks moved to Google code

pyAntTasks is a set of Apache Ant tasks to work with Python code I created a while back. Debedb has added a py-cover task to report on code coverage. I recently moved pyAntTasks over to Google code for hosting so it’s easier for people to get the source.

Getting set up on Google code was a breeze… Register your project, get Subversion access, check in the source, and upload the binary distribution. All in all it took about 5 minutes.

Posted in Python | Leave a comment