SlideShare a Scribd company logo
Saranya Siripuekpong
SPECIAL TOPIC
Name the world
Naming convention!
for any programming languages!
27 June 2015
รันยาคือใคร
27 June 2015
WHO AM I?
2@rzranya
ที่ทำงานปัจจุบัน
27 June 2015
WHO AM I?
3@rzranya
Saranya Siripuekpong
หัวข้อวันนี้
Name the world
Naming convention!
for any programming languages!
Based on PHP!
27 June 2015
Review
27 June 2015 5@rzranya
PHP Variable name rules
27 June 2015
Review
6@rzranya
PHP Variable name rules
!
!
[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*!
27 June 2015
Review
source: php.net!
7@rzranya
PHP Variable name rules
•  A variable starts with the $ sign, followed by
the name of the variable!
•  A variable name must start with a letter or the
underscore character!
•  A variable name cannot start with a number!
•  A variable name can only contain alpha-
numeric characters and underscores (A-z,
0-9, and _ )!
•  Variable names are case-sensitive ($age and
$AGE are two different variables)!
27 June 2015
Review
source: w3schools.com!
8@rzranya
PHP Reserved words: Keywords
__halt_compiler()! abstract! and! array()! as!
break! callable! case! catch! class!
clone! const! continue! declare! default!
die()! do! echo! else! elseif!
empty()! enddeclare! endfor! endforeach! endif!
endswitch! endwhile! eval()! exit()! extends!
final! finally! for! foreach! function!
global! goto! if! implements! include!
include_once! instanceof! insteadof! interface! isset()!
list()! namespace! new! or! print!
private! protected! public! require! require_once!
return! static! switch! throw! trait!
try! unset()! use! var! while!
xor! yield!
27 June 2015
Review
9@rzranya
PHP Reserved words: Predefined
27 June 2015
Review
•  __CLASS__!
•  __DIR__!
•  __FILE__!
•  __FUNCTION__!
•  __LINE__!
•  __METHOD__!
•  __NAMESPACE__!
•  __TRAIT__!
source: php.net!
10@rzranya
PHP Reserved words: Other
•  int!
•  float!
•  bool!
•  string!
•  true!
•  false!
•  null!
•  resource!
•  object!
•  mixed!
•  numeric!
27 June 2015
Review
source: php.net!
11@rzranya
PHP Function
calculateMe() vs Calculateme()!
27 June 2015
Review
12@rzranya
Naming in PHP
•  Case sensitive!
–  variables!
–  constants!
–  array keys!
–  class properties!
–  class constants!
•  Case insensitive!
–  functions!
–  class constructors!
–  class methods!
–  keywords and
constructs (if, else,
null, foreach, echo
etc.)!
27 June 2015
Review
source: the-echoplex.net!
13@rzranya
Naming in JAVA
•  Classes!
•  Methods!
•  Variables!
•  Constants!
27 June 2015
Review
14@rzranya
Letter case styles
•  UPPERCASE!
•  lowercase!
•  camelCase!
•  PascalCase!
•  train-case!
•  snake_case!
•  StUdLyCaPs!
•  Acronyms treatment: ALL CAPS!
27 June 2015
Review
15@rzranya
Reserved words in JAVA
abstract	 continue	 for	 new	 switch	
assert	 default	 goto	 package	 synchronized	
boolean	 do	 if	 private	 this	
break	 double	 implements	 protected	 throw	
byte	 else	 import	 public	 throws	
case	 enum	 instanceof	 return	 transient	
catch	 extends	 int	 short	 try	
char	 final	 interface	 static	 void	
class	 finally	 long	 strictfp	 volatile	
const	 float	 native	 super	 while	
27 June 2015
Review
source: oracle.com!
16@rzranya
JavaScript
•  $ /!
•  _!
•  ClassesName!
•  methodName!
•  GLOBAL_VARIABLE!
27 June 2015
Review
17@rzranya
SQL Reserved words
•  ANSI SQL 92!
•  ANSI SQL 99!
•  ANSI SQL 2003!
•  MySQL 3.23.x!
•  MySQL 4.x!
•  MySQL 5.x!
•  PostGreSQL 8.1!
•  MS SQL Server 2000!
•  MS ODBC!
•  Oracle 10.2!
27 June 2015
Review
source: drupal.org!
18@rzranya
What we need to name?
•  Variables!
•  Types, Class!
•  Function, Method!
•  File, Directory!
•  Namespace, Library!
•  Server, Device!
•  Project !?!
27 June 2015
Review
19@rzranya
PHP Naming Conventions
27 June 2015 20@rzranya
27 June 2015
PHP Naming Conventions
21@rzranya
27 June 2015
PHP Naming Conventions
source: wordpress.com!
22@rzranya
•  Use camelCase, not underscores, for
variable, function and method names,
arguments;!
•  Use underscores for option names and
parameter names;!
•  Use namespaces for all classes;!
•  Prefix abstract classes with
Abstract. Please note some early XX
classes do not follow this
convention and have not been renamed
for backward compatibility reasons.
However all new abstract classes
must follow this naming convention;!
•  Suffix interfaces with Interface;!
•  Suffix traits with Trait;!
•  Suffix exceptions with Exception;!
•  Use alphanumeric characters and
underscores for file names;!
27 June 2015
PHP Naming Conventions
23@rzranya
•  Use camelCase, not underscores, for
variable, function and method names,
arguments;!
•  Use underscores for option names and
parameter names;!
•  Use namespaces for all classes;!
•  Prefix abstract classes with
Abstract. Please note some early XX
classes do not follow this
convention and have not been renamed
for backward compatibility reasons.
However all new abstract classes
must follow this naming convention;!
•  Suffix interfaces with Interface;!
•  Suffix traits with Trait;!
•  Suffix exceptions with Exception;!
•  Use alphanumeric characters and
underscores for file names;!
27 June 2015
PHP Naming Conventions
source: symfony.com!
24@rzranya
•  Both database tables and columns are named in lower
case.!
•  Words in a name should be separated using
underscores (e.g. product_order).!
•  For table names, you may use either singular or plural
names, but not both. For simplicity, we recommend
using singular names.!
•  Table names may be prefixed with a common token
such as tbl_. This is especially useful when the
tables of an application coexist in the same database
with the tables of another application. The two sets of
tables can be readily separate by using different table
name prefixes.!
27 June 2015
PHP Naming Conventions
25@rzranya
•  Both database tables and columns are named in lower
case.!
•  Words in a name should be separated using
underscores (e.g. product_order).!
•  For table names, you may use either singular or plural
names, but not both. For simplicity, we recommend
using singular names.!
•  Table names may be prefixed with a common token
such as tbl_. This is especially useful when the
tables of an application coexist in the same database
with the tables of another application. The two sets of
tables can be readily separate by using different table
name prefixes.!
27 June 2015
PHP Naming Conventions
source: yiiframework.com!
26@rzranya
Frameworks & CMS Conventions
!
PHP Project Classes Methods Properties Functions Variables !
!
Akelos Framework PascalCase camelCase camelCase lower_case lower_case !
CakePHP Framework PascalCase camelCase camelCase camelCase camelCase !
CodeIgniter Framework Proper_Case lower_case lower_case lower_case lower_case !
Concrete5 CMS PascalCase camelCase camelCase lower_case lower_case !
Doctrine ORM PascalCase camelCase camelCase camelCase camelCase !
Drupal CMS PascalCase camelCase camelCase lower_case lower_case !
Joomla CMS PascalCase camelCase camelCase camelCase camelCase !
modx CMS PascalCase camelCase camelCase camelCase lower_case !
Pear Framework PascalCase camelCase camelCase !
Prado Framework PascalCase camelCase Pascal/camel lower_case !
SimplePie RSS PascalCase lower_case lower_case lower_case lower_case !
Symfony Framework PascalCase camelCase camelCase camelCase camelCase !
WordPress CMS lower_case lower_case !
Zend Framework PascalCase camelCase camelCase camelCase camelCase !
!
27 June 2015
PHP Naming Conventions
source: Jason Holland, 2012.!
27@rzranya
Frameworks & CMS Conventions
•  ClassName – PascalCase!
•  methodName – camelCase !
•  propertyName – camelCase !
•  regular_function_name – snake_case!
•  $variable_name – snake_case !
27 June 2015 @rzranya 28
PHP Naming Conventions
source: Jason Holland, 2012.!
INCORRECT:!
function fileproperties() ! !// not descriptive and needs underscore separator!
function fileProperties() ! !// not descriptive and uses CamelCase!
function getfileproperties() ! !// Better! But still missing underscore separator!
function getFileProperties() ! !// uses CamelCase!
function get_the_file_properties_from_the_file() !// wordy!
!
CORRECT:!
function get_file_properties() !// descriptive, underscore separator, and all !
! ! ! ! ! ! !// lowercase letters!
!
INCORRECT:!
$j = 'foo'; ! !// single letter variables should only be used in for() loops!
$Str! ! ! !// contains uppercase letters!
$bufferedText ! !// uses CamelCasing, and could be shortened without losing semantic
meaning!
$groupid ! ! !// multiple words, needs underscore separator!
$name_of_last_city_used // too long!
!
CORRECT:!
for ($j = 0; $j < 10; $j++)!
$str!
$buffer!
$group_id!
$last_city!
27 June 2015
PHP Naming Conventions
source: ellislab.com!
29@rzranya
Global Naming Convention
27 June 2015 30@rzranya
27 June 2015
Naming Conventions: Example
credit: facebook.com!
31@rzranya
27 June 2015
Naming Conventions: Example
32@rzranya
General Naming Conventions
1.  Length!
2.  Letter case or delimiter!
3.  Notation!
27 June 2015
Naming Conventions
33@rzranya
โปรแกรมนี้ทำอะไร?
!
!
function calc($t, $w) {!
!$p = $t * $w * 0.97;!
!return $p;!
}!
27 June 2015
Naming Conventions
34@rzranya
โปรแกรมนี้ทำอะไร?
!
!
define(‘WH_TAX_RATE’, 0.03);!
!
function calculate_payout($hour, $rate) {!
!return $hour * $rate * (1 – WH_TAX_RATE);!
}!
27 June 2015
Naming Conventions
35@rzranya
โปรแกรมนี้ทำอะไร?
27 June 2015
Naming Conventions
36@rzranya
โปรแกรมนี้ทำอะไร?
27 June 2015
Naming Conventions
37@rzranya
Naming Strategy
27 June 2015 38@rzranya
Naming Strategy
DO!
•  Variables !what it contains (noun)!
•  Class ! !how you call it in general (noun)!
•  Constant !type of usage&value (nominal phrase)!
•  Function !what it does (verb)!
27 June 2015
Naming Strategy
39@rzranya
Naming Strategy
DO!
•  File ! !what it applies to the program (noun)!
•  Folder !type of files it contains || part name (noun)!
•  Table! !Object or action it records 

! ! ! !(noun / verb / noun & verb)!
•  Field! !what it contains (noun)!
•  FK! ! !what it refers to (and may be how)!
27 June 2015
Naming Strategy
40@rzranya
Naming Strategy
DO!
Short and meaningful!
!
Avoid programming keywords!
!
English!
27 June 2015
Naming Strategy
41@rzranya
Naming Strategy
Don’t!
Too long!
!
1 character name!
!
Karaoke!
27 June 2015
Naming Strategy
42@rzranya
Naming Strategy
1.  Examine it as object!
2.  Write full description!
i.  What is is?!
ii.  What it does?!
3.  Find n. , v. or extract to phrase!
4.  Check its distinctness!
27 June 2015
Naming Strategy
43@rzranya
Example
27 June 2015 44@rzranya
27 June 2015
Example
45@rzranya
2"
1"
remove&item&from&shopping&cart
remove&cart’s&item
removeCartItem
rating&this&product
rate&product
AddProductRating
27 June 2015
Example
46@rzranya
3"
4"
27 June 2015
Example
47@rzranya
3"
4"
review"
review_comment"
reviewScore"
rv_msg"
ra5ngreview"
27 June 2015
Example
48@rzranya
27 June 2015
Example
49@rzranya
27 June 2015
Example
50@rzranya
จัดห้องสำหรับงาน Code Mania
27 June 2015
Example
51@rzranya
ถามได้นะ
27 June 2015 52@rzranya
please make them …
Short and meaningful ! !NOT ! !Too long!
!
Noun, Verb, or Phrase ! !NOT ! !1 character name!
! ! ! ! ! ! ! ! ! ! !(except temporary or !
! ! ! ! ! ! ! ! ! ! !throwaway)!
!
English ! ! ! ! ! !NOT ! !Karaoke!
!
Distinctive ! ! ! ! !NOT ! !Ambiguous!
27 June 2015
When you name the world,
53@rzranya
จบแล้ว
27 June 2015 54@rzranya

More Related Content

Similar to Name the World

Psr 2 coding style guide - Tidepool Labs
Psr 2   coding style guide - Tidepool LabsPsr 2   coding style guide - Tidepool Labs
Psr 2 coding style guide - Tidepool Labs
Harutyun Abgaryan
 
Materi Dasar PHP
Materi Dasar PHPMateri Dasar PHP
Materi Dasar PHP
Robby Firmansyah
 
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Muhamad Al Imran
 
Php basics
Php basicsPhp basics
Php basics
Jamshid Hashimi
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
KIRAN KUMAR SILIVERI
 
Php introduction
Php introductionPhp introduction
Php introduction
krishnapriya Tadepalli
 
Hsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdfHsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdf
AAFREEN SHAIKH
 
php basics
php basicsphp basics
php basics
Anmol Paul
 
GTU PHP Project Training Guidelines
GTU PHP Project Training GuidelinesGTU PHP Project Training Guidelines
GTU PHP Project Training Guidelines
TOPS Technologies
 
01-basics.ppt
01-basics.ppt01-basics.ppt
01-basics.ppt
SmartKutti1
 
Let's PHP in a better way! - Coding Recommendations.
Let's PHP in a better way! - Coding Recommendations.Let's PHP in a better way! - Coding Recommendations.
Let's PHP in a better way! - Coding Recommendations.
Leekas Shep
 
php basic
php basicphp basic
php basic
zalatarunk
 
01 basics
01 basics01 basics
01 basics
Ashwini1593
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02) iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
Jonathan Engelsma
 
PHP Variables and scopes
PHP Variables and scopesPHP Variables and scopes
PHP Variables and scopes
sana mateen
 
introduction to server-side scripting
introduction to server-side scriptingintroduction to server-side scripting
introduction to server-side scripting
Amirul Shafeeq
 
Php classes in mumbai
Php classes in mumbaiPhp classes in mumbai
Php classes in mumbai
Vibrant Technologies & Computers
 
Lecture-3.pptx and faculty. His research interests include RF sensing,
Lecture-3.pptx and faculty. His research interests include RF sensing,Lecture-3.pptx and faculty. His research interests include RF sensing,
Lecture-3.pptx and faculty. His research interests include RF sensing,
MuhammadUsmanYaseen2
 
BioSamples Database Linked Data, SWAT4LS Tutorial
BioSamples Database Linked Data, SWAT4LS TutorialBioSamples Database Linked Data, SWAT4LS Tutorial
BioSamples Database Linked Data, SWAT4LS Tutorial
Rothamsted Research, UK
 
Software Engineering Thailand: Programming with Scala
Software Engineering Thailand: Programming with ScalaSoftware Engineering Thailand: Programming with Scala
Software Engineering Thailand: Programming with Scala
Brian Topping
 

Similar to Name the World (20)

Psr 2 coding style guide - Tidepool Labs
Psr 2   coding style guide - Tidepool LabsPsr 2   coding style guide - Tidepool Labs
Psr 2 coding style guide - Tidepool Labs
 
Materi Dasar PHP
Materi Dasar PHPMateri Dasar PHP
Materi Dasar PHP
 
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
 
Php basics
Php basicsPhp basics
Php basics
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Php introduction
Php introductionPhp introduction
Php introduction
 
Hsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdfHsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdf
 
php basics
php basicsphp basics
php basics
 
GTU PHP Project Training Guidelines
GTU PHP Project Training GuidelinesGTU PHP Project Training Guidelines
GTU PHP Project Training Guidelines
 
01-basics.ppt
01-basics.ppt01-basics.ppt
01-basics.ppt
 
Let's PHP in a better way! - Coding Recommendations.
Let's PHP in a better way! - Coding Recommendations.Let's PHP in a better way! - Coding Recommendations.
Let's PHP in a better way! - Coding Recommendations.
 
php basic
php basicphp basic
php basic
 
01 basics
01 basics01 basics
01 basics
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02) iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
 
PHP Variables and scopes
PHP Variables and scopesPHP Variables and scopes
PHP Variables and scopes
 
introduction to server-side scripting
introduction to server-side scriptingintroduction to server-side scripting
introduction to server-side scripting
 
Php classes in mumbai
Php classes in mumbaiPhp classes in mumbai
Php classes in mumbai
 
Lecture-3.pptx and faculty. His research interests include RF sensing,
Lecture-3.pptx and faculty. His research interests include RF sensing,Lecture-3.pptx and faculty. His research interests include RF sensing,
Lecture-3.pptx and faculty. His research interests include RF sensing,
 
BioSamples Database Linked Data, SWAT4LS Tutorial
BioSamples Database Linked Data, SWAT4LS TutorialBioSamples Database Linked Data, SWAT4LS Tutorial
BioSamples Database Linked Data, SWAT4LS Tutorial
 
Software Engineering Thailand: Programming with Scala
Software Engineering Thailand: Programming with ScalaSoftware Engineering Thailand: Programming with Scala
Software Engineering Thailand: Programming with Scala
 

Recently uploaded

Pro-competitive Industrial Policy – LANE – June 2024 OECD discussion
Pro-competitive Industrial Policy – LANE – June 2024 OECD discussionPro-competitive Industrial Policy – LANE – June 2024 OECD discussion
Pro-competitive Industrial Policy – LANE – June 2024 OECD discussion
OECD Directorate for Financial and Enterprise Affairs
 
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
OECD Directorate for Financial and Enterprise Affairs
 
Gregory Harris - Cycle 2 - Civics Presentation
Gregory Harris - Cycle 2 - Civics PresentationGregory Harris - Cycle 2 - Civics Presentation
Gregory Harris - Cycle 2 - Civics Presentation
gharris9
 
Pro-competitive Industrial Policy – OECD – June 2024 OECD discussion
Pro-competitive Industrial Policy – OECD – June 2024 OECD discussionPro-competitive Industrial Policy – OECD – June 2024 OECD discussion
Pro-competitive Industrial Policy – OECD – June 2024 OECD discussion
OECD Directorate for Financial and Enterprise Affairs
 
XP 2024 presentation: A New Look to Leadership
XP 2024 presentation: A New Look to LeadershipXP 2024 presentation: A New Look to Leadership
XP 2024 presentation: A New Look to Leadership
samililja
 
Competition and Regulation in Professions and Occupations – OECD – June 2024 ...
Competition and Regulation in Professions and Occupations – OECD – June 2024 ...Competition and Regulation in Professions and Occupations – OECD – June 2024 ...
Competition and Regulation in Professions and Occupations – OECD – June 2024 ...
OECD Directorate for Financial and Enterprise Affairs
 
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie WellsCollapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Rosie Wells
 
The remarkable life of Sir Mokshagundam Visvesvaraya.pptx
The remarkable life of Sir Mokshagundam Visvesvaraya.pptxThe remarkable life of Sir Mokshagundam Visvesvaraya.pptx
The remarkable life of Sir Mokshagundam Visvesvaraya.pptx
JiteshKumarChoudhary2
 
Artificial Intelligence, Data and Competition – OECD – June 2024 OECD discussion
Artificial Intelligence, Data and Competition – OECD – June 2024 OECD discussionArtificial Intelligence, Data and Competition – OECD – June 2024 OECD discussion
Artificial Intelligence, Data and Competition – OECD – June 2024 OECD discussion
OECD Directorate for Financial and Enterprise Affairs
 
IEEE CIS Webinar Sustainable futures.pdf
IEEE CIS Webinar Sustainable futures.pdfIEEE CIS Webinar Sustainable futures.pdf
IEEE CIS Webinar Sustainable futures.pdf
Claudio Gallicchio
 
ASONAM2023_presection_slide_track-recommendation.pdf
ASONAM2023_presection_slide_track-recommendation.pdfASONAM2023_presection_slide_track-recommendation.pdf
ASONAM2023_presection_slide_track-recommendation.pdf
ToshihiroIto4
 
Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...
Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...
Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...
OECD Directorate for Financial and Enterprise Affairs
 
原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样
原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样
原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样
gpww3sf4
 
Artificial Intelligence, Data and Competition – LIM – June 2024 OECD discussion
Artificial Intelligence, Data and Competition – LIM – June 2024 OECD discussionArtificial Intelligence, Data and Competition – LIM – June 2024 OECD discussion
Artificial Intelligence, Data and Competition – LIM – June 2024 OECD discussion
OECD Directorate for Financial and Enterprise Affairs
 
BRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdf
BRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdfBRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdf
BRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdf
Robin Haunschild
 
Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...
Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...
Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...
Suzanne Lagerweij
 
Carrer goals.pptx and their importance in real life
Carrer goals.pptx  and their importance in real lifeCarrer goals.pptx  and their importance in real life
Carrer goals.pptx and their importance in real life
artemacademy2
 
The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...
The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...
The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...
OECD Directorate for Financial and Enterprise Affairs
 
Using-Presentation-Software-to-the-Fullf.pptx
Using-Presentation-Software-to-the-Fullf.pptxUsing-Presentation-Software-to-the-Fullf.pptx
Using-Presentation-Software-to-the-Fullf.pptx
kainatfatyma9
 
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
OECD Directorate for Financial and Enterprise Affairs
 

Recently uploaded (20)

Pro-competitive Industrial Policy – LANE – June 2024 OECD discussion
Pro-competitive Industrial Policy – LANE – June 2024 OECD discussionPro-competitive Industrial Policy – LANE – June 2024 OECD discussion
Pro-competitive Industrial Policy – LANE – June 2024 OECD discussion
 
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
 
Gregory Harris - Cycle 2 - Civics Presentation
Gregory Harris - Cycle 2 - Civics PresentationGregory Harris - Cycle 2 - Civics Presentation
Gregory Harris - Cycle 2 - Civics Presentation
 
Pro-competitive Industrial Policy – OECD – June 2024 OECD discussion
Pro-competitive Industrial Policy – OECD – June 2024 OECD discussionPro-competitive Industrial Policy – OECD – June 2024 OECD discussion
Pro-competitive Industrial Policy – OECD – June 2024 OECD discussion
 
XP 2024 presentation: A New Look to Leadership
XP 2024 presentation: A New Look to LeadershipXP 2024 presentation: A New Look to Leadership
XP 2024 presentation: A New Look to Leadership
 
Competition and Regulation in Professions and Occupations – OECD – June 2024 ...
Competition and Regulation in Professions and Occupations – OECD – June 2024 ...Competition and Regulation in Professions and Occupations – OECD – June 2024 ...
Competition and Regulation in Professions and Occupations – OECD – June 2024 ...
 
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie WellsCollapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
 
The remarkable life of Sir Mokshagundam Visvesvaraya.pptx
The remarkable life of Sir Mokshagundam Visvesvaraya.pptxThe remarkable life of Sir Mokshagundam Visvesvaraya.pptx
The remarkable life of Sir Mokshagundam Visvesvaraya.pptx
 
Artificial Intelligence, Data and Competition – OECD – June 2024 OECD discussion
Artificial Intelligence, Data and Competition – OECD – June 2024 OECD discussionArtificial Intelligence, Data and Competition – OECD – June 2024 OECD discussion
Artificial Intelligence, Data and Competition – OECD – June 2024 OECD discussion
 
IEEE CIS Webinar Sustainable futures.pdf
IEEE CIS Webinar Sustainable futures.pdfIEEE CIS Webinar Sustainable futures.pdf
IEEE CIS Webinar Sustainable futures.pdf
 
ASONAM2023_presection_slide_track-recommendation.pdf
ASONAM2023_presection_slide_track-recommendation.pdfASONAM2023_presection_slide_track-recommendation.pdf
ASONAM2023_presection_slide_track-recommendation.pdf
 
Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...
Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...
Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...
 
原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样
原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样
原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样
 
Artificial Intelligence, Data and Competition – LIM – June 2024 OECD discussion
Artificial Intelligence, Data and Competition – LIM – June 2024 OECD discussionArtificial Intelligence, Data and Competition – LIM – June 2024 OECD discussion
Artificial Intelligence, Data and Competition – LIM – June 2024 OECD discussion
 
BRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdf
BRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdfBRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdf
BRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdf
 
Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...
Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...
Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...
 
Carrer goals.pptx and their importance in real life
Carrer goals.pptx  and their importance in real lifeCarrer goals.pptx  and their importance in real life
Carrer goals.pptx and their importance in real life
 
The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...
The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...
The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...
 
Using-Presentation-Software-to-the-Fullf.pptx
Using-Presentation-Software-to-the-Fullf.pptxUsing-Presentation-Software-to-the-Fullf.pptx
Using-Presentation-Software-to-the-Fullf.pptx
 
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
 

Name the World

  • 1. Saranya Siripuekpong SPECIAL TOPIC Name the world Naming convention! for any programming languages! 27 June 2015
  • 4. Saranya Siripuekpong หัวข้อวันนี้ Name the world Naming convention! for any programming languages! Based on PHP! 27 June 2015
  • 6. PHP Variable name rules 27 June 2015 Review 6@rzranya
  • 7. PHP Variable name rules ! ! [a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*! 27 June 2015 Review source: php.net! 7@rzranya
  • 8. PHP Variable name rules •  A variable starts with the $ sign, followed by the name of the variable! •  A variable name must start with a letter or the underscore character! •  A variable name cannot start with a number! •  A variable name can only contain alpha- numeric characters and underscores (A-z, 0-9, and _ )! •  Variable names are case-sensitive ($age and $AGE are two different variables)! 27 June 2015 Review source: w3schools.com! 8@rzranya
  • 9. PHP Reserved words: Keywords __halt_compiler()! abstract! and! array()! as! break! callable! case! catch! class! clone! const! continue! declare! default! die()! do! echo! else! elseif! empty()! enddeclare! endfor! endforeach! endif! endswitch! endwhile! eval()! exit()! extends! final! finally! for! foreach! function! global! goto! if! implements! include! include_once! instanceof! insteadof! interface! isset()! list()! namespace! new! or! print! private! protected! public! require! require_once! return! static! switch! throw! trait! try! unset()! use! var! while! xor! yield! 27 June 2015 Review 9@rzranya
  • 10. PHP Reserved words: Predefined 27 June 2015 Review •  __CLASS__! •  __DIR__! •  __FILE__! •  __FUNCTION__! •  __LINE__! •  __METHOD__! •  __NAMESPACE__! •  __TRAIT__! source: php.net! 10@rzranya
  • 11. PHP Reserved words: Other •  int! •  float! •  bool! •  string! •  true! •  false! •  null! •  resource! •  object! •  mixed! •  numeric! 27 June 2015 Review source: php.net! 11@rzranya
  • 12. PHP Function calculateMe() vs Calculateme()! 27 June 2015 Review 12@rzranya
  • 13. Naming in PHP •  Case sensitive! –  variables! –  constants! –  array keys! –  class properties! –  class constants! •  Case insensitive! –  functions! –  class constructors! –  class methods! –  keywords and constructs (if, else, null, foreach, echo etc.)! 27 June 2015 Review source: the-echoplex.net! 13@rzranya
  • 14. Naming in JAVA •  Classes! •  Methods! •  Variables! •  Constants! 27 June 2015 Review 14@rzranya
  • 15. Letter case styles •  UPPERCASE! •  lowercase! •  camelCase! •  PascalCase! •  train-case! •  snake_case! •  StUdLyCaPs! •  Acronyms treatment: ALL CAPS! 27 June 2015 Review 15@rzranya
  • 16. Reserved words in JAVA abstract continue for new switch assert default goto package synchronized boolean do if private this break double implements protected throw byte else import public throws case enum instanceof return transient catch extends int short try char final interface static void class finally long strictfp volatile const float native super while 27 June 2015 Review source: oracle.com! 16@rzranya
  • 17. JavaScript •  $ /! •  _! •  ClassesName! •  methodName! •  GLOBAL_VARIABLE! 27 June 2015 Review 17@rzranya
  • 18. SQL Reserved words •  ANSI SQL 92! •  ANSI SQL 99! •  ANSI SQL 2003! •  MySQL 3.23.x! •  MySQL 4.x! •  MySQL 5.x! •  PostGreSQL 8.1! •  MS SQL Server 2000! •  MS ODBC! •  Oracle 10.2! 27 June 2015 Review source: drupal.org! 18@rzranya
  • 19. What we need to name? •  Variables! •  Types, Class! •  Function, Method! •  File, Directory! •  Namespace, Library! •  Server, Device! •  Project !?! 27 June 2015 Review 19@rzranya
  • 20. PHP Naming Conventions 27 June 2015 20@rzranya
  • 21. 27 June 2015 PHP Naming Conventions 21@rzranya
  • 22. 27 June 2015 PHP Naming Conventions source: wordpress.com! 22@rzranya
  • 23. •  Use camelCase, not underscores, for variable, function and method names, arguments;! •  Use underscores for option names and parameter names;! •  Use namespaces for all classes;! •  Prefix abstract classes with Abstract. Please note some early XX classes do not follow this convention and have not been renamed for backward compatibility reasons. However all new abstract classes must follow this naming convention;! •  Suffix interfaces with Interface;! •  Suffix traits with Trait;! •  Suffix exceptions with Exception;! •  Use alphanumeric characters and underscores for file names;! 27 June 2015 PHP Naming Conventions 23@rzranya
  • 24. •  Use camelCase, not underscores, for variable, function and method names, arguments;! •  Use underscores for option names and parameter names;! •  Use namespaces for all classes;! •  Prefix abstract classes with Abstract. Please note some early XX classes do not follow this convention and have not been renamed for backward compatibility reasons. However all new abstract classes must follow this naming convention;! •  Suffix interfaces with Interface;! •  Suffix traits with Trait;! •  Suffix exceptions with Exception;! •  Use alphanumeric characters and underscores for file names;! 27 June 2015 PHP Naming Conventions source: symfony.com! 24@rzranya
  • 25. •  Both database tables and columns are named in lower case.! •  Words in a name should be separated using underscores (e.g. product_order).! •  For table names, you may use either singular or plural names, but not both. For simplicity, we recommend using singular names.! •  Table names may be prefixed with a common token such as tbl_. This is especially useful when the tables of an application coexist in the same database with the tables of another application. The two sets of tables can be readily separate by using different table name prefixes.! 27 June 2015 PHP Naming Conventions 25@rzranya
  • 26. •  Both database tables and columns are named in lower case.! •  Words in a name should be separated using underscores (e.g. product_order).! •  For table names, you may use either singular or plural names, but not both. For simplicity, we recommend using singular names.! •  Table names may be prefixed with a common token such as tbl_. This is especially useful when the tables of an application coexist in the same database with the tables of another application. The two sets of tables can be readily separate by using different table name prefixes.! 27 June 2015 PHP Naming Conventions source: yiiframework.com! 26@rzranya
  • 27. Frameworks & CMS Conventions ! PHP Project Classes Methods Properties Functions Variables ! ! Akelos Framework PascalCase camelCase camelCase lower_case lower_case ! CakePHP Framework PascalCase camelCase camelCase camelCase camelCase ! CodeIgniter Framework Proper_Case lower_case lower_case lower_case lower_case ! Concrete5 CMS PascalCase camelCase camelCase lower_case lower_case ! Doctrine ORM PascalCase camelCase camelCase camelCase camelCase ! Drupal CMS PascalCase camelCase camelCase lower_case lower_case ! Joomla CMS PascalCase camelCase camelCase camelCase camelCase ! modx CMS PascalCase camelCase camelCase camelCase lower_case ! Pear Framework PascalCase camelCase camelCase ! Prado Framework PascalCase camelCase Pascal/camel lower_case ! SimplePie RSS PascalCase lower_case lower_case lower_case lower_case ! Symfony Framework PascalCase camelCase camelCase camelCase camelCase ! WordPress CMS lower_case lower_case ! Zend Framework PascalCase camelCase camelCase camelCase camelCase ! ! 27 June 2015 PHP Naming Conventions source: Jason Holland, 2012.! 27@rzranya
  • 28. Frameworks & CMS Conventions •  ClassName – PascalCase! •  methodName – camelCase ! •  propertyName – camelCase ! •  regular_function_name – snake_case! •  $variable_name – snake_case ! 27 June 2015 @rzranya 28 PHP Naming Conventions source: Jason Holland, 2012.!
  • 29. INCORRECT:! function fileproperties() ! !// not descriptive and needs underscore separator! function fileProperties() ! !// not descriptive and uses CamelCase! function getfileproperties() ! !// Better! But still missing underscore separator! function getFileProperties() ! !// uses CamelCase! function get_the_file_properties_from_the_file() !// wordy! ! CORRECT:! function get_file_properties() !// descriptive, underscore separator, and all ! ! ! ! ! ! ! !// lowercase letters! ! INCORRECT:! $j = 'foo'; ! !// single letter variables should only be used in for() loops! $Str! ! ! !// contains uppercase letters! $bufferedText ! !// uses CamelCasing, and could be shortened without losing semantic meaning! $groupid ! ! !// multiple words, needs underscore separator! $name_of_last_city_used // too long! ! CORRECT:! for ($j = 0; $j < 10; $j++)! $str! $buffer! $group_id! $last_city! 27 June 2015 PHP Naming Conventions source: ellislab.com! 29@rzranya
  • 30. Global Naming Convention 27 June 2015 30@rzranya
  • 31. 27 June 2015 Naming Conventions: Example credit: facebook.com! 31@rzranya
  • 32. 27 June 2015 Naming Conventions: Example 32@rzranya
  • 33. General Naming Conventions 1.  Length! 2.  Letter case or delimiter! 3.  Notation! 27 June 2015 Naming Conventions 33@rzranya
  • 34. โปรแกรมนี้ทำอะไร? ! ! function calc($t, $w) {! !$p = $t * $w * 0.97;! !return $p;! }! 27 June 2015 Naming Conventions 34@rzranya
  • 35. โปรแกรมนี้ทำอะไร? ! ! define(‘WH_TAX_RATE’, 0.03);! ! function calculate_payout($hour, $rate) {! !return $hour * $rate * (1 – WH_TAX_RATE);! }! 27 June 2015 Naming Conventions 35@rzranya
  • 38. Naming Strategy 27 June 2015 38@rzranya
  • 39. Naming Strategy DO! •  Variables !what it contains (noun)! •  Class ! !how you call it in general (noun)! •  Constant !type of usage&value (nominal phrase)! •  Function !what it does (verb)! 27 June 2015 Naming Strategy 39@rzranya
  • 40. Naming Strategy DO! •  File ! !what it applies to the program (noun)! •  Folder !type of files it contains || part name (noun)! •  Table! !Object or action it records 
 ! ! ! !(noun / verb / noun & verb)! •  Field! !what it contains (noun)! •  FK! ! !what it refers to (and may be how)! 27 June 2015 Naming Strategy 40@rzranya
  • 41. Naming Strategy DO! Short and meaningful! ! Avoid programming keywords! ! English! 27 June 2015 Naming Strategy 41@rzranya
  • 42. Naming Strategy Don’t! Too long! ! 1 character name! ! Karaoke! 27 June 2015 Naming Strategy 42@rzranya
  • 43. Naming Strategy 1.  Examine it as object! 2.  Write full description! i.  What is is?! ii.  What it does?! 3.  Find n. , v. or extract to phrase! 4.  Check its distinctness! 27 June 2015 Naming Strategy 43@rzranya
  • 44. Example 27 June 2015 44@rzranya
  • 53. please make them … Short and meaningful ! !NOT ! !Too long! ! Noun, Verb, or Phrase ! !NOT ! !1 character name! ! ! ! ! ! ! ! ! ! ! !(except temporary or ! ! ! ! ! ! ! ! ! ! ! !throwaway)! ! English ! ! ! ! ! !NOT ! !Karaoke! ! Distinctive ! ! ! ! !NOT ! !Ambiguous! 27 June 2015 When you name the world, 53@rzranya