Under the Bridge

Dependency Graphing

Here’s a little script to help you delight in/be horrified by your program structure:

nst / objc_dep

…So how do we achieve loose coupling in our own code? Well, at first, we need to get a better idea on the current coupling. Let us define class dependancy: class A depends on B iff class A imports class B header. With such a definition, we can draw a graph of dependancies between classes by considering the Objective-C #import directives in each class. We assume here that the files are named according to the classes they contain.

I wrote objc_dep.py, a Python script which extracts imports from Objective-C source code. The output can then be displayed in GraphViz or OmniGraffle. You can then see an oriented graph of dependancies between classes…

687474703a2f2f736572696f742e63682f626c6f672f706963732f6f626a635f6465702f6c617267657270726f6a6563742e706e67.png

Just the thing to hopelessly confuse those documentation-insisting project managers!

h/t: @jomtwi,@myell0w, maniacdev!  

UPDATES:

Open Source Tool For Automatically Graphing Objective-C Class/Instance Details

0