Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Talk:Coding: Difference between revisions

From MoodleDocs
(Classes and their methods)
(→‎Classes and their methods: naming classes and their methods)
Line 22: Line 22:


There is nothing regarding classes and methods naming style. Is there an agreement on how to name classes and methods? I mean should I use "class lower_case_name" or "class CamelCaseName". And similar to methods - shall I type "function say_hello()" or "function sayHello()" if the function is a method of a class? --[[User:David Mudrak|David Mudrak]] 17:30, 10 May 2008 (CDT)
There is nothing regarding classes and methods naming style. Is there an agreement on how to name classes and methods? I mean should I use "class lower_case_name" or "class CamelCaseName". And similar to methods - shall I type "function say_hello()" or "function sayHello()" if the function is a method of a class? --[[User:David Mudrak|David Mudrak]] 17:30, 10 May 2008 (CDT)
: After a skype chat with Eloy and Petr, I added info about using lowercase in this case. --[[User:David Mudrak|David Mudrak]] 14:30, 11 May 2008 (CDT)

Revision as of 19:30, 11 May 2008

Single quotes vs. double quotes: no noticable speed differences...

As PHP 4.3.0 is now the minimum version, the speed issue of single quotes vs. double quotes is negligible. See http://phplens.com/lens/php-book/optimizing-debugging-php.php, under "Useless Optimizations". There might be other reasons, however. I like to use "". ' is more convinient if a string has a lot of "s it it, like 'I have no "issues" with the "quotations"'. --Samuli Karevaara 04:26, 10 October 2006 (CDT)

I see that Martin changed the rationale, so single quotes should be used with strings that have parsed variables in them. However, Tim changed the example back to use double quotes :-) --Samuli Karevaara 00:13, 17 March 2008 (CDT)

Using clone()

Unless I'm mistaken, there are some cases where we should use Moodle's full_clone() method. Maybe someone could clarify this...

Probably this bit under the item 9: "If the thing you want to copy is not an object, but may contain objects (eg an array of objects) then use fullclone() instead." --Samuli Karevaara 00:18, 17 March 2008 (CDT)

Single vs Double quotes

According to the PHP.net manual page referenced, the memory usage issue for strings is not with single v double quotes, but with parsed variables in strings vs concatenated variables in strings.

As a PHP developer, I find it is overall much better to use double quotes for strings if for no other reason than that you can stick newlines (\n) in. Putting newlines in makes HTML debugging MUCH easier.

Just my $0.02.

Thanks!

Classes and their methods

There is nothing regarding classes and methods naming style. Is there an agreement on how to name classes and methods? I mean should I use "class lower_case_name" or "class CamelCaseName". And similar to methods - shall I type "function say_hello()" or "function sayHello()" if the function is a method of a class? --David Mudrak 17:30, 10 May 2008 (CDT)

After a skype chat with Eloy and Petr, I added info about using lowercase in this case. --David Mudrak 14:30, 11 May 2008 (CDT)