| Database | Core Data |
| Primary function is storing and fetching data | Primary function is graph management (although reading and writing to disk is an important supporting feature) |
| Operates on data stored on disk (or minimally and incrementally loaded) | Operates on objects stored in memory (although they can be lazily loaded from disk) |
| Stores "dumb" data | Works with fully-fledged objects that self-manage a lot of their behavior and can be subclassed and customized for further behaviors |
| Can be transactional, thread-safe, multi-user | Non-transactional, single threaded, single user (unless you create an entire abstraction around Core Data which provides these things) |
| Can drop tables and edit data without loading into memory | Only operates in memory |
| Perpetually saved to disk (and often crash resilient) | Requires a save process |
| Can be slow to create millions of new rows | Can create millions of new objects in-memory very quickly (although saving these objects will be slow) |
| Offers data constraints like "unique" keys | Leaves data constraints to the business logic side of the program |
Closures are self contained chunks of code that can be passed around and used in your code. Closures can capture and store references to any constants or variables from the context in which they are defined. This is know as closing over those variables, hence the name closures. Closures are use intensively in the Cocoa frameworks – which are used to develop iOS or Mac applications. Functions are a special kind of closures. There are three kinds of closures: global functions – they have a name and cannot capture any values nested functions – they have a name and can capture values from their enclosing functions closure expressions – they don’t have a name and can capture values from their context The thing to keep in mind for the moment is that you already have an intuition about closures. They are almost the same as functions but don’t necessarily have a name. // a closure that has no parameters and return a String var hello: () -> ( String ) = { ...
Comments
Post a Comment