Quantcast
Channel: Antipodal Apps
Viewing all articles
Browse latest Browse all 12

Organizing Files in Xcode

$
0
0

I’ve been using a fairly traditional approach to organizing files in Xcode for iPhone MVC apps. I have groups for Models, Views, and Controllers. In some cases I have subfolders for Behaviors (under Models) and groups of Controller classes (i.e. subcontrollers). But this is becoming quite cumbersome.

What I think I want to move to is to group files by scene or user story. For example, in ProjectF I have a scene called Results. The Results scene makes use of the following related Objective-C classes

  • ResultsViewController
  • ResultsCommentsScrollSubController
  • ResultsBehavior

I do try to keep the classes loosely coupled, but the truth is they are used together. The UIViewController subclasses have to fetch data from the behavioral model. I think it would make a lot more sense to group these files together in a single Xcode group as I often access them together.  If I used multiple iOS storyboards or XIB files I could  keep them with the classes related to their scenes as well.

That said, I’d even more like to group classes together with their test files! In the above example I have:

  • ResultsViewControllerSpec
  • ResultsCommentsScrollSubcontrollerSpec
  • ResultsBehaviorSpec

I always access these together. These seems more complicated, possible I’m sure, but would sacrifice convenience as the default target Xcode chooses for new files is based on the group. That is, this would mean I’d have to actually remember to set a target when adding new tests.

Do I have the right Object Oriented Design?

I wonder though if the fact that I have to access these files together so often is actually an indication of a problem.

Yesterday, I watched a video of Evan Light’s “If it bleeds it leads“. Evan discussed Martin Fowler’s quote from Principles of Enterprise Application Architecture:

Layers encapsulate some, but not all, things well. As a result you sometimes get cascading changes. The classic example of this in a layered enterprise application is adding a field that needs to display on the UI, must be in the database, and thus must be added to every layer in between.

In a lot of cases I feel like this is what I’m facing. Perhaps, I need to address this problem rather than the organization of the files in my source navigator.

 


Viewing all articles
Browse latest Browse all 12

Latest Images

Trending Articles





Latest Images