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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Rights 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
DOI: https://doi.org/10.1007/978-1-4302-1816-6_6
Publisher Name: Apress
Print ISBN: 978-1-4302-1815-9
Online ISBN: 978-1-4302-1816-6
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)