< Previous PageNext Page > Hide TOC

Choosing Technologies to Match Your Design Goals

Mac OS X has many layers of technology. Before choosing a specific technology to implement a solution, think about the intended role for that technology. Is that technology appropriate for your needs? Is there a better technology available? In some cases, Mac OS X offers several technologies that implement the same behavior but with varying levels of complexity and flexibility. Understanding your operational needs can help you make appropriate choices during design.

As you consider the design of your software, think about your overall goals. The following sections list some of the high-level goals you should strive for in your Mac OS X software. Along with each goal are a list of some technologies that can help you achieve that goal. These lists are not exhaustive but provide you with ideas you might not have considered otherwise. For specific design tips related to these goals, see Apple Human Interface Guidelines.

In this section:

High Performance
Easy to Use
Attractive Appearance
Reliability
Adaptability
Interoperability
Mobility


High Performance

Performance is the perceived measure of how fast or efficient your software is, and it is critical to the success of all software. If your software seems slow, users may be less inclined to buy it. Even software that uses the most optimal algorithms may seem slow if it spends more time processing data than responding to the user.

Developers who have experience programming on other platforms (including Mac OS 9) should take the time to learn about the factors that influence performance on Mac OS X. Understanding these factors can help you make better choices in your design and implementation. For information about performance factors and links to performance-related documentation, see Performance Overview.

Table 7-1 lists several Mac OS X technologies that you can use to improve the performance of your software.

Table 7-1  Technologies for improving performance

Technology

Description

Universal Binaries

Because Macintosh computers may contain PowerPC or Intel processors, it is important to create universal binaries to ensure that your code always runs natively on the user’s computer. Native code runs much faster than emulated code and the Mach-O file format can easily accommodate multiple copies of your executable code in a single package. For information on how to create universal binaries, see Universal Binary Programming Guidelines, Second Edition.

64-bit

Although not appropriate in all cases, providing a 64-bit version of your application can improve performance, especially on Intel-based Macintosh computers. The 64-bit capable Intel processors typically have more hardware registers available for performing calculations and passing function parameters. More registers often leads to better performance. As always, test your code in both 32-bit and 64-bit modes to see if providing a 64-bit version is worthwhile. For more information, see 64-Bit Transition Guide.

NSOperation and NSOperationQueue

Mac OS X v10.5 includes two new Cocoa classes that simplify the process of supporting multiple threads in your application. The NSOperation object acts as a wrapper for encapsulated tasks while the NSOperationQueue object manages the execution of those tasks. Operations support dependency and priority ordering and can be customized to configure the threading environment as needed. For more information about these classes, see Threading Programming Guide.

Threads

With all new Macintosh computers shipping with multi-core processors, one way to take advantage of the extra computing power of these machines is to use threads to exploit any inherent parallelism in your software. Mac OS X implements user-level threads using the POSIX threading package but also supports several higher-level APIs for managing threads. For information about these APIs and threading support in general, see “Threading Support” and Threading Programming Guide.

Instruments and Shark

Apple provides a suite of performance tools for measuring many aspects of your software. Instruments and Shark in particular provide new ways of looking at your application while it runs and analyzing its performance. Use these tools to identify hot spots and gather performance metrics that can help identify potential problems. For more information Instruments, see “Instruments.” For information about Shark and the other performance tools that come with Mac OS X, see “Performance Tools.”

Accelerate Framework

The Accelerate framework provides an API for performing multiple scalar or floating-point operations in parallel by taking advantage of the underlying processor’s vector unit. Because it is tuned for both PowerPC and Intel processor architectures, using the Accelerate framework eliminates the need for you to write custom code for both the AltiVec and SSE vector units. For more information about using this framework, see Accelerate Release Notes.

Lower-level APIs

Mac OS X provides many layers of APIs. As you consider the design of your application, examine the available APIs to find the appropriate tradeoff between performance, simplicity, and flexibility that you need. Usually, lower-level system APIs offer the best performance but are more complicated to use. Conversely, higher-level APIs may be simpler to use but be less flexible. Whenever possible, choose the lowest-level API that you feel comfortable using.

Mac OS X supports many modern and legacy APIs. Most of the legacy APIs derive from the assorted managers that were part of the original Macintosh Toolbox and are now a part of Carbon. While many of these APIs still work in Mac OS X, they are not as efficient as APIs created specifically for Mac OS X. In fact, many APIs that provided the best performance in Mac OS 9 now provide the worst performance in Mac OS X because of fundamental differences in the two architectures.

Note: For specific information about legacy Carbon managers and the recommended replacements for them, see “Carbon Considerations.”

As Mac OS X evolves, the list of APIs and technologies it encompasses may change to meet the needs of developers. As part of this evolution, less efficient interfaces may be deprecated in favor of newer ones. Apple makes these changes only when deemed absolutely necessary and uses the availability macros (defined in /usr/include/AvailabilityMacros.h) to identify deprecated interfaces. When you compile your code, deprecated interfaces also trigger the generation of compiler warnings. Use these warnings to find deprecated interfaces, and then check the corresponding reference documentation or header files to see if there are recommended replacements.

Easy to Use

An easy-to-use program offers a compelling, intuitive experience for the user. It offers elegant solutions to complex problems and has a well thought out interface that uses familiar paradigms. It is easy to install and configure because it makes intelligent choices for the user, but it also gives the user the option to override those choices when needed. It presents the user with tools that are relevant in the current context, eliminating or disabling irrelevant tools. It also warns the user against performing dangerous actions and provides ways to undo those actions if taken.

Table 7-2 lists several Mac OS X technologies that you can use to make your software easier to use.

Table 7-2  Technologies for achieving ease of use

Technology

Description

Aqua

If your program has a visual interface, it should adhere to the human interface guidelines for Aqua, which include tips for how to lay out your interface and manage its complexity. For more information, see “Aqua.”

Quick Look

Introduced in Mac OS X v10.5, Quick Look generates previews of user documents that can be displayed in the Finder and Dock. These previews make it easier for the user to find relevant information quickly without launching any applications. For more information, see “Quick Look.”

Bonjour

Bonjour simplifies the process of configuring and detecting network services. Your program can vend network services or use Bonjour to be a client of an existing network service. For more information, see “Bonjour.”

Accessibility technologies

The Accessibility interfaces for Carbon and Cocoa make it easier for people with disabilities to use your software. For more information, see “Accessibility.”

AppleScript

AppleScript makes it possible for users to automate complex workflows quickly. It also gives users a powerful tool for controlling your application. For more information, see “AppleScript.”

Internationalization

Mac OS X provides significant infrastructure for internationalizing software bundles. For more information, see “Internationalization and Localization.”

Keychain Services

Keychains provide users with secure access to passwords, certificates, and other secret information. Adding support for Keychain Services in your program can reduce the number of times you need to prompt the user for passwords and other secure information. For more information, see “Keychain Services.”

For information on designing an easy-to-use interface, see Apple Human Interface Guidelines.

Attractive Appearance

One feature that draws users to the Macintosh platform, and to Mac OS X in particular, is the stylish design and attractive appearance of the hardware and software. Although creating attractive hardware and system software is Apple’s job, you should take advantage of the strengths of Mac OS X to give your own programs an attractive appearance.

The Finder and other programs that come with Mac OS X use high-resolution, high-quality graphics and icons that include 32-bit color and transparency. You should make sure that your programs also use high-quality graphics both for the sake of appearance and to better convey relevant information to users. For example, the system uses pulsing buttons to identify the most likely choice and transparency effects to add a dimensional quality to windows.

Table 7-3 lists several Mac OS X technologies you can use to ensure that your software has an attractive appearance.

Table 7-3  Technologies for achieving an attractive appearance

Technology

Description

Aqua

Aqua defines the guidelines all developers should follow when crafting their application’s user interface. Following these guidelines ensures that your application looks and feels like a Mac OS X application. For more information, see “Aqua.”

Resolution independence

Screen resolutions continue to increase with most screens now supporting over 100 pixels per inch. In order to prevent content from shrinking too much, Mac OS X will soon apply a scaling factor to drawing operations to keep them at an appropriate size. Your software needs to be ready for this scaling factor by being able to draw more detailed content in the same “logical” drawing area. For more information, see “Resolution-Independent User Interface.”

Core Animation

In Mac OS X v10.5 and later, you can use Core Animation to add advanced graphics behaviors to your software. Core Animation a lightweight mechanism for performing advanced animations in your Cocoa views. For more information, see “Core Animation.”

Quartz

Quartz is the native (and preferred) 2D rendering API for Mac OS X. It provides primitives for rendering text, images, and vector shapes and includes integrated color management and transparency support. For more information, see “Quartz.”

Core Text

In Mac OS X v10.5 and later, Core Text replaces the ATSUI and MLTE technologies as the way to high quality rendering and layout of Unicode text for Carbon and Cocoa applications. The Cocoa text system uses Core Text for its implementation. For more information, see “Core Text.”

Core Image

In Mac OS X v10.4 and later, Core Image provides advanced image processing effects for your application. Core Image makes it possible to manipulate image data in real time using the available hardware rendering and to perform complex manipulations that make your application look stunning. For more information, see “Core Image.”

OpenGL

OpenGL is the preferred 3D rendering API for Mac OS X. The Mac OS X implementation of OpenGL is hardware accelerated on many systems and has all of the standard OpenGL support for shading and textures. See OpenGL Programming Guide for Mac OS X for an overview of OpenGL and guidelines on how to use it. For an example of how to use OpenGL with Cocoa, see the sample code project Cocoa OpenGL.

Reliability

A reliable program is one that earns the user’s trust. Such a program presents information to the user in an expected and desired way. A reliable program maintains the integrity of the user’s data and does everything possible to prevent data loss or corruption. It also has a certain amount of maturity to it and can handle complex situations without crashing.

Reliability is important in all areas of software design, but especially in areas where a program may be running for an extended period of time. For example, scientific programs often perform calculations on large data sets and can take a long time to complete. If such a program were to crash during a long calculation, the scientist could lose days or weeks worth of work.

As you start planning a new project, put some thought into what existing technologies you can leverage from both Mac OS X and the open-source community. For example, if your application displays HTML documents, it doesn’t make sense to write your own HTML parsing engine when you can use the Web Kit framework instead.

By using existing technologies, you reduce your development time by reducing the amount of new code you have to write and test. You also improve the reliability of your software by using code that has already been designed and tested to do what you need.

Using existing technologies has other benefits as well. For many technologies, you may also be able to incorporate future updates and bug fixes for free. Apple provides periodic updates for many of its shipping frameworks and libraries, either through software updates or through new versions of Mac OS X. If your application links to those frameworks, it receives the benefit of those updates automatically.

All of the technologies of Mac OS X offer a high degree of reliability. However, Table 7-4 lists some specific technologies that improve reliability by reducing the amount of complex code you have to write from scratch.

Table 7-4  Technologies for achieving reliability

Technology

Description

Code signing

Code signing associates a digital signature with your application and helps the system determine when your application has changed, possibly because of tampering. When changes occur, the system can warn the user and provide an option for disabling the application. For more information, see “Code Signing.”

Authorization Services

Authorization Services provides a way to ensure that only authorized operations take place. Preventing unauthorized access helps protect your program as well as the rest of the system. See Authorization Services Programming Guide for more information.

Core Foundation

Core Foundation supports basic data types and eliminates the need for you to implement string and collection data types, among others. Both Carbon and Cocoa support the Core Foundation data types, which makes it easier for you to integrate them into your own data structures. See Getting Started with Core Foundation for more information.

Web Kit

The Web Kit provides a reliable, standards-based mechanism for rendering HTML content (including JavaScript code) in your application.

Adaptability

An adaptable program is one that adjusts appropriately to its surroundings; that is, it does not stop working when the current conditions change. If a network connection goes down, an adaptable program lets the user continue to work offline. Similarly, if certain resources are locked or become unavailable, an adaptable program finds other ways to meet the user’s request.

One of the strengths of Mac OS X is its ability to adapt to configuration changes quickly and easily. For example, if the user changes a computer’s network configuration from the system preferences, the changes are automatically picked up by applications such as Safari and Mail, which use CFNetwork to handle network configuration changes automatically.

Table 7-5 lists some Mac OS X technologies that you can use to improve the overall adaptability of your software.

Table 7-5  Technologies for achieving adaptability

Technology

Description

FSEvents API

The FSEvents API lets you detect changes to the file system easily and efficiently. You might use this technology to update your application’s internal data structures whenever changes occur to specific directories or directory hierarchies. For more information, see “FSEvents API.”

Core Foundation

Core Foundation provides services for managing date, time, and number formats based on any locale. See Reference Library > Core Foundation for specific reference documents.

Quartz Services

Quartz Services provides access to screen information and provides notifications when screen information changes. See Quartz Display Services Reference for more information.

Bonjour

Bonjour simplifies the process of configuring and detecting network services. Your program can vend network services or use Bonjour to be a client of an existing network service. For more information, see “Bonjour.”

System Configuration

The System Configuration framework provides information about availability of network entities. See System Configuration Framework Reference and System Configuration Programming Guidelines for more information.

Interoperability

Interoperability refers to a program’s ability to communicate across environments. This communication can occur at either the user or the program level and can involve processes on the current computer or on remote computers. At the program level, an interoperable program supports ways to move data back and forth between itself and other programs. It might therefore support the pasteboard and be able to read file formats from other programs on either the same or a different platform. It also makes sure that the data it creates can be read by other programs on the system.

Users see interoperability in features such as the pasteboard (the Clipboard in the user interface), drag and drop, AppleScript, Bonjour, and services in the Services menu. All of these features provide ways for the user to get data into or out of an application.

Table 7-6 lists some Mac OS X technologies that you can use to improve the interoperability of your software.

Table 7-6  Technologies for achieving interoperability

Technology

Description

AppleScript

AppleScript is a scripting system that gives users direct control over your application as well as parts of Mac OS X. See AppleScript Overview for information on supporting AppleScript.

Drag and drop

Although primarily implemented in applications, you can add drag and drop support to any program with a user interface. See Drag Manager Reference or Drag and Drop Programming Topics for Cocoa for information on how to integrate drag and drop support into your program.

Pasteboard

Both Carbon and Cocoa support cut, copy, and paste operations through the pasteboard. See the Pasteboard.h header file in the HIServices framework or Pasteboard Programming Topics for Cocoa for information on how to support the pasteboard in your program.

Bonjour

Your program can vend network services or use Bonjour to be a client of an existing network service. For more information, see “Bonjour.”

Services

Services let the user perform a specific operation in your application using data on the pasteboard. Services use the pasteboard to exchange data but act on that data in a more focused manner than a standard copy-and-paste operation. For example, a service might create a new mail message and paste the data into the message body. See Setting Up Your Carbon Application to Use the Services Menu or System Services for information on setting up an application to use services.

XML

XML is a structured format that can be used for data interchange. Mac OS X provides extensive support for reading, writing, and parsing XML data. For more information, see “XML Parsing Libraries.”

Mobility

Designing for mobility has become increasingly important as laptop usage soars. A program that supports mobility doesn’t waste battery power by polling the system or accessing peripherals unnecessarily, nor does it break when the user moves from place to place, changes monitor configurations, puts the computer to sleep, or wakes the computer up.

To support mobility, programs need to be able to adjust to different system configurations, including network configuration changes. Many hardware devices can be plugged in and unplugged while the computer is still running. Mobility-aware programs should respond to these changes gracefully. They should also be sensitive to issues such as power usage. Constantly accessing a hard drive or optical drive can drain the battery of a laptop quickly. Be considerate of mobile users by helping them use their computer longer on a single battery charge.

Table 7-7 lists some Mac OS X technologies that you can use to improve the mobility of your software.

Table 7-7  Technologies for achieving mobility

Technology

Description

Performance

An efficient application uses fewer instructions to compute its data. On portable computers, this improved efficiency translates to power savings and a longer battery life. You should strive to make your applications as efficient as possible using the available system technologies and tools. For more information, see “High Performance.”

CFNetwork

CFNetwork provides a modern interface for accessing network services and handling changes in the network configuration. See CFNetwork Programming Guide for an introduction to the CFNetwork API.

Quartz Services

Quartz Services provides access to screen information and provides notifications when screen information changes. See Quartz Display Services Reference for information about the API.

Bonjour

Bonjour lets mobile users find services easily or vend their own services for others to use. For more information, see “Bonjour.”

System Configuration

The System Configuration framework is the foundation for Apple’s mobility architecture. You can use its interfaces to get configuration and status information for network entities. It also sends out notifications when the configuration or status changes. See System Configuration Programming Guidelines for more information.



< Previous PageNext Page > Hide TOC


© 2004, 2008 Apple Inc. All Rights Reserved. (Last updated: 2008-10-15)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.