[TYPO3-core] New TYPO3 Coding Guidelines

View: New views
20 Messages — Rating Filter:   Alert me  
< Prev | 1 - 2 - 3 | Next >

Parent Message unknown Re: [TYPO3-core] New TYPO3 Coding Guidelines

by Vladimir Podkovanov-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Francois Suter wrote:

> Hi all,
>
> After a long wait the new TYPO3 Coding Guidelines have been released
> last Friday. So head over to typo3.org and get your copy [1]! These new
> rules apply to all pending or future patches with immediate effect.
>
> You can read a longer announcement in the Core Blog [2].
>
> Happy coding to all!
>
>
> Francois Suter & Michael Stucki
>
>
> [1]
> http://typo3.org/documentation/document-library/core-documentation/doc_core_cgl/current/ 
>
>
> [2] http://buzz.typo3.org/teams/core/article/new-typo3-coding-guidelines/

Hi!
since single quotes vs double quotes are now working eighter fast (see
http://www.phpbench.com/) would not be better to use

"Hello $userName"
rather than
'Hello ' . $userName ?

In such way it saves time on concatenations.

--
-rgds-
Vladimir
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: [TYPO3-core] New TYPO3 Coding Guidelines

by David Bruchmann-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

----- Ursprüngliche Nachricht -----
Von:        Vladimir Podkovanov <admin@...>
Gesendet:   Donnerstag, 9. Juli 2009 19:06:13
An:         typo3-dev@...
CC:
Betreff:    Re: [TYPO3-dev] [TYPO3-core] New TYPO3 Coding Guidelines

> Francois Suter wrote:
>> Hi all,
>>
>> After a long wait the new TYPO3 Coding Guidelines have been released
>> last Friday. So head over to typo3.org and get your copy [1]! These new
>> rules apply to all pending or future patches with immediate effect.
>>
>> You can read a longer announcement in the Core Blog [2].
>>
>> Happy coding to all!
>>
>>
>> Francois Suter & Michael Stucki
>>
>>
>> [1]
>> http://typo3.org/documentation/document-library/core-documentation/doc_core_cgl/current/ 
>>
>>
>> [2] http://buzz.typo3.org/teams/core/article/new-typo3-coding-guidelines/
>
> Hi!
> since single quotes vs double quotes are now working eighter fast (see
> http://www.phpbench.com/) would not be better to use
>
> "Hello $userName"
> rather than
> 'Hello ' . $userName ?
>
> In such way it saves time on concatenations.
>

In general it's possible but noting variables like this:
'Hello ' . $userName ?
... makes the text in most editors much more readable because variables
arent marked as string. Readiblity is an important point for the source.

Best Regards
David
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Parent Message unknown Re: [TYPO3-core] New TYPO3 Coding Guidelines

by Dmitry Dulepov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!

Vladimir Podkovanov wrote:
> since single quotes vs double quotes are now working eighter fast (see
> http://www.phpbench.com/) would not be better to use
>
> "Hello $userName"
> rather than
> 'Hello ' . $userName ?
>
> In such way it saves time on concatenations.

It wouldn't. We already have a certain style in the core and we will follow that. We changed it once and changing it again is useless loss of time.

--
Dmitry Dulepov
LinkedIn: http://www.linkedin.com/in/dmitrydulepov
Twitter: http://twitter.com/dmitryd
Skype: liels_bugs
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: [TYPO3-core] New TYPO3 Coding Guidelines

by Vladimir Podkovanov-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

David Bruchmann wrote:

>
> In general it's possible but noting variables like this:
> 'Hello ' . $userName ?
> ... makes the text in most editors much more readable because variables
> arent marked as string. Readiblity is an important point for the source.
>
> Best Regards
> David

Oh, I see, I'm using Zend Studio and did not know that others IDEs don't
highlight var inside string.

--
-rgds-
Vladimir
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Parent Message unknown Re: [TYPO3-core] New TYPO3 Coding Guidelines

by Marc Wöhlken :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!
Vladimir Podkovanov schrieb:

> since single quotes vs double quotes are now working eighter fast (see
> http://www.phpbench.com/) would not be better to use
>
> "Hello $userName"
> rather than
> 'Hello ' . $userName ?
>
> In such way it saves time on concatenations.
>
The difference in performance seems to be below 10% (at least on
www.phpbench.com)and nobody can guarantee that this will be the same
with future php releases. There may be optimizations rendering current
results completely useless.

Adittinonally using different php caches may result in very different
benchmark results.

Readability is also an issue as David already pointed out.

Regards
 Marc

--
...........................................................
Marc Wöhlken                     TYPO3 certified intregator

Quadracom - Proffe & Wöhlken

Rembertistraße 32              WWW: http://www.quadracom.de
D-28203 Bremen                E-Mail: woehlken@...
______________             PGP-Key: http://pgp.quadracom.de
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Parent Message unknown Re: [TYPO3-core] New TYPO3 Coding Guidelines

by Vladimir Podkovanov-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Marc Wöhlken wrote:
> The difference in performance seems to be below 10% (at least on
> www.phpbench.com)and nobody can guarantee that this will be the same
> with future php releases. There may be optimizations rendering current
> results completely useless.

Yes, but that difference there without mentioned concats! So concat
operator (.) will more slow down overall time for 'string' . $var

>
> Adittinonally using different php caches may result in very different
> benchmark results.
>
> Readability is also an issue as David already pointed out.
>
> Regards
>  Marc
>

Sure, it is right if many editors does not hightlight vars in string.
However in Zend Studio IMHO more readable when var inside string as I
can see all SQL request and don't try to concat parts in my mind in
order to see whole request ;)

--
-rgds-
Vladimir
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Parent Message unknown Re: [TYPO3-core] New TYPO3 Coding Guidelines

by Vladimir Podkovanov-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Sure, it is right if many editors does not hightlight vars in string.
> However in Zend Studio IMHO more readable when var inside string as I
> can see all SQL request and don't try to concat parts in my mind in
> order to see whole request ;)
>

Example:

"where login = '$login'"
vs
'where login = \'' . $login . '\''

--
-rgds-
Vladimir
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: [TYPO3-core] New TYPO3 Coding Guidelines

by Peter Russ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

--- Original Nachricht ---
Absender:   Vladimir Podkovanov
Datum:       09.07.2009 22:29:

>> Sure, it is right if many editors does not hightlight vars in string.
>> However in Zend Studio IMHO more readable when var inside string as I
>> can see all SQL request and don't try to concat parts in my mind in
>> order to see whole request ;)
>>
>
> Example:
>
> "where login = '$login'"
> vs
> 'where login = \'' . $login . '\''
>
vs
'where login = "'.$login.'"'

Vladimir: it's decided. See next release of CGL ;-)

Regs. Peter-

--
Fiat lux! Docendo discimus.
_____________________________
uon GbR

http://www.uon.li
http://www.xing.com/profile/Peter_Russ
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: [TYPO3-core] New TYPO3 Coding Guidelines

by Christopher Torgalson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

On Thu, Jul 9, 2009 at 1:29 PM, Vladimir
Podkovanov<admin@...> wrote:

>> Sure, it is right if many editors does not hightlight vars in string.
>> However in Zend Studio IMHO more readable when var inside string as I
>> can see all SQL request and don't try to concat parts in my mind in
>> order to see whole request ;)
>>
>
> Example:
>
> "where login = '$login'"
> vs
> 'where login = \'' . $login . '\''


If you want to do that, you could also use sprintf--it makes for nice
and readable code up to a point (after 7 or 8 replacements, it's can
be pretty hard to read...):

$format = 'SELECT %s FROM %s WHERE %s LIMIT %d';
$query = sprintf($format, $tables, $from, $where, $limit);

--
Christopher Torgalson
http://www.typo3apprentice.com/
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: [TYPO3-core] New TYPO3 Coding Guidelines

by Ernesto Baschny [cron IT] :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Christopher Torgalson schrieb:

> On Thu, Jul 9, 2009 at 1:29 PM, Vladimir
> Podkovanov<admin@...> wrote:
>>> Sure, it is right if many editors does not hightlight vars in string.
>>> However in Zend Studio IMHO more readable when var inside string as I
>>> can see all SQL request and don't try to concat parts in my mind in
>>> order to see whole request ;)
>>>
>> Example:
>>
>> "where login = '$login'"
>> vs
>> 'where login = \'' . $login . '\''
>
>
> If you want to do that, you could also use sprintf--it makes for nice
> and readable code up to a point (after 7 or 8 replacements, it's can
> be pretty hard to read...):
>
> $format = 'SELECT %s FROM %s WHERE %s LIMIT %d';
> $query = sprintf($format, $tables, $from, $where, $limit);

My tests show this on my environment (PHP 5.2.0 with eaccelerator):

$a = 'test2';

100.00%  $tmp = 'test ' . $a;
105.64%  $tmp = "test $a";
174.98%  $tmp = sprintf('test %s', $a);
180.87%  $tmp = str_replace('#a#', $a, 'test #a#');

Slight difference. Isn't worth a change, as the first one is the most
"readable" one. I also like the "template-based" sprintf, but it
shouldn't be used if you are going to loop through it 50.000 times. :)

Cheers,
Ernesto
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: [TYPO3-core] New TYPO3 Coding Guidelines

by Marc Wöhlken :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Peter Russ schrieb:

> Vladimir: it's decided. See next release of CGL ;-)
Does this argument hold for all comments regarding the CGL? In other
words are comments welcome or just a useless waste of time?

Regards
  Marc
--
...........................................................
Marc Wöhlken                     TYPO3 certified intregator

Quadracom - Proffe & Wöhlken

Rembertistraße 32              WWW: http://www.quadracom.de
D-28203 Bremen                E-Mail: woehlken@...
______________             PGP-Key: http://pgp.quadracom.de
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: [TYPO3-core] New TYPO3 Coding Guidelines

by Christopher Torgalson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Jul 9, 2009 at 2:42 PM, Ernesto Baschny [cron
IT]<ernst@...> wrote:
> Christopher Torgalson schrieb:

<snip>

>> If you want to do that, you could also use sprintf--it makes for nice
>> and readable code up to a point (after 7 or 8 replacements, it's can
>> be pretty hard to read...):
>>
>> $format = 'SELECT %s FROM %s WHERE %s LIMIT %d';
>> $query = sprintf($format, $tables, $from, $where, $limit);
>
> My tests show this on my environment (PHP 5.2.0 with eaccelerator):
>
> $a = 'test2';
>
> 100.00%  $tmp = 'test ' . $a;
> 105.64%  $tmp = "test $a";
> 174.98%  $tmp = sprintf('test %s', $a);
> 180.87%  $tmp = str_replace('#a#', $a, 'test #a#');
>
> Slight difference. Isn't worth a change, as the first one is the most
> "readable" one. I also like the "template-based" sprintf, but it
> shouldn't be used if you are going to loop through it 50.000 times. :)


Thanks Ernesto, that's a useful tid-bit...

--
Christopher Torgalson
http://www.typo3apprentice.com/
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: [TYPO3-core] New TYPO3 Coding Guidelines

by Vladimir Podkovanov-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ernesto Baschny [cron IT] wrote:

>
> My tests show this on my environment (PHP 5.2.0 with eaccelerator):
>
> $a = 'test2';
>
> 100.00%  $tmp = 'test ' . $a;
> 105.64%  $tmp = "test $a";
> 174.98%  $tmp = sprintf('test %s', $a);
> 180.87%  $tmp = str_replace('#a#', $a, 'test #a#');
>
> Slight difference. Isn't worth a change, as the first one is the most
> "readable" one. I also like the "template-based" sprintf, but it
> shouldn't be used if you are going to loop through it 50.000 times. :)
>
> Cheers,
> Ernesto

Thanks :)

--
-rgds-
Vladimir
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: [TYPO3-core] New TYPO3 Coding Guidelines

by Peter Russ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

--- Original Nachricht ---
Absender:   Marc Wöhlken
Datum:       10.07.2009 01:03:
> Peter Russ schrieb:
>
>> Vladimir: it's decided. See next release of CGL ;-)
> Does this argument hold for all comments regarding the CGL? In other
> words are comments welcome or just a useless waste of time?
>
> Regards
>  Marc

As far as I can see from earlier discussions: it's waste of time and
energy as core developers are already following this guide for month and
will not change.

Peter.

--
Fiat lux! Docendo discimus.
_____________________________
uon GbR

http://www.uon.li
http://www.xing.com/profile/Peter_Russ
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: [TYPO3-core] New TYPO3 Coding Guidelines

by Francois Suter-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Peter,

> As far as I can see from earlier discussions: it's waste of time and
> energy as core developers are already following this guide for month and
> will not change.

I would to stress that writing CGLs is not an easy thing *at all*. In
some cases it is possible rely on benchmarks because some syntax are
more efficient than others, and even then we have to be sure that such
benchmarks are reliable and reproducible.

Besides those (rather rare) situations, CGLs are mostly a matter of
taste. The way you decide to use and write curly braces for code blocks
(for example) is entirely subjective.

Maybe your bitter (at least that's how I feel them) remarks are due to
the fact that you were present at the CGL session at T3DD08 and are
wondering why some decisions (taken by public vote) were overruled. The
main problem with that session was that there only rather few core team
members. And we are the ones who need to live with CGLs on a daily basis
(more or less ;-) ). So there was quite some dissent over some points
and they were changed so that all core team members could feel at lease
at ease, if not happy, with this new version of the CGLs.

In retrospect doing a public session about CGLs seems like a very bad
idea. Yes, TYPO3 is an Open Source project and the broader community is
a vital part of it, but trying to discuss subjective matters with 100
people is definitely not a good idea. It's hard enough trying to find a
consensus among a smaller group, like the core team (and please note
that this is not a criticism of my fellow team members, it's just a fact
and probably an unavoidable situation among any group of programmers).

Changing CGLs is not an exercise that should be undertaken lightly not
too frequently. As Dmitry already pointed out, there's lot of legacy
code in TYPO3 which doesn't match even the previous version of the CGLs.
Changing too often will cause code chaos and a terrible overhead.

This doesn't mean that things can't be improved and you are always
welcome to make suggestions. Just don't expect major changes unless
there's a very good reason.

Last but not least, these CGLs are binding only for core patches. For
extension developers they are just recommendations. So you are free to
do what you prefer inside your own extensions if you can't bear our CGLs.

I hope this will clarify the situation and prevent too easy criticisms,
although I'm no fool and have no hope of making everybody happy ;-)

Cheers

--

Francois Suter
Cobweb Development Sarl - http://www.cobweb.ch
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: [TYPO3-core] New TYPO3 Coding Guidelines

by Mathias Schreiber [wmdb >] :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Francois Suter schrieb:
> Last but not least, these CGLs are binding only for core patches. For
> extension developers they are just recommendations. So you are free to
> do what you prefer inside your own extensions if you can't bear our CGLs.
>
> I hope this will clarify the situation and prevent too easy criticisms,
> although I'm no fool and have no hope of making everybody happy ;-)

Thanks for those clear words.
I think it's kinda hard for developers who have been writing a certain
style of codefor a frickin long time to adapt to some parts of the new CGL.
A good thing would be if someone could point out *why* certain changes
were applied.
This way other folks could see "ok, this n that changed for these reasons".

The new whitespace-after-everything style makes me wanna throw up, I
still would like to know why this was added.
The only reason I can see so far is that if you use an IDE without
syntax highlighting makes te code... different... not easier to read.

If someone could point me to why this has been changed I could try to
understand what's going on.

I do think that
$content=$bla
if worse than
$content = $bla
but
$hello = 'This is ' . $name . ' Name' sucks to read from my point of view.

Anyways... I just wanted to say that I understand both sides of the
story and think it might help if the reasons for changed were put
together (as soon as those who dislike parts of te CGL ask for it - no
need to comment on everything :))

cheers
Mathias

--
TYPO3 certified interogator
T3DD09 Entertainer
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: [TYPO3-core] New TYPO3 Coding Guidelines

by Stefan Geith-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mathias Schreiber [wmdb >] schrieb:
> ...
>
> I do think that
> $content=$bla
> is worse than
> $content = $bla
> but
> $hello = 'This is ' . $name . ' Name' sucks to read from my point of view.

For me too - but fortunally, this is the only thing in the new CGI
that twists my eyes ;)

/Stefan Geith

_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: [TYPO3-core] New TYPO3 Coding Guidelines

by Francois Suter-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

> Thanks for those clear words.

You're welcome.

> I think it's kinda hard for developers who have been writing a certain
> style of codefor a frickin long time to adapt to some parts of the new CGL.

I fully agree with that, I had the same problem when I started writing
my first core patches. But being able to abide by the rules is also what
makes someone a good team member ;-)

> Anyways... I just wanted to say that I understand both sides of the
> story and think it might help if the reasons for changed were put
> together (as soon as those who dislike parts of te CGL ask for it - no
> need to comment on everything :))

Can't help you there. I wasn't really part of the CGLs makeover, so I
don't know the reasons for the various changes. I mostly took care that
they get published eventually :-)

Cheers

--

Francois Suter
Cobweb Development Sarl - http://www.cobweb.ch
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: [TYPO3-core] New TYPO3 Coding Guidelines

by Dmitry Dulepov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!

Marc Wöhlken wrote:
> Does this argument hold for all comments regarding the CGL? In other
> words are comments welcome or just a useless waste of time?

Comments are welcome but it does not mean they all will be accepted and we will change the core again from ' to " :)

CGL are meant to be stable. They can be improved but base stuff will not be changed.

--
Dmitry Dulepov
LinkedIn: http://www.linkedin.com/in/dmitrydulepov
Twitter: http://twitter.com/dmitryd
Skype: liels_bugs
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: [TYPO3-core] New TYPO3 Coding Guidelines

by Dmitry Dulepov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Mathias!

Mathias Schreiber [wmdb >] wrote:
> I think it's kinda hard for developers who have been writing a certain
> style of codefor a frickin long time to adapt to some parts of the new CGL.

Let's say 30% of new CGL were not according to my style. But in the end I adopted this new style because  we have to use the same style. We argued quite a lot about it and finally had an agreement. It was not easy at all. But we did it :) We all gave up something in order to have a common base :)

--
Dmitry Dulepov
LinkedIn: http://www.linkedin.com/in/dmitrydulepov
Twitter: http://twitter.com/dmitryd
Skype: liels_bugs
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev
< Prev | 1 - 2 - 3 | Next >