Lesson 7
Object-Oriented Programming with Swift
Over the years, computer application developers have developed various strategies to create applications that can solve complex problems. One of the earliest approaches to problem solving was the concept of structured programming.
Structured programming (which predates object-oriented programming) centered on a divide-and-conquer philosophy. A complex program was broken down into a set of tasks, and then each task into a set of simpler sub-tasks. A key feature of structured programming is that there is a clear separation between data and the code that operates on that data.
Structured programming is still in use in some types of applications today, but it has a few drawbacks:
- People generally think of data (account numbers) and what they can do with it (compute balance, interest, and so on) as related concepts. It is not natural to think of them in isolation.
- Programmers were constantly reinventing the wheel, creating solutions for things that had been solved over and over again by others. Structured programming did not address the need to reuse existing functions (either written by you or someone else) conveniently.
- A new approach to programming, object-oriented programming (OOP), was created. Essentially, OOP tries to address the deficiencies in the structured programming model by:
- Providing techniques to achieve re-use of software components.
- Coupling data with the functions that act on them.
Core to object-oriented programming ...
Get Swift iOS 24-Hour Trainer now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.