Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8316117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:17:13+00:00 2026-06-08T21:17:13+00:00

I’ve inherited a long term maintenance code base that has two radically different iPhone

  • 0

I’ve inherited a long term maintenance code base that has two radically different iPhone and iPad views. This has created one large UIViewController class that has ballooned to over 1k lines of code, is a mashup of ISIPAD statements, private vars, properties, iBOutlets/Actions and, for example, uses a UITableView for one implementation and something completely different for another.

To make matters worse the current software pattern relies on subclassing.

Currently we look like this:

ParentVC (both iphone/ipad God class also has xib(xib~ipad) + iboutlets/actions)
      |         |            |
    ChildA    ChildB       ChildC

My initial thought was to take the ParentVC and split it into iPhone/iPad specific classes

               ParentVCBase
         |                     |
     ParentVC_iPad(xib~ipad)  ParentVC_iPhone(xib)
         |                       |
   ChildA/B/C_iPad         ChildA/B/C_iPhone

and spit out the correct Child subclass via a factory call.

The issue I’ve encountered is that each Child overrides a few ParentVC method calls and implements it’s own feature specific methods that are not device specific (keep in mind the main goal of the original subclassing was to share view layout). This design pattern would only work if I were to duplicate code for ChildA_iPhone and ChildB_iPad. I’d rather avoid that as I’ve traded one anti-pattern for another.

I’m a at a bit of a loss here. I’ve almost considered creating the Child classes at runtime (objc/runtime.h), swizzeling the required Child methods from a reference Child class but that doesn’t seem any less of a mess than we currently have. To simply clean up I’ve also considered keeping the ParentVC header (with it’s large list of IBOUTlets, properties, etc) and putting device specific methods into categories to at least separate the functionality until the day a real refactor is needed.

Curious if there are any iOS architects that have had to deal with this at one point in time or how they might deal with it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:17:14+00:00Added an answer on June 8, 2026 at 9:17 pm

    This isn’t an iOS specific question as much as it is a object-oriented design question.

    You definitely want to avoid code duplication. Duplication is the source of much evil.

    In general, what you want do is avoid being restricted by the limitations of inheritance in designing your classes. What you want to move towards is class composition.

    So you could move to a design that looks like this using the bridge pattern:

      ParentVC           --->             ImplementationA
       |    |                               |            |
    ChildA ChildB                 Implementation_iPhone Implementation_iPad
    

    Here, ParentVC has the same class hierarchy as above, but it uses a separate class hierarchy, ImplementationA, for implementation. That class hierarchy breaks down into iPhone and iPad versions. Class ImplementationA holds the guts of the implementation that was in ParentVC.

    Inheritance is a design pattern, but it is just one of many. If you stick to just using that one pattern you’ll get stuck into making bad designs. You need to combine patterns to properly model the system.

    Of course, be sure to use unit tests, as much as possible, to ensure you don’t break anything when you’re making these changes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.