title: How to decompose a Cocoa application into reusable functional parts?
body: <p>Suppose I'd like to <strong>decompose an application into functional parts</strong>. E.g. a customer data management part, a text-formatting part, an invoicing part. I'd prefer be such parts somehow simple but complete applications.</p>
  
  <p>Furthermore, suppose I'd like to design parts, which may be <strong>reused in new or other applications</strong>. E.g. the customers data part could be used in a CRM solution, but as well in an invoicing application.</p>
  
  <p>I'm in search for something like a <a href="http://en.wikipedia.org/wiki/Compound_document" rel="nofollow noreferrer"><strong>compound documents</strong></a> <strong>architecture</strong>.</p>
  
  <p><strong>Questions...</strong></p>
  
  <ul>
  <li>Which <strong>Apple / Cocoa technology</strong> should I use to create such functional parts?</li>
  <li>Would it be possible to enclose in a function part the <strong>data-store and the UI</strong>?</li>
  <li>If true, how could one use a UI of one application / part in another application?</li>
  <li>Does such infrastructure / framework / technology exist for Cocoa?</li>
  </ul>
  
  <p><strong>Probably simpler Questions...</strong></p>
  
  <p>Suppose I have two applications <code>A</code> and <code>B</code>. <code>B</code> <strong>provides an editor</strong> for some <code>B</code>-related data. Suppose <code>B</code>'s editor is fully contained in an NSView subclass. Thus, the edit controls are fully contained inside the subclass. </p>
  
  <ul>
  <li>May I somehow make B's NSView's subclass live appear in an A's windows.</li>
  </ul>
  
  <p>My aim is <strong>not</strong> to live embed <strong>arbitrary</strong> stuff of <code>B</code> in <code>A</code>. It would be OK to instrument <code>A</code> and <code>B</code> by a certain common protocol.</p>
  
  <p><strong>Of interest...</strong></p>
  
  <p>I'm aware of <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/DistrObjects/DistrObjects.html" rel="nofollow noreferrer">Cocoa's distributed objects technology</a>, which allows applications to talk to each other even if they run on different compute nodes. But since <strong>DO simply provides a transport mechanism</strong>, it isn't a solution for my high-level decomposition question.</p>
  
  <p>While an application can <strong>register URL schemes</strong> to be called from other applications, they do not provide enough functionality - since URLs are one way from caller to called. See <a href="http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html" rel="nofollow noreferrer">here</a> and <a href="https://developer.apple.com/library/ios/#featuredarticles/iPhoneURLScheme_Reference/Introduction/Introduction.html" rel="nofollow noreferrer">here</a>.</p>
  
  <p>Apple provides this <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/LoadingCode/Concepts/Plugins.html" rel="nofollow noreferrer">Plug-In Architectures document</a> - but focuses on <strong>one application's own plug-ins</strong>. Furthermore <a href="https://developer.apple.com/library/mac/#documentation/CoreFoundation/Conceptual/CFPlugIns/CFPlugIns.html" rel="nofollow noreferrer">Apple's CFPlugin document</a> might be of interest too (still valid?).</p>
  
  <p><a href="http://cocoawithlove.com/" rel="nofollow noreferrer">Matt Gallagher</a> provides a short overview of various options in <a href="http://cocoawithlove.com/2008/06/five-approaches-to-listening-observing.html" rel="nofollow noreferrer">Five approaches to listening, observing and notifying in Cocoa</a>. Except sending notifications through <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSDistributedNotificationCenter_Class/Reference/Reference.html" rel="nofollow noreferrer"><strong>NSDistributedNotificationCenter</strong></a>, all options are application-local. Thus, the Apple document <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Notifications/Introduction/introNotifications.html" rel="nofollow noreferrer">Notification Programming Topics</a> is of interest, but more as a l<strong>ow-level object transport mechanism</strong>.</p>
  
  <p>I'm pretty sure, that some years ago, a <strong>group of software developers/companies</strong> tried to implement some kind of <strong>dynamic data exchange</strong> at the Cocoa level. Their framework didn't come from Apple. Unfortunately, I don't remember their framework's name.</p>
  
  <p><a href="https://stackoverflow.com/questions/6816542/how-to-open-a-new-application-within-an-existing-nsview-on-os-x">How to open a new application within an existing NSView on OS X?</a></p>
  
  <p><strong>Influenced by...</strong></p>
  
  <p>My question is influenced by <a href="http://developer.android.com/reference/android/content/Intent.html" rel="nofollow noreferrer"><strong>intents</strong> of the Android SDK</a>. Citation:</p>
  
  <p><em>'An Intent provides a facility for performing late runtime binding between the code in different applications. Its most significant use is in the launching of activities, where it can be thought of as the glue between activities. It is basically a passive data structure holding an abstract description of an action to be performed.'</em></p>
  
  <p><strong>Very loosely related...</strong></p>
  
  <ul>
  <li>Web-related: <a href="http://www.infoq.com/news/2012/02/the-object-network#.TzBDoHMYwbU.twitter" rel="nofollow noreferrer">InfoQ article</a> about <a href="http://the-object.net/" rel="nofollow noreferrer">The Object Network: Linking up our APIs</a>. </li>
  <li>A 1993 article by <a href="http://scripting.com/" rel="nofollow noreferrer">Dave Winer</a> about <a href="http://scripting.com/frontier/sdk/macbirdplugins.html" rel="nofollow noreferrer">IOA, an Interactive Object Architecture</a></li>
  </ul>