Source File Organization
Mark Dalrymple, Scott Knaster · Apress eBooks · 2009
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.
Cited by 0 works. doi:10.1007/978-1-4302-1816-6_6