Coding Standards
-
Upload
roadhump -
Category
Technology
-
view
926 -
download
3
Transcript of Coding Standards
- 1. Twinslash 2010
2. 3.
4. 5. 6.
- (2 )
7. 80-120 ( ) 8. UTF-8 9. Unix 10. PHP
- :
- PEARhttp://pear.php.net/manual/ru/standards.php
11. symfonyhttp://trac.symfony-project.org/wiki/HowToContributeToSymfony#CodingStandards 12.
- :$myVariable ,class NewReport( )
13. : $my_variable 14. ,
- PHP?>
15. , .class.php 16. ,
- .
if ( $a> 0 ) { $a= 4 ; } class User { public functiongetAge () { } } 17. ,
- , .
if ( $age> 5 &&$rate> 50 ) { $wineStatus= 'good' ; } 18.
- PHPtrue ,falsenull .
19. $isCreated= true ; $count_degrees= 40 ;
- -- .
20. functioncount_events ( $user ) { //... }
- .
21. define ( 'PROJECT_VERSION' , '1.2' ) ; class User { constAGE_MAX= 90 ; }
- :
22. class User { } classtransinetUserextendssfUser { }
- , -namespace symfony
23. classCar { public$numOfWheels= 4 ; protected$engine=null ; public functiongetWheels () { //.. } }
- . protected private .
24.
- , , .
- $isSomething ,$useSomething
25. $somethingAt$dateOfSomething 26.
- $numOfSomething$somethingCount
27. - - getSomething()setSomething($value) 28. renderSomething() 29. $someArray= array ( 'foo' => 'bar' , 'spam' => 'ham' , 'bzz' => array ( 'bzz1' , 'bzz2' ) ) ;
30.
- if ,for ,while ,switch
31. , . 32. , , 33. // !!!111 if ( $i> 0 )$i+= 4 ; // if ( $i> 0 ) { $i+= 4 ; } 34.
- switch
switch ($ condition ) { case 1 : action1() ; break ; case 2 : action2() ; break ; case 3 : default : defaultaction() ; break ; } 35.
if ( $condition1 || $condition2 || $condition3 ) { // code here } 36.
- C ( /* */ ) C++ ( // ), Perl ( # ) .
// $name= 'preved' ; 37.
- .
38. , . 39. " ", . 40. classToolbar{ } classphUserextendssfUser { } 41.
- , .
classCar { public$numOfWheels= 4 ; protected$engine=null ; public functiongetWheels () { //.. } protected functionloadWheels () { } } 42. HTML HTML c PHP
- , HTML
43. PHP 44. if: elseif: endif, foreach: endforeach .. 45. switch if else 46. HTML HTML c PHP < div > < strong > strong > div > 47. HTML HTML c PHP
- PHP .
48. YML
UserProfile : columns : name : type : string length : 255 status : type :enum values : -active -unactive -pending default :active 49. SQL
- .
50. : , , . 51. < >_< > 52. SQL
- ( PHP)
53. is_... 54. ..._at 55. SQL
- SQL ( ) , .
56. SQL . 57. SQL SELECT t.id,t.owner_sf_guard_user_id,t.created_at,t.is_draftFROM event tWHEREt . ended_at> NOW () 58.
- ?