UseBB Community

The official board for UseBB help and discussion

UseBB Community » 1.0 Discussion » Coding guidelines

Coding guidelines

Page: 1

Author Post
Member
Registered: May 2004
Posts: 99
Location: Australia
I've got a couple of thoughts/questions about the guidelines.

First off, I see it done everywhere, using if statements without the block:

if ( $cond == true )
exit();

This code might appear innocent, but if someone who hasn't had much experience coding in PHP decides to add something before the exit call:

if ( $cond == true )
log_exit();
exit();

Well, you're in big trouble. So I'd like to suggest that curley brackets are always used, even for simple one liners.

The other thing: Is it ok to use the 'null' instead of an empty string ? I find null to be better because when working with a lot of joined strings its always easy to see.
Member
Registered: Apr 2004
Posts: 39
Location: Rainy Belgium
A little bit offtopic:

why use

if ( $cond == true )


instead of

if ( $cond )


For the null question: null means no string while "" means an empty string so they actualy mean different things.
Member
Registered: May 2004
Posts: 99
Location: Australia
It was an example.

Null isn't a string sure, but its not like that matters.
Developer
Registered: Apr 2004
Posts: 2218
Location: Belgium
Well I'm used to always not use brackets when there's only one statement inside. It'll probably stay like this in 1.0, but for 2.0 this is worth considering.
_______________
--Dietrich (developer)
UseBB roadmap, dev mailing list & weblog
Member
Registered: May 2004
Posts: 99
Location: Australia
Cool, ok.
Member
Registered: Jul 2005
Posts: 10
Location: The Netherlands
I agree with The Wolf. Not using brackets can cause many problems and besides, the code is easier to read when brackets are used (at least IMO).

Page: 1

UseBB Community » 1.0 Discussion » Coding guidelines

UseBB Community is powered by UseBB 1 Forum Software