Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99390 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80522 invoked from network); 6 Jun 2017 08:17:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jun 2017 08:17:37 -0000 X-Host-Fingerprint: 62.31.75.76 76.75-31-62.static.virginmediabusiness.co.uk Received: from [62.31.75.76] ([62.31.75.76:17029] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 10/6B-27119-02566395 for ; Tue, 06 Jun 2017 04:17:37 -0400 Message-ID: <10.6B.27119.02566395@pb1.pair.com> To: internals@lists.php.net References: <9dffe898-e550-c6d6-46bd-86dcf74735ea@fleshgrinder.com> <3cfc0130-e530-64ed-36e8-372b044811a8@rhsoft.net> <03.F6.12681.AF215395@pb1.pair.com> <3351770B-C53E-4062-A91A-D3AA7439F02B@gmail.com> In-Reply-To: <3351770B-C53E-4062-A91A-D3AA7439F02B@gmail.com> Date: Tue, 6 Jun 2017 09:17:31 +0100 Lines: 1 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="utf-8"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Newsreader: Microsoft Windows Live Mail 16.4.3564.1216 X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3564.1216 X-Posted-By: 62.31.75.76 Subject: Re: [PHP-DEV] Class Naming in Core From: TonyMarston@hotmail.com ("Tony Marston") "Rowan Collins" wrote in message news:3351770B-C53E-4062-A91A-D3AA7439F02B@gmail.com... > >On 5 June 2017 09:14:47 BST, Tony Marston wrote: >>Seriously, can you explain in words of one syllable the precise >>benefits of >>such a consistency? > >I will try: > >- When we write code, we need to know how to spell the names of things. If >the things all have names that look the same, it is less hard for us to >guess what the name is. This means we take less time to learn the names, >and get less things wrong. Words and abbreviations are spelled the same whether you use snake_case or CamelCase, the only difference is how you show the boundary between one word and the next. Studies have shown that snake_case is more readable than CamelCase. >- Our brains are made to spot when things are the same, and when things are >not the same. When one thing is not like the things near it, we think "why >is that?" This slows us down. Seeing a name written in snake_case does not slow you down. In normal writing there is a space between each word, but as names in software cannot have embedded spaces. This is why underscores are used, and this is infinitely more readable than replacing spaces with a capital letter. >- When we get things wrong, we need to find out what we did wrong. If one >way to write a name is wrong, we can spot when we wrote it that way, and >know that it is wrong. Writing a name wrong has nothing to do with the difference between snake_case and CamelCase. My IDE will show me existing names that match what I am typing as soon as I start typing, so I can easily pick the name that I want. >- If we make two things that mean the same thing, but do not look the same, >we might not spot that we wrote a third thing that does not mean the same >thing. If you try to instantiate a class that does not exist, or call a method/function which does not exist, then you will soon know about it. Using snake_case instead of CamelCase does not invite more errors. >I think there are more things that make it good to have names that look the >same, but I hope this helps for now. The only universally accepted "rule" for names is that they be unique and convey proper meaning. In proper languages all names are case-insensitive as the ability to write the same name with the exact same spelling but different case is simply inviting disaster. -- Tony Marston