Is there a way in Cocoa that is currently considered best practice for creating a multi-tier or client server application?
I'm an experienced web developer and I really love Python. I'm new to Cocoa though. The application I'm toying with writing is a patient management system for a large hospital. The system is expected to store huge amounts of data over time but the data transferred during a single session is very light (mostly just text). The communication is assumed to occur over a local network (wired or wireless). It has to be highly secure, of course.
The best I could come up with is to write a Python REST web service and connect to it through the Cocoa app. Maybe I'll even use Python to code the Cocoa app itself.
Looking at Cocoa, I see really great technologies in Cocoa like CoreData but I couldn't find anything similar for client server development. I just want to make sure that I'm not missing anything.
What do you think?
Real world examples will be greatly appreciated.
Thanks in advance.
If you have control of both the client and server, and you can limit the client to OS X only, I second Marc's answer. Cocoa's distributed objects are an amazing technology and make RPC-style client-server apps very easy.
If the requirements above are too restrictive for you, you still have many options available to you in the Cocoa world:
You can code the entire client app in Python using PyObjC. With this approach, you can use the standard network code that you're familiar with from the Python standard library. Twisted also integrates nicely with the Cocoa run loop (examples in the PyObjC example code) and I've had a lot of success using Twisted for network communication from with in a Cocoa app. If you choose to go this route, you may want to code the client app in Objective-C and load the python code as a plugin (using NSBundle). PyObjC's py2app
can compile loadable bundles from python code.
You can use NSURLConnection for high-level access to an HTTP-based server.
Dropping down a level of abstraction, you can use Cocoa's NSStream to implement your network protocol. The class documentation is here, with links to example code demonstrating HTTP and SOAP protocols.
You can drop a further level down and use the CFNetwork classes. NSStream is based on CFNetwork, but you have lower-level control over the line using CFNetwork.
Finally, the Apple technology for client-server architectures is the WebObjects framework.