Descriptive naming



  • Been working on a maintenance job which fortunately is paid hourly. I was trying to track down a lovely bad access crash on a pre-ARC iOS build, and came across a mysterious source folder in XCode just called "object". Within this folder was a definition for an interface called 'MyObject'. How descriptive!

    @interface MyObject : NSObject {

    NSDate *myDate;



    NSData *myData;



    NSString *_from;



    NSString *_to;



    NSInteger locationID;



    }

    That's the entire thing. Searching through the rest of the source files to find where this bloody thing is used, I come across a couple of declarations which look like:

    MyObject *object;

    That's right, an instance of MyObject called object. Results in this kind of lovely readable code:

    object = [[MyObject alloc]init];



    object.myDate = [NSDate date];



    object._from = tmpLocation.startPoint;



    object._to = tmpLocation.endPoint;



    object.locationID = tmpLocation.serverdbID;

    All of which is, of course, buried in the middle of 50-line procedures and uncommented. WHAT DOES IT DO?!?!?!



  • @soupy said:

    WHAT DOES IT DO?!?!?!





    It's there solely to drive the next person to work on it crazy. Congratulations!



  • Use the refactor feature to rename it something like "moogoogaipan", then search the code for places "moogoogaipan" is used.

    HELPFUL TIP!



  • @blakeyrat said:

    Use the refactor feature to rename it something like "Paula", then search the code for places "Brillant" is used.

    HELPFUL TIP!

    FTFY

Log in to reply