Thursday, April 14, 2005

Core Data: the most interesting part of OS X Tiger

Developing with Core Data

This, to me, is the most interesting part of OS X Tiger -- though Tiger's metadata model is also very interesting.
Core Data, new in Tiger, completes the Cocoa vision for building well-factored applications based on the Model-View-Controller (MVC) pattern by providing a strong, flexible, and powerful data model framework...

...Firstly, in the same way that Interface Builder vastly simplifies creating user interfaces, Core Data lets you quickly define your application's data model in a graphic way and easily access it from your code. Secondly, Core Data provides an infrastructure to deal with common functionality such as undo and redo and data persistence, allowing you to get on with the task of building innovation into your application.

... The technically correct way to describe Core Data is as an object-graph management and persistence framework...

... Core Data builds on some of the concepts of enterprise-class database application frameworks, such as the Enterprise Objects Framework in WebObjects...

...All changes to the objects managed by Core Data happen in memory and are transient until they are committed to disk. To commit changes to the data model to disk, simply send a save: message to the managed object context. This behavior preserves the traditional document semantics that users expect in document-based applications.

... In Tiger, Core Data support three different kinds of data store formats to save managed objects contexts to. These formats are:

* XML file format
* Binary archive file format
* SQLite database file format

Each of these formats has its strengths and weaknesses. The XML format is a good testing format as it is fairly human readable. The binary format is not human readable, but provides better performance than the XML format. Both of these formats are atomic—in other words, the entire data model is read from disk and saved to disk in a single operation.

The last format, the SQLite format, is the most scalable and fastest. SQLite is an open source embedded database that is included in Tiger and has many properties which make it an ideal data storage layer for Core Data.
I have a feeble hope that we'll get a "pro" version of iPhoto based on this framework that will actually, maybe, perhaps ... work.

1 comment:

  1. I too want a better IPhoto. But lately I have been thinking that Spotlight will save us, not CoreData.

    Consider a process where all you do to import your photos is to dump them all in one directory. Then, you add ratings and keywords as metadata on the files. Spotlight smartfolders will then segregate your photos into albums and so on.

    This doesn't get you image editing and image sharing (books, email, etc.) but thsoe services are available outside of Iphoto. The big win is that the voodoo is gone. Our image collection is just using files and their metadata.

    ReplyDelete