Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Coding standard in vanilla/garden framework

nepheusnepheus New
edited August 2012 in Vanilla 2.0 - 2.8

I'm not an expert, just more than a novice a little bit. I've checked and tested many sources before, the code standard that makes it so obviously and basically that a verb should be lowercase and following by uppercase noun phrases (used for function name), such as: setValue, setUserEmail, etc.
When I look at the vanilla code, why it would be SetValue or SetSomething for a normal function name? Is it against the standard naming style? My feeling is that "SetValue" - style makes the code looks really heavy after all.
I decided to use vanilla to develop a small community, and It feels like I have to adapt this kind of naming style by the way. Just a little thought about the reason why it would be like that, while the standard is ... standard and it does not hurt your eyes.

And do we have any docs about the coding style and standard coding in garden framework? It really does help improve quality of plugins/addons, too.

Comments

  • Options
    422422 Developer MVP
    edited August 2012

    Are you kidding?

    So SetValue as opposed to setValue HuRtS yOUr EYES

    There was an error rendering this rich post.

  • Options

    the code standard that makes it so obviously and basically that a verb should be lowercase and following

    ???

    Camel case not to do with verbs and nouns, simply words. There are variations on form, this is perfectly acceptable. Typically in English you put the action first. In other languages they do not type Valueset becuase that wouldn't work very well for differentiating the words.

    It is a "convention" rather than a standard. The difference is it is implicit. There is a phase "Convention over configuration" that sums it up well.

    The main thing with convention is to be fairly consistent.

    Regarding natural language syntax, programming languages have been caught up with that before. Although it may make sense initially to base your programming language around natural sentence/phrase structure, it can cause more problems than it solves. It can lead to overly verbose, misleading, and even buggy code.

    Proponents of such system were very idealistic about it through 70s to mid 00s.

    The connection between programming language and natural language remains a superficial one. Of course certain structure remain becuase they have gained meaning that is beyond natural language.

    The obsession with pure OO has started to abait, as more people realise it isn't the be all and end all.

    The reality is the future is in concurrency, rather than sequential programming, and the context couldn't be less like verbal instructions.

    Just like with OO, that isn't the only way of modelling at things (even in real life), you could think of it as the Newtonian mechanics rather than Quantum mechanics programming.

    grep is your friend.

  • Options
    SS ✭✭
    edited August 2012
  • Options

    422 said:
    Are you kidding?

    So SetValue as opposed to setValue HuRtS yOUr EYES

    I guess it supposed to. And while you write code, [shift] has to be your friend at typing a function name, that's much more awkward compared to type a lowercase character then get a list of code suggestion. And I also guess your little finger will be tired for a short while. However, I found it's more natural to write such a function name like that, class names are often Capitalized (camel-case) for better naming convention.

    @x00: it's function name, so it should be setValue, it's more natural while they use english word to write code, no matter what kind of languages they're using. And I'm not talking much about future, I'd like to deal with what is popular and the present.

    I can understand that the language will change, but if you look into popular php framework nowadays, they almost use the camel-case, and there're a list of coding convention that I remember relating to a book I read not long times ago, and it's a good one about these things: "C++ coding standard 101 rules, guidelines, and best practices" - Herb Sutter (it's for C++ but the same for other languages too). Where they're adopted in industries, we shouldn't change it if we don't need to. Maybe I'm too firm about the looking of the code, but behind that is feeling when coding.

  • Options
    x00x00 MVP
    edited August 2012

    SetValue is camel case

    setValue is lower camel case, "camel back" or "mixed case".

    Seriously I think you are teaching grandma to suck eggs, in any event if you think the framework is going to change you are mistaken. Consistency is key.

    I have seen many frameworks that don't use came case at all. In fact many languages don't either it is, quite common to use underscores with lower-case, or mixed case with underscores, or a whole host of another conventions.

    I'm sorry but it it not the same for other languages. try erlang for example.

    grep is your friend.

  • Options

    @x00: I don't think I'm trying to teach anyone to suck eggs here or whatever. And I'm NOT expecting this framework to change, just a couple feelings when get touching code.

    However, camel-case is a format, and has many variants, while in coding we can use those variants to recognize different type of code. If you're not accepting to that, how about naming a class this_is_a_class ; then method: this_is_a_method. You call it this_is_a_class::this_is_a_method? How bad?

    Good framework has code style attached to docs. Hope garden would have it too.

  • Options

    thanks for the link. I'll adapt into that.

  • Options
    LincLinc Detroit Admin

    I long ago learned that "this hurts my eyes" is just another way of saying "this is different than what I'm used to".

    I'm not really sure what use this discussion is. You'd have better luck converting Israel to Hinduism than changing the coding standards of a mature open source project.

  • Options
    ToddTodd Chief Product Officer Vanilla Staff

    @nepheus, focusing on the particulars of a framework's coding practices is a common mistake that novice programmers make. Once you've explored more code you'll see that there isn't one true style. What matters most is the code that's written and that a project is internally consistent.

  • Options
    422422 Developer MVP

    Just noticed z-index of your vanilla logo in text area is greater than the text @todd

    There was an error rendering this rich post.

  • Options
    422422 Developer MVP

    Ooh weird it sorted itself...

    There was an error rendering this rich post.

  • Options
    422422 Developer MVP

    Hmmm so you marked as off topic highlighting an issue that was live and viewable at that exact moment... Okies low blow. I wont bother in future

    There was an error rendering this rich post.

  • Options

    @Todd: Capitalize variable names as part of kinda code style, it's strange and it take time to get used to.
    @422: I don't get what you mean, but the way you reply to the discussion makes me feel uncomfortable, thank you for being so friendly to a new comer.

  • Options
    422422 Developer MVP

    Omg you were offended by , are you kidding? Fgs get a grip

    There was an error rendering this rich post.

  • Options

    Idealism can seriously stall progresses.

    The obsession with XML and XHTML standards is an example, until others took the matter into their own hands worked what became HTML5, 10 years overdue.

    grep is your friend.

  • Options
    ToddTodd Chief Product Officer Vanilla Staff

    All-in-all thanks to the community members for their level headedness in this discussion. I really do appreciate it.

    I think everything that needs to be said on this topic has been said.

This discussion has been closed.