How to Use Object-Oriented Design with Non-OO Language for iOS Apps - dummies

How to Use Object-Oriented Design with Non-OO Language for iOS Apps

By Rajiv Ramnath

Although using an Object-oriented (OO) language such as Objective-C to create an iOS app naturally forces you to think in an object-oriented manner, you can use OO design thinking even when using a non-OO language.

Start with objects first and then translate each object into a data structure. Next, translate methods to functions that operate on each data structure and declare these functions in the same file as you did the data structure.

You’ll be pretty close to an OO program. Here’s an overview of the development:

  • Analyze: Begin with analysis to identify the following:

    • Objects

    • Object capabilities (also known as its responsibilities, its behavior, its methods, or its functions)

    • Object characteristics (also known as attributes or variables)

  • Consolidate: Identify generalizations and specializations of objects (the Vessel object is a generalization of the Teacup object, which in turn, is a specialization of the Vessel).

  • Write program: Write the actual program by composing interactions among the objects.

  • Reuse: This happens with an entire object.

Object-oriented design is a better way of thinking about and writing programs. The fact that it begins with an analysis means that you come away with a deeper understanding of the domain in which you’re programming.

This understanding will serve you in good stead as you write more programs in that domain, especially if you end up building large-scale software systems comprising many programs that share data and collaborate with each other.

Consider basing your program on the objects in the domain (as opposed to the actions in the domain, that is, the behavior) makes your programs more stable because although many behaviors occur in a domain and behaviors also tend to evolve rapidly in the domain, the objects tend to be more constant.

The fact that you think objects first and then write programs by composing interactions means that reuse is a focus from the start, rather than after the fact.