Live data from Hacker News

NYTimes Objective–C Style Guide

github.com

11–20 of 51 posts

Re: NYTimes Objective–C Style Guide

#11
I hate absurdly long variable names like this:

    static const NSTimeInterval NYTArticleViewControllerNavigationFadeAnimationDuration = 0.3;
I feel like if your naming convention forces you to have variable names over 50 letters long, there is a problem.

Re: NYTimes Objective–C Style Guide

#12

I hate absurdly long variable names like this: static const NSTimeInterval NYTArticleViewControllerNavigationFadeAnimationDuration = 0.3; I feel like if your naming convention forces you to have variable names over 50 letters long, there is a problem.

Objective-C's tendency to long names (variables, selectors, classes) makes it more "self-documenting" than any language I've worked with. Besides, it's not that bad with autocomplete.

Re: NYTimes Objective–C Style Guide

#13

I hate absurdly long variable names like this: static const NSTimeInterval NYTArticleViewControllerNavigationFadeAnimationDuration = 0.3; I feel like if your naming convention forces you to have variable names over 50 letters long, there is a problem.

It's also a sign that your language lacks namespaces.

Re: NYTimes Objective–C Style Guide

#14
post #12

I hate absurdly long variable names like this: static const NSTimeInterval NYTArticleViewControllerNavigationFadeAnimationDuration = 0.3; I feel like if your naming convention forces you to have variable names over 50 letters long, there is a problem.

Objective-C's tendency to long names (variables, selectors, classes) makes it more "self-documenting" than any language I've worked with. Besides, it's not that bad with autocomplete.

Now if only that autocomplete would passively infer the current project prefix + (super)class name, so you wouldn't have to type it when it's "local"...

Re: NYTimes Objective–C Style Guide

#15
post #13

I hate absurdly long variable names like this: static const NSTimeInterval NYTArticleViewControllerNavigationFadeAnimationDuration = 0.3; I feel like if your naming convention forces you to have variable names over 50 letters long, there is a problem.

It's also a sign that your language lacks namespaces.

Right, if only it used C#! Then it could use nice short names like ListViewVirtualItemsSelectionRangeChangedEventHandler or DataGridViewColumnDividerDoubleClickEventArgs.

Re: NYTimes Objective–C Style Guide

#16
post #13

Earlier quoted context omitted.

It's also a sign that your language lacks namespaces.

Right, if only it used C#! Then it could use nice short names like ListViewVirtualItemsSelectionRangeChangedEventHandler or DataGridViewColumnDividerDoubleClickEventArgs.

haha, you win this round :) though using a Microsoft (or Java) codebase might be considered cheating.

Re: NYTimes Objective–C Style Guide

#17
post #2

> Asterisks indicating pointers belong with the variable, i.e. NSString text not NSString text or NSString * text, except in the case of global string constants. I know I have it wrong, but I always feel that the the variable is of type "pointer to type" so isnt it fairer to have the asterisk paired with the type denoting it is of the kind "pointer to type"?

You don't have it wrong. In an object-oriented context, whether you're working in C, C++, or Obj-C, it is entirely reasonable to attach the asterisk to the type name, and treat `MyObject* ` as a type.

For every weird little edge case where `MyObject* ` doesn't make sense, there are hundreds of examples where it makes complete sense.

I've been doing it that way since I started in the 90s, and I've always felt the people who do it the old way (attaching the asterisk to the variable name) are either holding on to an obsolete bit of antique C style, or they don't know what they're doing. It has no place in modern object-oriented code.

So what about `int* a, b, c;`? Never declare multiple variables on one line like this.

Re: NYTimes Objective–C Style Guide

#20
post #13

Earlier quoted context omitted.

It's also a sign that your language lacks namespaces.

Right, if only it used C#! Then it could use nice short names like ListViewVirtualItemsSelectionRangeChangedEventHandler or DataGridViewColumnDividerDoubleClickEventArgs.

Oh god. That's an artifact of the idiotic VB-style, non-generic event handling "pattern". If event handlers used normal functions like everything else this just wouldn't be a problem (those types just wouldn't exist).
Post reply on HN