iOS Development

Model

Michael L. Collard, Ph.D.

Department of Computer Science, The University of Akron

Major Parts of iOS Application

  • UI code - what the user sees and interacts with
    • View - What the user sees
    • Controller - How the user interacts with the
  • Data code - information viewed and controlled by the user
    • Model - Basic data

MVC

  • Model-View-Controller
  • Basic design pattern
  • Many variations
  • Most important architectural feature of your application

Pure MVC

  • Separate classes for View, Controller, and Model
  • Separate classes for each View and Controller
  • Why?

Major Design Characteristics

  • cohesion - how the parts of a class interact
    • High cohesion → good, low cohesion → bad
  • coupling - how different classes interact
    • Low coupling → good, high coupling → bad
    • Want system to be decoupled

Example: srcML Architecture

<unit xmlns="http://www.sdml.info/srcML/src" xmlns:cpp="http://www.sdml.info/srcML/cpp" language="C++" filename="main.cpp"/>
  • CLI client, srcml, which converts from src → srcml
    • Handles multiple input sources, e.g., file, directory, URL, archive (.tar.gz), etc.
    • Includes parser for C, C++, Java, and C#

srcML Design

  • Problem: To use srcML in your program, must run CLI srcml client
    • Clunky and inefficient
    • Client features were too coupled to parsing features
  • Solution: Decouple parsing from file handling
    • Create separate callable library, libsrcml, and have client use it (much more difficult and costly then you would think)
    • Allow other programs to also call it
  • Other examples: diff utility (no libdiff), gcc (no libgcc), clang and llvm (separate libraries)

Why not go further?

  • Separate parsers for C, C++, Java, and C#!
  • That way you only get what you need
  • Problem: These parsers are tightly coupled, difficult to separate
  • Problem: Separating entails a lot of overlap
  • General Issue: What about new languages? Another mechanism for that

iOS Coupling

  • At an application level, most Apps are decoupled
    • Ex. MS Excel vs separate apps
  • Strong relationship between data in app and what is going to be displayed
  • Tend to rewrite app due to new iOS features and UI

iOS MVC

  • Could be pure MVC, but is not always needed
  • Question 1: Where is the Model?
    • In a ViewController (i.e., tightly coupled)?
  • Question 2: How do ViewControllers share data?

For 3460:489

  • Where you choose to put the Model is up to you
  • However, think about this issue as you develop