Giter VIP home page Giter VIP logo

Comments (8)

dkhamsing avatar dkhamsing commented on September 17, 2024

Yeah I find this applicable to views too, for example you can have *messageLabel as opposed to message for a UILabel

from objective-c-style-guide.

cdzombak avatar cdzombak commented on September 17, 2024

I wonder how we could clarify that this is a common (and useful) practice in some but certainly not all cases.

For example, an Article class probably has a title property, which is probably a fine name for it.

I will need to take some time to think through what exactly determines whether this naming style applies in my day-to-day coding.

from objective-c-style-guide.

mbbischoff avatar mbbischoff commented on September 17, 2024

For example, an Article class probably has a title property, which is probably a fine name for it.

Totally agree. This can be helpful, but sometimes gets a bit wordy.

from objective-c-style-guide.

bcapps avatar bcapps commented on September 17, 2024

I mostly disagree with this overall premise. Symbols should be named the most appropriate name. title is a much better name for that property than titleString, because it's obvious that title will be a string. An array of articles would ideally be called articles because expressively that's what it is. But a string representation of a date should definitely be called something like dateString. I think that the rule should be something like only appending the type of the symbol to the variable name if it is unexpected or otherwise unclear. But that is so difficult to codify for anything other than variables that include one type in their name but are actually another.

This is especially important when dealing with a variable that is not precisely the semantic type it sounds like

I agree, but I think that this is actually the only time we should follow this as a rule.

from objective-c-style-guide.

paulbruneau avatar paulbruneau commented on September 17, 2024

Capps' description matches my practice. I put the type after rarely used classes too like blahBlahIndexPath for example

from objective-c-style-guide.

cdzombak avatar cdzombak commented on September 17, 2024

I think that the rule should be something like only appending the type of the symbol to the variable name if it is unexpected or otherwise unclear.

Agreed.

I think the key point is that the name should clearly represent what the symbol is, which just sounds like common sense. Consider the following examples, which I would consider good names:

  • NSString *title: It is reasonable to assume a "title" is a string. No further clarification needed.
  • NSString *titleHTML: A title, which may contain HTML which should be parsed for display. "HTML" is needed for the programmer to use this variable properly.
  • NSAttributedString *titleAttributedString: A title, formatted for display.
  • articles: Could be an array or set of articles; either way, it's a collection containing n articles.
  • NSDate *now
  • NSDate *lastModifiedDate: Simply lastModified is ambiguous; one could reasonably assume it is one of a few different things.
  • NSURL *url vs. NSString *urlString, for obvious reasons

from objective-c-style-guide.

mbbischoff avatar mbbischoff commented on September 17, 2024

Totally agree with @cdzombak here. Not sure how we can write it up in the guide, but it makes complete sense.

from objective-c-style-guide.

cdzombak avatar cdzombak commented on September 17, 2024

Totally agree with @cdzombak here. Not sure how we can write it up in the guide, but it makes complete sense.

Written in #108.

from objective-c-style-guide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.