Object Oriented Programming, Project Organization and Code Documentation
Most good programmers do programming not because they expect to get paid or adulation by the public, but because it is fun to program.
- Linus Torvalds
If you read from the very beginning of the book and have worked through all the projects, you've gone pretty far. By now, you should be able to build an iPhone app with navigation controllers and table views using Interface Builder. We'll further enhance the FoodPin app, and improve the detail view. Did you manage to complete the previous exercise and develop your own detail view? This shouldn't be difficult to implement if you understand the materials and I intentionally left out that part for you as an exercise.
Anyway, we'll revisit it and show you how to improve the detail screen. But before that, I have to introduce to you the basics of Object Oriented Programming. In the next chapter, we'll build on top of what we'll learn in this chapter and enhance the detail view screen.
Don't be scared by the term "Object Oriented Programming" or OOP in short. It's not a new kind of programming language, but a programming concept. While some programming books start out by introducing the OOP concept, I purposely left it out when I began writing the book. I want to keep things simple and show you how to create an app. I don't want to scare you away from building apps, just because of a technical term or concept. Having said that, I think it's time to discuss OOP. As you're still reading the book, I believe you're determined to learn iOS programming, and you want to take programming skills to the next level.
Okay, let's get started.
The Basic Theory of Object Oriented Programming
Like Objective-C, Swift is known as an Object Oriented Programming (OOP) language. OOP is a way of constructing software application composed of objects. In other words, the code written in an app in some ways deals with objects of some kinds. The
UITableView objects that you have used are some sample objects that come with the iOS SDK. Not only can you use the built-in objects, you have already created your own objects in the project, such as
First, why OOP? One important reason is that we want to decompose complex software into smaller pieces (or building block) which are easier to develop and manage. Here, the smaller pieces are the objects. Each object has its own responsibility, and objects coordinate with each other in order to make the software work. That is the basic concept of OOP. ￼ To continue reading and access the full version of the book, please get the full copy here. You will also be able to access the full source code of the project.