As Apple Computer Inc. rolls out Mac OS X 10.4 by touting over 200 updated features, one new element of the operating system—Core Data—is generating a lot interest among developers. In fact, most Mac users will never notice Core Datas existence.
Core Data is a new framework and part of the new Core Services underpinnings for Mac OS Xs Cocoa development environment; it is a unified storage system designed to provide developers with a pre-built functionality for managing model objects, including persistent objects.
Using Core Data, developers can automatically give their applications automatic undo and redo, input validation and the ability to save data to SQL and XML for later retrieval, and even use SQLite as an embedded database engine. Previously, developers seeking to give their applications such functionalities would have to create the storage system, also called the data model, from scratch.
The data model is part of the Model-View-Controller (MVC) design pattern common to desktop applications. The view component is the element the user sees, such as text and window controls. The model component is the data that the application works with and is translated to the view; the model can be items stored in a database, strings or other abstracted forms. What translates the model to the view is the controller.
In Mac OS X 10.3, Apple introduced Bindings for Cocoa, which enabled developers to use pre-made controllers rather than having to code their own. Core Data presents the last piece of the puzzle, offering developers a pre-made data model. For a more technical discussion, Apple has a Web page outlining development with Core Data.
The end result, said Brent Simmons, the owner and programmer for Seattle-based Ranchero Software, is that “now it is much easier to write Cocoa applications than ever before. Really, stunningly easy. And you have less code to maintain going forward, which is huge.”
“What Core Data does is allow application developers to stop wasting time worrying about and writing code for modeling and saving program information to disk,” said Evan DiBiase, an engineer and architect for desktop Java applications.
DiBiase used the example of writing a music library application. Prior to Core Data, he said, “Id have to start by writing code to store information about songs, artists and albums. Then Id have to write lots of lines of code to make sure that artists could have many albums and that albums could have many songs.” Similarly, DiBiase said, he also had to code and test so that the information wasnt forgotten after quitting the program, and he had to write more code to add undo and redo features, and then test and debug.
“With Core Data,” he said, “all this is taken care of for me. It might take 5 minutes if Im slow on the mouse that day.”
Simmons also provided examples of Core Datas benefit to developers. “E-mail applications, Usenet and RSS readers, Weblog editors, calendars and so on could all use Core Data, since theyre all database-like applications. A text editor is less likely to use Core Data,” he said.
Simmons said hes looking at using Core Data for developing future applications, but he noted that “for a mature application, it probably wont make much sense to switch [to Core Data], assuming the data handling is already well-done.”
Core Data is not without shortcomings, though, said DiBiase. Currently, he noted, Core Data cannot store data to a relational database, such as PostgreSQL or Oracle.
As a result, he said, he doesnt think that well start seeing many more applications built with Core Data that can interact with remote databases. However, DiBiase said, developers wanting such functionality could work with Core Datas ability to model data and write custom code to align the applications data with such a database.
However, though DiBiase noted that Core Data allows “more agile development” and “support for the basics”, which could result in a surge in small applications from hobbyists, Core Datas benefits can seem small to large software companies who maintain their own code bases for their mature applications. As a result, Simmons noted, Core Data may not be as compelling a draw to the Mac OS X for established software companies.
“Mac OS X is quite attractive to developers already. But being attractive and compelling are two different things,” he said. “Im not sure where the tipping point is, or if this is it.”