Titanium 3.3.0: Ti.include() deprecated.

This is one of a series of blogs on new features and (breaking) changes in the upcoming Titanium 3.3.0 and Alloy 1.4.0 releases. Get the beta versions now!


As from Titanium 3.3.0, Ti.Include() is deprecated. For those who do not know the meaning of the word; Deprecation, especially in terms of Appelerator;

Denotes that something should be avoided, this feature is now on notice that it will be removed from future versions of the Titanium SDK.  Apps relying on this feature will either need to be updated or rely on versions of the Titanium SDK prior to the version that has officially removed the feature.

Why is Ti.include() being deprecated?

It is considered an anti-pattern;

A commonly used process, structure or pattern of action that despite initially appearing to be an appropriate and effective response to a problem, typically has more bad consequences than beneficial results, and

A good alternative solution exists that is documented, repeatable and proven to be effective.

I have personally long campaigned for the deprecation of Ti.include(), as have many others.  My views come down to this;

The Ti.include method was a solution fit for another time in Titanium’s history. That time has long since gone. Too many newbies are using Ti.include as if it is the correct pattern to develop their apps against.

The only reason against deprecation is that some older apps still use Ti.include. However using this as a reason only serves to increase the number of apps this will affect.

What does this mean for your apps?

If you do not use Ti.include() – you do not have to make ANY changes.  Your life is easy, go have a coffee.

If your app does use Ti.include() then now is the time to start planning for change.  The good news is the changes you need to make are likely to be very small.

What if you want to keep using Ti.include?

You will only be able to compile your app with the last SDK version that provided the method.  You will no longer be able to use any future SDK that has completed the deprecation process where the feature has been removed.

What is the alternative for Ti.include?

Titanium has evolved significantly since it was first publicly available in June 2009 for mobile development.  During that time it has allowed developers to use many ways to re-use code, each time with increasing benefits.  Ti.include() was one of the first, but it no longer meets the needs of modern app development.

Ideally your apps should be using Alloy in addition to CommonJS, but if you have yet to make transition to the Alloy Framework then using the CommonJS structure is the answer.

Documentation

The Titanium documentation has already been updated to reflect the deprecation.  It has also been update to note that this mechanism is not supported with Alloy projects even before the final removal of the feature.

Final Thought

If you are still using Ti.include() then making the transition away will only have positive effects for your apps.

Related links

Owner of Core 13 Ltd a UK based mobile app development agency. Malcolm is affectionately known by Appcelerator and the big wide world as "The Oracle". With 25 years commercial software development experience from desktop apps to web sites for single users to large enterprises.\n You may have seen some of the many contributions provided within the Titanium Q&A.


Comments

  • Thomas Torr

    I have a nice alloy app but all my code is basically in in my index.js file, and I have no idea how to split the file into smaller segments. I tried Ti.include but I got the error:

    [ERROR] : TypeError: Object false has no method ‘replace’

    Even though there is no object false or method replace used anywhere