Skip to main content

Source File Organization

  • Chapter
Learn Objective-C on the Mac
  • 686 Accesses

Abstract

So far, every project we’ve talked about has had all its source code crammed into its main.m file. The main() function and all the @interface and @implementation sections for our classes are piled into the same file. That structure’s fine for small programs and quick hacks, but it doesn’t scale to larger projects. As your program gets bigger, you’ll have a ponderous file to scroll through, making it harder to find stuff. Back in your school days (assuming you’re finished with them), you didn’t put every term paper into the same word processing document (assuming you had word processors). You kept each paper in its own document, with a descriptive name. Likewise, it’s a good idea to split your program’s source code into multiple files, and you can give each one a helpful name. Compartmentalizing your program into smaller files gives you a chance to find important bits of code more quickly, and it helps others get a quick overview when they look at your project. Putting your code in multiple files also makes sending the source for an interesting class to a friend easier: you just pack up a couple of files rather than your entire project. In this chapter, we’ll discuss strategies and ideas for keeping various bits of your program in separate files.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 44.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2009 Mark Dalrymple and Scott Knaster

About this chapter

Cite this chapter

Dalrymple, M., Knaster, S. (2009). Source File Organization. In: Learn Objective-C on the Mac. Apress. https://doi.org/10.1007/978-1-4302-1816-6_6

Download citation

Publish with us

Policies and ethics