FC001, attributes as strings vs symbols

Ohai, Chefs!

We want to hear from you: which way of using node attributes do you prefer? Please take this single question survey:

http://www.surveygizmo.com/s3/1059291/FC001-Use-strings-in-preference-to-symbols-to-access-node-attributes

This is in response to a longer twitter discussion today on the subject. The survey will be left open for awhile, letting as many people as possible answer. We really value this feedback.

If you want an explanation of why this rule came about the way it did, and our rationale for preferring strings to symbols, see this issue in the Foodcritic project:

If you're going to be at the Chef summit next week, I'm happy to discuss this in greater detail, too :-).

As a maintainer of in-house and 3rd party cookbooks for my organization, I
find FC001 too noisy to be useful. We haven't yet modernized our repo to
include every single cookbook as a self-contained repo, and in some cases
find little benefit in doing so. New cookbooks follow FC001 and other best
practices that didn't yet exist or weren't widely known at the time, so
this rule is mostly ignored for now and we test for the desired outcome
instead.

Jeremy

On Tue, Oct 16, 2012 at 11:28 AM, Joshua Timberman joshua@opscode.comwrote:

Ohai, Chefs!

We want to hear from you: which way of using node attributes do you
prefer? Please take this single question survey:

FC001 - Use strings in preference to symbols to access node attributes

This is in response to a longer twitter discussion today on the subject.
The survey will be left open for awhile, letting as many people as possible
answer. We really value this feedback.

If you want an explanation of why this rule came about the way it did, and
our rationale for preferring strings to symbols, see this issue in the
Foodcritic project:

Rule FC001 contrary to Opscode recommendation · Issue #1 · Foodcritic/foodcritic · GitHub

If you're going to be at the Chef summit next week, I'm happy to discuss
this in greater detail, too :-).

I agree with the too noisy sentiment. I think that being consistent in
a cook is good, but I personally prefer symbols and enforcing a no -'s
in attrib names. Of course there are exceptions that you run into, and
you have to use strings. I find symbols easier on the eyes and
fingers.

Jesse Nelson

On Tue, Oct 16, 2012 at 12:21 PM, Jeremy Voorhis jvoorhis@gmail.com wrote:

As a maintainer of in-house and 3rd party cookbooks for my organization, I
find FC001 too noisy to be useful. We haven't yet modernized our repo to
include every single cookbook as a self-contained repo, and in some cases
find little benefit in doing so. New cookbooks follow FC001 and other best
practices that didn't yet exist or weren't widely known at the time, so this
rule is mostly ignored for now and we test for the desired outcome instead.

Jeremy

On Tue, Oct 16, 2012 at 11:28 AM, Joshua Timberman joshua@opscode.com
wrote:

Ohai, Chefs!

We want to hear from you: which way of using node attributes do you
prefer? Please take this single question survey:

FC001 - Use strings in preference to symbols to access node attributes

This is in response to a longer twitter discussion today on the subject.
The survey will be left open for awhile, letting as many people as possible
answer. We really value this feedback.

If you want an explanation of why this rule came about the way it did, and
our rationale for preferring strings to symbols, see this issue in the
Foodcritic project:

Rule FC001 contrary to Opscode recommendation · Issue #1 · Foodcritic/foodcritic · GitHub

If you're going to be at the Chef summit next week, I'm happy to discuss
this in greater detail, too :-).

Why add unnecessary constraints?
What do we gain by stopping people from using -'s and other marks in
attributes?

It doesn't particularly affect me either way because I don't do it, but
I'm not sure I see a particular benefit in restricting such practices.

Paul

On 10/16/2012 10:13 AM, Jesse Nelson wrote:

I agree with the too noisy sentiment. I think that being consistent in
a cook is good, but I personally prefer symbols and enforcing a no -'s
in attrib names. Of course there are exceptions that you run into, and
you have to use strings. I find symbols easier on the eyes and
fingers.

Jesse Nelson

On Tue, Oct 16, 2012 at 12:21 PM, Jeremy Voorhis jvoorhis@gmail.com wrote:

As a maintainer of in-house and 3rd party cookbooks for my organization, I
find FC001 too noisy to be useful. We haven't yet modernized our repo to
include every single cookbook as a self-contained repo, and in some cases
find little benefit in doing so. New cookbooks follow FC001 and other best
practices that didn't yet exist or weren't widely known at the time, so this
rule is mostly ignored for now and we test for the desired outcome instead.

Jeremy

On Tue, Oct 16, 2012 at 11:28 AM, Joshua Timberman joshua@opscode.com
wrote:

Ohai, Chefs!

We want to hear from you: which way of using node attributes do you
prefer? Please take this single question survey:

FC001 - Use strings in preference to symbols to access node attributes

This is in response to a longer twitter discussion today on the subject.
The survey will be left open for awhile, letting as many people as possible
answer. We really value this feedback.

If you want an explanation of why this rule came about the way it did, and
our rationale for preferring strings to symbols, see this issue in the
Foodcritic project:

Rule FC001 contrary to Opscode recommendation · Issue #1 · Foodcritic/foodcritic · GitHub

If you're going to be at the Chef summit next week, I'm happy to discuss
this in greater detail, too :-).

I think string should be two options. Should interpolated string
attributes be encouraged if the situation does not call for it? I think
it is a fuzzy definition as it stands for FC001. Sorry in advance, for
harping over a bikeshed.

  • As an interpolated string (node["my_attribute"]).
  • As a literal string (node['my_attribute']).

Missing option:

  • Don't really care as long as the style is consistent.

Eric G. Wolfe
Senior Linux Administrator,
IT Infrastructure Systems

Marshall University Computing Services
Drinko Library 428-K
One John Marshall Dr.
Huntington, WV 25755
Phone: 304.942.3970
Email: eric.wolfe@marshall.edu

You will be recognized and honored as a community leader.

On 10/16/2012 02:28 PM, Joshua Timberman wrote:

Ohai, Chefs!

We want to hear from you: which way of using node attributes do you prefer? Please take this single question survey:

FC001 - Use strings in preference to symbols to access node attributes

This is in response to a longer twitter discussion today on the subject. The survey will be left open for awhile, letting as many people as possible answer. We really value this feedback.

If you want an explanation of why this rule came about the way it did, and our rationale for preferring strings to symbols, see this issue in the Foodcritic project:

Rule FC001 contrary to Opscode recommendation · Issue #1 · Foodcritic/foodcritic · GitHub

If you're going to be at the Chef summit next week, I'm happy to discuss this in greater detail, too :-).

I tend to agree with both Jesse and Paul, and FC001 just doesn't seem to
fit in when the attributes hierarchy is mostly in Mashes. Imagine the
backlash if Opscode reverted the Mash to a Hash!

On Tue, Oct 16, 2012 at 1:16 PM, Paul Graydon paul@paulgraydon.co.ukwrote:

Why add unnecessary constraints?
What do we gain by stopping people from using -'s and other marks in
attributes?

It doesn't particularly affect me either way because I don't do it, but
I'm not sure I see a particular benefit in restricting such practices.

Paul

On 10/16/2012 10:13 AM, Jesse Nelson wrote:

I agree with the too noisy sentiment. I think that being consistent in
a cook is good, but I personally prefer symbols and enforcing a no -'s
in attrib names. Of course there are exceptions that you run into, and
you have to use strings. I find symbols easier on the eyes and
fingers.

Jesse Nelson

On Tue, Oct 16, 2012 at 12:21 PM, Jeremy Voorhis jvoorhis@gmail.com
wrote:

As a maintainer of in-house and 3rd party cookbooks for my organization,
I
find FC001 too noisy to be useful. We haven't yet modernized our repo to
include every single cookbook as a self-contained repo, and in some cases
find little benefit in doing so. New cookbooks follow FC001 and other
best
practices that didn't yet exist or weren't widely known at the time, so
this
rule is mostly ignored for now and we test for the desired outcome
instead.

Jeremy

On Tue, Oct 16, 2012 at 11:28 AM, Joshua Timberman joshua@opscode.com
wrote:

Ohai, Chefs!

We want to hear from you: which way of using node attributes do you
prefer? Please take this single question survey:

http://www.surveygizmo.com/s3/**1059291/FC001-Use-strings-in-**
preference-to-symbols-to-**access-node-attributeshttp://www.surveygizmo.com/s3/1059291/FC001-Use-strings-in-preference-to-symbols-to-access-node-attributes

This is in response to a longer twitter discussion today on the subject.
The survey will be left open for awhile, letting as many people as
possible
answer. We really value this feedback.

If you want an explanation of why this rule came about the way it did,
and
our rationale for preferring strings to symbols, see this issue in the
Foodcritic project:

https://github.com/acrmp/**foodcritic/issues/1https://github.com/acrmp/foodcritic/issues/1

If you're going to be at the Chef summit next week, I'm happy to discuss
this in greater detail, too :-).

FC019 catches exactly that. And thanks for pointing out that we're
bikeshedding :wink: I think I've exhausted my opinions on the matter..

On Tue, Oct 16, 2012 at 1:18 PM, Eric G. Wolfe eric.wolfe@marshall.eduwrote:

I think string should be two options. Should interpolated string
attributes be encouraged if the situation does not call for it? I think it
is a fuzzy definition as it stands for FC001. Sorry in advance, for
harping over a bikeshed.

  • As an interpolated string (node["my_attribute"]).
  • As a literal string (node['my_attribute']).

Missing option:

  • Don't really care as long as the style is consistent.

Eric G. Wolfe
Senior Linux Administrator,
IT Infrastructure Systems
------------------------------**--------
Marshall University Computing Services
Drinko Library 428-K
One John Marshall Dr.
Huntington, WV 25755
Phone: 304.942.3970
Email: eric.wolfe@marshall.edu

You will be recognized and honored as a community leader.

On 10/16/2012 02:28 PM, Joshua Timberman wrote:

Ohai, Chefs!

We want to hear from you: which way of using node attributes do you
prefer? Please take this single question survey:

http://www.surveygizmo.com/s3/**1059291/FC001-Use-strings-in-**
preference-to-symbols-to-**access-node-attributeshttp://www.surveygizmo.com/s3/1059291/FC001-Use-strings-in-preference-to-symbols-to-access-node-attributes

This is in response to a longer twitter discussion today on the subject.
The survey will be left open for awhile, letting as many people as possible
answer. We really value this feedback.

If you want an explanation of why this rule came about the way it did,
and our rationale for preferring strings to symbols, see this issue in the
Foodcritic project:

https://github.com/acrmp/**foodcritic/issues/1https://github.com/acrmp/foodcritic/issues/1

If you're going to be at the Chef summit next week, I'm happy to discuss
this in greater detail, too :-).

symbols will break in ruby when using -'s

[1] pry(main)> :a-b
NameError: undefined local variable or method b' for main:Object from (pry):1:in pry'
[2] pry(main)> :a_b
=> :a_b

On Tue, Oct 16, 2012 at 1:16 PM, Paul Graydon paul@paulgraydon.co.uk wrote:

Why add unnecessary constraints?
What do we gain by stopping people from using -'s and other marks in
attributes?

It doesn't particularly affect me either way because I don't do it, but I'm
not sure I see a particular benefit in restricting such practices.

Paul

On 10/16/2012 10:13 AM, Jesse Nelson wrote:

I agree with the too noisy sentiment. I think that being consistent in
a cook is good, but I personally prefer symbols and enforcing a no -'s
in attrib names. Of course there are exceptions that you run into, and
you have to use strings. I find symbols easier on the eyes and
fingers.

Jesse Nelson

On Tue, Oct 16, 2012 at 12:21 PM, Jeremy Voorhis jvoorhis@gmail.com
wrote:

As a maintainer of in-house and 3rd party cookbooks for my organization,
I
find FC001 too noisy to be useful. We haven't yet modernized our repo to
include every single cookbook as a self-contained repo, and in some cases
find little benefit in doing so. New cookbooks follow FC001 and other
best
practices that didn't yet exist or weren't widely known at the time, so
this
rule is mostly ignored for now and we test for the desired outcome
instead.

Jeremy

On Tue, Oct 16, 2012 at 11:28 AM, Joshua Timberman joshua@opscode.com
wrote:

Ohai, Chefs!

We want to hear from you: which way of using node attributes do you
prefer? Please take this single question survey:

FC001 - Use strings in preference to symbols to access node attributes

This is in response to a longer twitter discussion today on the subject.
The survey will be left open for awhile, letting as many people as
possible
answer. We really value this feedback.

If you want an explanation of why this rule came about the way it did,
and
our rationale for preferring strings to symbols, see this issue in the
Foodcritic project:

Rule FC001 contrary to Opscode recommendation · Issue #1 · Foodcritic/foodcritic · GitHub

If you're going to be at the Chef summit next week, I'm happy to discuss
this in greater detail, too :-).

Actually, symbols do work w/ -'s, you just have to wrap them in quotes:

1.9.3-p194 :002 > :"a-b"

  • => :"a-b" *
    *1.9.3-p194 :003 > *

-John

On Tue, Oct 16, 2012 at 4:23 PM, Jesse Nelson spheromak@gmail.com wrote:

symbols will break in ruby when using -'s

[1] pry(main)> :a-b
NameError: undefined local variable or method b' for main:Object from (pry):1:in pry'
[2] pry(main)> :a_b
=> :a_b

On Tue, Oct 16, 2012 at 1:16 PM, Paul Graydon paul@paulgraydon.co.uk
wrote:

Why add unnecessary constraints?
What do we gain by stopping people from using -'s and other marks in
attributes?

It doesn't particularly affect me either way because I don't do it, but
I'm
not sure I see a particular benefit in restricting such practices.

Paul

On 10/16/2012 10:13 AM, Jesse Nelson wrote:

I agree with the too noisy sentiment. I think that being consistent in
a cook is good, but I personally prefer symbols and enforcing a no -'s
in attrib names. Of course there are exceptions that you run into, and
you have to use strings. I find symbols easier on the eyes and
fingers.

Jesse Nelson

On Tue, Oct 16, 2012 at 12:21 PM, Jeremy Voorhis jvoorhis@gmail.com
wrote:

As a maintainer of in-house and 3rd party cookbooks for my
organization,
I
find FC001 too noisy to be useful. We haven't yet modernized our repo
to
include every single cookbook as a self-contained repo, and in some
cases
find little benefit in doing so. New cookbooks follow FC001 and other
best
practices that didn't yet exist or weren't widely known at the time, so
this
rule is mostly ignored for now and we test for the desired outcome
instead.

Jeremy

On Tue, Oct 16, 2012 at 11:28 AM, Joshua Timberman <joshua@opscode.com

wrote:

Ohai, Chefs!

We want to hear from you: which way of using node attributes do you
prefer? Please take this single question survey:

FC001 - Use strings in preference to symbols to access node attributes

This is in response to a longer twitter discussion today on the
subject.
The survey will be left open for awhile, letting as many people as
possible
answer. We really value this feedback.

If you want an explanation of why this rule came about the way it did,
and
our rationale for preferring strings to symbols, see this issue in the
Foodcritic project:

Rule FC001 contrary to Opscode recommendation · Issue #1 · Foodcritic/foodcritic · GitHub

If you're going to be at the Chef summit next week, I'm happy to
discuss
this in greater detail, too :-).

sure but then you may as well have your attribs just be strings :slight_smile:

/bikeshed supreme

On Tue, Oct 16, 2012 at 1:28 PM, John Dyer johntdyer@gmail.com wrote:

Actually, symbols do work w/ -'s, you just have to wrap them in quotes:

1.9.3-p194 :002 > :"a-b"
=> :"a-b"
1.9.3-p194 :003 >

-John

On Tue, Oct 16, 2012 at 4:23 PM, Jesse Nelson spheromak@gmail.com wrote:

symbols will break in ruby when using -'s

[1] pry(main)> :a-b
NameError: undefined local variable or method b' for main:Object from (pry):1:in pry'
[2] pry(main)> :a_b
=> :a_b

On Tue, Oct 16, 2012 at 1:16 PM, Paul Graydon paul@paulgraydon.co.uk
wrote:

Why add unnecessary constraints?
What do we gain by stopping people from using -'s and other marks in
attributes?

It doesn't particularly affect me either way because I don't do it, but
I'm
not sure I see a particular benefit in restricting such practices.

Paul

On 10/16/2012 10:13 AM, Jesse Nelson wrote:

I agree with the too noisy sentiment. I think that being consistent in
a cook is good, but I personally prefer symbols and enforcing a no -'s
in attrib names. Of course there are exceptions that you run into, and
you have to use strings. I find symbols easier on the eyes and
fingers.

Jesse Nelson

On Tue, Oct 16, 2012 at 12:21 PM, Jeremy Voorhis jvoorhis@gmail.com
wrote:

As a maintainer of in-house and 3rd party cookbooks for my
organization,
I
find FC001 too noisy to be useful. We haven't yet modernized our repo
to
include every single cookbook as a self-contained repo, and in some
cases
find little benefit in doing so. New cookbooks follow FC001 and other
best
practices that didn't yet exist or weren't widely known at the time,
so
this
rule is mostly ignored for now and we test for the desired outcome
instead.

Jeremy

On Tue, Oct 16, 2012 at 11:28 AM, Joshua Timberman
joshua@opscode.com
wrote:

Ohai, Chefs!

We want to hear from you: which way of using node attributes do you
prefer? Please take this single question survey:

FC001 - Use strings in preference to symbols to access node attributes

This is in response to a longer twitter discussion today on the
subject.
The survey will be left open for awhile, letting as many people as
possible
answer. We really value this feedback.

If you want an explanation of why this rule came about the way it
did,
and
our rationale for preferring strings to symbols, see this issue in
the
Foodcritic project:

Rule FC001 contrary to Opscode recommendation · Issue #1 · Foodcritic/foodcritic · GitHub

If you're going to be at the Chef summit next week, I'm happy to
discuss
this in greater detail, too :-).

On Wed, Oct 17, 2012 at 7:16 AM, Paul Graydon paul@paulgraydon.co.uk wrote:

Why add unnecessary constraints?
What do we gain by stopping people from using -'s and other marks in
attributes?

To my mind using strings facilitates, if not encourages, a bad
practice in naming: using minus, dash, etc. in attribute names.
It seems that if we go down the path of endorsing strings then we
should give up accessing attr data via methods and maybe even symbol
keys.

If not then there will be a growing population of names with minus,dash,etc..
Eventually, and I really do mean taking a long term view, this means
your cookbook/shop cannot adopt a practice/convention of accessing by
method name. or you have to sanitize strings before intern-ing them.

IMO, this benefit to discouraging use of strings a key names is large
enough to make the short term pain worthwhile.

Hopefully I have not misunderstood something.
Best wishes
Hedge

It doesn't particularly affect me either way because I don't do it, but I'm
not sure I see a particular benefit in restricting such practices.

Paul

On 10/16/2012 10:13 AM, Jesse Nelson wrote:

I agree with the too noisy sentiment. I think that being consistent in
a cook is good, but I personally prefer symbols and enforcing a no -'s
in attrib names. Of course there are exceptions that you run into, and
you have to use strings. I find symbols easier on the eyes and
fingers.

Jesse Nelson

On Tue, Oct 16, 2012 at 12:21 PM, Jeremy Voorhis jvoorhis@gmail.com
wrote:

As a maintainer of in-house and 3rd party cookbooks for my organization,
I
find FC001 too noisy to be useful. We haven't yet modernized our repo to
include every single cookbook as a self-contained repo, and in some cases
find little benefit in doing so. New cookbooks follow FC001 and other
best
practices that didn't yet exist or weren't widely known at the time, so
this
rule is mostly ignored for now and we test for the desired outcome
instead.

Jeremy

On Tue, Oct 16, 2012 at 11:28 AM, Joshua Timberman joshua@opscode.com
wrote:

Ohai, Chefs!

We want to hear from you: which way of using node attributes do you
prefer? Please take this single question survey:

FC001 - Use strings in preference to symbols to access node attributes

This is in response to a longer twitter discussion today on the subject.
The survey will be left open for awhile, letting as many people as
possible
answer. We really value this feedback.

If you want an explanation of why this rule came about the way it did,
and
our rationale for preferring strings to symbols, see this issue in the
Foodcritic project:

Rule FC001 contrary to Opscode recommendation · Issue #1 · Foodcritic/foodcritic · GitHub

If you're going to be at the Chef summit next week, I'm happy to discuss
this in greater detail, too :-).

--
πόλλ' οἶδ ἀλώπηξ, ἀλλ' ἐχῖνος ἓν μέγα
[The fox knows many things, but the hedgehog knows one big thing.]
Archilochus, Greek poet (c. 680 BC – c. 645 BC)
http://hedgehogshiatus.com

On Tue, Oct 16, 2012 at 2:28 PM, Joshua Timberman joshua@opscode.com wrote:

Ohai, Chefs!

We want to hear from you: which way of using node attributes do you prefer? Please take this single question survey:

FC001 - Use strings in preference to symbols to access node attributes

This is in response to a longer twitter discussion today on the subject. The survey will be left open for awhile, letting as many people as possible answer. We really value this feedback.

If you want an explanation of why this rule came about the way it did, and our rationale for preferring strings to symbols, see this issue in the Foodcritic project:

Rule FC001 contrary to Opscode recommendation · Issue #1 · Foodcritic/foodcritic · GitHub

If you're going to be at the Chef summit next week, I'm happy to discuss this in greater detail, too :-).

FWIW, since I was involved with this, I'll restate here:

I only prefer symbols from an aesthetic perspective. string keys just
don't stand out in most syntax highlighting regardless of the color
scheme in use (http://s3itch.s3.amazonaws.com/Screen_Shot_2012-10-16_at_4.28.14_PM-20121016-162843.jpg)

There are both downsides and upsides to using symbols -

(downside) symbols aren't GCd
(upside) only one copy of a given symbol exists in memory
(downside) symbols can't contain dashes without "effort"
(upside) everybody I know uses symbols :wink:

Any arguments over symbol vs. string r.e. memory are largely silly
imho. It's like trying to optimize by only using double quotes when
doing interpolation and single quotes the rest of the time.

When I learned Ruby, the general rule of thumb I was given was to use
symbols for identifiers essentially. Countless articles try and go
over the differences between strings and symbols and in the end they
all just basically say "a symbol is an immutable string" (which
glosses over a lot but is fairly pragmatic in implementation).

I favor visual consistency and cringe when I see MIXED usage.
Interestingly enough I've been working with a lot of chef AND ruby
newbies and for the most part they all seem to prefer symbols over
strings. And of course they've been tripped up on the dash issue.

In the end I'd say while I prefer symbols, strings are probably the
best bet long term AND it would need to be enforced on the chef side
(not just some FC rule). That would raise holy hell though with older
cookbooks. Maybe in Chef 12 :wink:

The hyphen is commonly used in naming, and is as good a practice as any.
For example, it is used in:

  • names in LISP
  • certain element and attribute names in XML and various XML languages such
    as HTML
  • CSS property names and values
  • various filesystem path conventions
  • various URL conventions

So hyphens are fine by me. Indeed they seem to me to be, in some way, nicer
than the alternatives; but that's just taste.

Data is data. When dealing with data, it should be obvious that it's data.
Node attributes are data, so when dealing with node attributes, it should
be obvious that what you're dealing with is data. In Ruby, symbols are
typically reserved for denoting named parts of your program - e.g.
metaprogramming, reflection, and named arguments to methods -, while
methods are typically reserved for behavior rather than data, even if the
behavior is simply to fetch data. But strings are the universal language of
data, in Ruby as well as in other languages, and in Chef as well as in
other Ruby systems.

Simply put, using strings for node attributes makes it dead obvious to all
concerned that what you're dealing with is normal, run-of-the-mill,
non-fancy, unadulterated, pure data.

From a memory perspective, using symbols in your code is not problematic.
The problem is symbolizing strings willy-nilly that come from input or
other external sources. E.g., in a web apps, symbolizing strings that come
from the browser is an invitation to be DoS'd, since anybody can just
iterate the same request but substituting all possible strings into the
request until your app runs out of memory and crashes. (It also opens up
the thread-safety-vs-slow-lock problem.) But most people using Chef won't
run into that problem.

Cheers,
Jay

On Tue, Oct 16, 2012 at 4:41 PM, Hedge Hog hedgehogshiatus@gmail.comwrote:

On Wed, Oct 17, 2012 at 7:16 AM, Paul Graydon paul@paulgraydon.co.uk
wrote:

Why add unnecessary constraints?
What do we gain by stopping people from using -'s and other marks in
attributes?

To my mind using strings facilitates, if not encourages, a bad
practice in naming: using minus, dash, etc. in attribute names.
It seems that if we go down the path of endorsing strings then we
should give up accessing attr data via methods and maybe even symbol
keys.

If not then there will be a growing population of names with
minus,dash,etc..
Eventually, and I really do mean taking a long term view, this means
your cookbook/shop cannot adopt a practice/convention of accessing by
method name. or you have to sanitize strings before intern-ing them.

IMO, this benefit to discouraging use of strings a key names is large
enough to make the short term pain worthwhile.

Hopefully I have not misunderstood something.
Best wishes
Hedge

It doesn't particularly affect me either way because I don't do it, but
I'm
not sure I see a particular benefit in restricting such practices.

Paul

On 10/16/2012 10:13 AM, Jesse Nelson wrote:

I agree with the too noisy sentiment. I think that being consistent in
a cook is good, but I personally prefer symbols and enforcing a no -'s
in attrib names. Of course there are exceptions that you run into, and
you have to use strings. I find symbols easier on the eyes and
fingers.

Jesse Nelson

On Tue, Oct 16, 2012 at 12:21 PM, Jeremy Voorhis jvoorhis@gmail.com
wrote:

As a maintainer of in-house and 3rd party cookbooks for my
organization,
I
find FC001 too noisy to be useful. We haven't yet modernized our repo
to
include every single cookbook as a self-contained repo, and in some
cases
find little benefit in doing so. New cookbooks follow FC001 and other
best
practices that didn't yet exist or weren't widely known at the time, so
this
rule is mostly ignored for now and we test for the desired outcome
instead.

Jeremy

On Tue, Oct 16, 2012 at 11:28 AM, Joshua Timberman <joshua@opscode.com

wrote:

Ohai, Chefs!

We want to hear from you: which way of using node attributes do you
prefer? Please take this single question survey:

FC001 - Use strings in preference to symbols to access node attributes

This is in response to a longer twitter discussion today on the
subject.
The survey will be left open for awhile, letting as many people as
possible
answer. We really value this feedback.

If you want an explanation of why this rule came about the way it did,
and
our rationale for preferring strings to symbols, see this issue in the
Foodcritic project:

Rule FC001 contrary to Opscode recommendation · Issue #1 · Foodcritic/foodcritic · GitHub

If you're going to be at the Chef summit next week, I'm happy to
discuss
this in greater detail, too :-).

--
πόλλ' οἶδ ἀλώπηξ, ἀλλ' ἐχῖνος ἓν μέγα
[The fox knows many things, but the hedgehog knows one big thing.]
Archilochus, Greek poet (c. 680 BC – c. 645 BC)
http://hedgehogshiatus.com

I'd like to clarify the main intention:

I am gathering data.

We don't currently have any plans to change the various ways of accessing node attributes. The FC001 rule clearly annoys a lot of people. Based on the data from the survey, I'll bring it up with the foodcritic project in the form of an issue.

Once the survey is closed, I'll share the results. Right now, its approximately 50% symbols, 35% strings and 15% methods out of 120 responses. The more data the better, so if you have coworkers who haven't responded, please send them the link. If you haven't responded, please do so :-). It only takes a moment, just one question.

Thank you

On Oct 16, 2012, at 12:28 PM, Joshua Timberman joshua@opscode.com wrote:

Ohai, Chefs!

We want to hear from you: which way of using node attributes do you prefer? Please take this single question survey:

FC001 - Use strings in preference to symbols to access node attributes

This is in response to a longer twitter discussion today on the subject. The survey will be left open for awhile, letting as many people as possible answer. We really value this feedback.

If you want an explanation of why this rule came about the way it did, and our rationale for preferring strings to symbols, see this issue in the Foodcritic project:

Rule FC001 contrary to Opscode recommendation · Issue #1 · Foodcritic/foodcritic · GitHub

If you're going to be at the Chef summit next week, I'm happy to discuss this in greater detail, too :-).

--
Opscode, Inc
Joshua Timberman, Technical Community Manager
IRC, Skype, Twitter, Github: jtimberman

I don't have any strong opinions on this matter, but I did start
writing recipes using symbols. Then I heard I should be using
strings. "Cripes," I said, "okay, I'll migrate to strings with a
great big ol' indiscriminately-fashioned regular expression."

Needless to say, this broke a number of things I'd written in cookbook
libraries and templates. I reverted those changes.

So I'll probably just use symbols, but I promise not to look askance
at anyone who uses methods or strings.

On Tue, Oct 16, 2012 at 3:49 PM, Joshua Timberman joshua@opscode.com wrote:

I'd like to clarify the main intention:

I am gathering data.

We don't currently have any plans to change the various ways of accessing node attributes. The FC001 rule clearly annoys a lot of people. Based on the data from the survey, I'll bring it up with the foodcritic project in the form of an issue.

Once the survey is closed, I'll share the results. Right now, its approximately 50% symbols, 35% strings and 15% methods out of 120 responses. The more data the better, so if you have coworkers who haven't responded, please send them the link. If you haven't responded, please do so :-). It only takes a moment, just one question.

Thank you

On Oct 16, 2012, at 12:28 PM, Joshua Timberman joshua@opscode.com wrote:

Ohai, Chefs!

We want to hear from you: which way of using node attributes do you prefer? Please take this single question survey:

FC001 - Use strings in preference to symbols to access node attributes

This is in response to a longer twitter discussion today on the subject. The survey will be left open for awhile, letting as many people as possible answer. We really value this feedback.

If you want an explanation of why this rule came about the way it did, and our rationale for preferring strings to symbols, see this issue in the Foodcritic project:

Rule FC001 contrary to Opscode recommendation · Issue #1 · Foodcritic/foodcritic · GitHub

If you're going to be at the Chef summit next week, I'm happy to discuss this in greater detail, too :-).

--
Opscode, Inc
Joshua Timberman, Technical Community Manager
IRC, Skype, Twitter, Github: jtimberman

My understanding is that because of the way that attribute code works, if you
use symbols to access attributes, it actually converts them to a string before
doing a symbol look-up on them.

Which… ya know… works and all, but probably isn’t what you intended.


Phil Dibowitz phil@ipom.com
Open Source software and tech docs Insanity Palace of Metallica
http://www.phildev.net/ http://www.ipom.com/

“Be who you are and say what you feel, because those who mind don’t matter
and those who matter don’t mind.”

  • Dr. Seuss

Phil,

That's correct. Under the hood, it's all strings.

The symbol and method syntaxes are just a small bit of sugar over the
underlying string syntax. But all of the node attribute keys are kept as
strings internally. And all of the methods that fetch keys or iterate over
the elements give the keys as strings, not as symbols (and certainly not as
methods).

Cheers,
Jay

On Wed, Oct 17, 2012 at 12:40 PM, Phil Dibowitz phil@ipom.com wrote:

My understanding is that because of the way that attribute code works, if
you
use symbols to access attributes, it actually converts them to a string
before
doing a symbol look-up on them.

Which... ya know... works and all, but probably isn't what you intended.

--
Phil Dibowitz phil@ipom.com
Open Source software and tech docs Insanity Palace of Metallica
http://www.phildev.net/ http://www.ipom.com/

"Be who you are and say what you feel, because those who mind don't matter
and those who matter don't mind."

  • Dr. Seuss

On Wed, Oct 17, 2012 at 01:01:17PM -0400, Jay Feldblum wrote:

Phil,

That's correct. Under the hood, it's all strings.

The symbol and method syntaxes are just a small bit of sugar over the
underlying string syntax. But all of the node attribute keys are kept as
strings internally. And all of the methods that fetch keys or iterate over
the elements give the keys as strings, not as symbols (and certainly not as
methods).

Right. And I think that's a pretty good reason for the best practice to be
"always use strings unless you have a reason to do otherwise."

--
Phil Dibowitz phil@ipom.com
Open Source software and tech docs Insanity Palace of Metallica
http://www.phildev.net/ http://www.ipom.com/

"Be who you are and say what you feel, because those who mind don't matter
and those who matter don't mind."

  • Dr. Seuss

I'm not sure this decision is important enough to warrant calling it a best
practice. Is there really harm in having one cookbook use symbols and
another use strings? I've never encountered a gotcha that is caused by
mixed accessing.

I can see why you'd want to be consistent within a cookbook, but ultimately
it's not going to make a difference.

I just turn off this check and let people do what they will. I personally
use symbols as it's more comfortable given I was a ruby developer before I
learned Chef.

Josiah

On Wed, Oct 17, 2012 at 10:50 AM, Phil Dibowitz phil@ipom.com wrote:

On Wed, Oct 17, 2012 at 01:01:17PM -0400, Jay Feldblum wrote:

Phil,

That's correct. Under the hood, it's all strings.

The symbol and method syntaxes are just a small bit of sugar over the
underlying string syntax. But all of the node attribute keys are kept as
strings internally. And all of the methods that fetch keys or iterate
over
the elements give the keys as strings, not as symbols (and certainly not
as
methods).

Right. And I think that's a pretty good reason for the best practice to be
"always use strings unless you have a reason to do otherwise."

--
Phil Dibowitz phil@ipom.com
Open Source software and tech docs Insanity Palace of Metallica
http://www.phildev.net/ http://www.ipom.com/

"Be who you are and say what you feel, because those who mind don't matter
and those who matter don't mind."

  • Dr. Seuss

On Thu, Oct 18, 2012 at 5:00 AM, Josiah Kiehl bluepojo@gmail.com wrote:

I just turn off this check and let people do what they will. I personally
use symbols as it's more comfortable given I was a ruby developer before I
learned Chef.

I used to use symbols but then changed to strings due to FC001 and hated it
at first as I used to write a lot of rails code and it seemed a foreign
code style. However overtime I got used to it and have found it is easier
to teach people about chef with it. It is also much easier when you start
mixing content into node attributes (i.e. we deep merge data bag data into
node attributes or extract json config from other services) as you don't
have to think about whether you can use symbols or strings in a particular
case - you always use strings.

I think Chef would be much easier to teach and learn if there was a single
way of doing things. Cookbooks would be consistent and easier to read.
The other techniques could be removed form the core but if people wanted to
use them they could always readd them through a support cookbook that
monkey patched the right classes.

--
Cheers,

Peter Donald