09-28-2009, 12:39 AM
|
#9 (permalink)
|
|
The Contributor
Join Date: Mar 2009
Location: US
Posts: 76
Thanks: 0
|
CamelCasing everything except for array keys there are seperated with a "_"
I also keep a very tidy codestructure ...
I do follow this religiously ... as most experienced programmers do, as far as switching when I am on another project ... I either will integrate my standard in as conventions most I see are extremely sloppy or I lead the project and I set it anyway
Quote:
|
I tend to avoid CamelCase because a lot of times you come across strange looking names like getId(). Then you have to decide between breaking your code convention to make it look right or just leaving it to look odd.
|
I too once followed the same mentality and used just about the same convention using underscores, but once you get used to CamelCasing you come to wonder why you coded that way in the first place, as i find it much much easier to read it CamelCased ... and the look doesnt have to make sense :)
php Code:
/** * Administration Login */ public function login () { $this-> view-> headerTitle(__ ('Login')); if (! $this-> session-> sessionExists('admin_login_lock')) { $this-> session-> startSession('admin_login_lock'); } if ($this-> session-> sessionExists('admin_login_lockout')) { $this-> lock_out = true; $this-> session-> sessionDestroy('admin_login_lock'); echo $this-> view-> getHtml('login'); } if (! $this-> request-> isPost()) { $this-> form = new Unus_Form ('login_form', ''); $username = $this-> form-> addElement('text', 'username'); $username-> setLabel(__ ('Username'))-> setRequire(array( 'msg' => array( 'required' => __ ('Please enter your username'), 'minlength' => __ ('Your username must be at least 4 characters'), 'alpha_num' => __ ('I\m sorry, you are only allowed letters and numbers, please choose another') , ), 'val' => array( 'required' => 'true', 'minlength' => '4', 'alpha_num' => 'true', ) ) ); $password = $this-> form-> addElement('password', 'password')-> setRequire(array( 'msg' => array( 'required' => __ ('Please enter you password'), //'pwd_chk' => __('Your password must must be at least 6 characters in length, contain a number, uppercase and lowercase letter') ), 'val' => array( 'required' => 'true', 'pwd_chk' => 'true' ) ) ); $submit = $this-> form-> addElement('submit', 'submit'); $submit-> setClass('key')-> setValue(__ ('Login'))-> setLabel(false); $button = $this-> form-> addElement('button', 'forgot_password'); $button-> setClass('help')-> setValue(__ ('Lost Password'))-> setLabel(false); $this-> form-> setDecorator(array( 'form_start' => false, 'form_end' => false, 'row_start' => false, 'row_end' => false, 'label_start' => false, 'label_end' => false, 'element_start' => false, 'element_end' => false, 'element_submit_label_start' => false, 'element_submit_label_end' => false, 'element_submit_start' => '<div class="clear"></div>', 'element_submit_end' => ' ', )); echo $this-> view-> getHtml('login'); } else {
|
|
|
|