프로그래밍 스타일프로그래밍 스타일(Programming style) 또는 코드 스타일(code style)은 컴퓨터 프로그램의 소스 코드를 작성할 때 사용되는 규칙이나 지침들의 모임이다. 특정 프로그래밍 스타일을 준수하면 프로그래머들이 해당 스타일에 준수하는 소스 코드를 읽고 이해하는데 도움을 주고 오류 유입을 막는데 도움을 준다고 주장된다. 이 주제와 관련하여 1970년대의 고전 작품인 프로그래밍 스타일의 요소(The Elements of Programming Style)는 당시 일반적이었던 포트란과 PL/I의 예시가 포함되었다. 코드상의 모습들여쓰기들여쓰기 방식은 코드의 제어 흐름과 블록을 식별하는데 도움을 준다. 다음은 모두 같은 방식으로 동작하는 코드이다. if (hours < 24 && minutes < 60 && seconds < 60) {
return true;
} else {
return false;
}
또는 if (hours < 24 && minutes < 60 && seconds < 60)
{
return true;
}
else
{
return false;
}
또는 if ( hours < 24
&& minutes < 60
&& seconds < 60
)
{return true
;} else
{return false
;}
수직 정렬오자로 생성된 버그를 더 명확하게 만들기 위해서는 비슷한 요소들을 수직으로 정렬하면 도움이 될 수 있다. 다음 두 코드를 비교할 것: $search = array('a', 'b', 'c', 'd', 'e');
$replacement = array('foo', 'bar', 'baz', 'quux');
// Another example:
$value = 0;
$anothervalue = 1;
$yetanothervalue = 2;
$search = array('a', 'b', 'c', 'd', 'e');
$replacement = array('foo', 'bar', 'baz', 'quux');
// Another example:
$value = 0;
$anothervalue = 1;
$yetanothervalue = 2;
탭int ix; // Index to scan array
long sum; // Accumulator for sum
int ix; // Index to scan array
long sum; // Accumulator for sum
같이 보기외부 링크 |
Index:
pl ar de en es fr it arz nl ja pt ceb sv uk vi war zh ru af ast az bg zh-min-nan bn be ca cs cy da et el eo eu fa gl ko hi hr id he ka la lv lt hu mk ms min no nn ce uz kk ro simple sk sl sr sh fi ta tt th tg azb tr ur zh-yue hy my ace als am an hyw ban bjn map-bms ba be-tarask bcl bpy bar bs br cv nv eml hif fo fy ga gd gu hak ha hsb io ig ilo ia ie os is jv kn ht ku ckb ky mrj lb lij li lmo mai mg ml zh-classical mr xmf mzn cdo mn nap new ne frr oc mhr or as pa pnb ps pms nds crh qu sa sah sco sq scn si sd szl su sw tl shn te bug vec vo wa wuu yi yo diq bat-smg zu lad kbd ang smn ab roa-rup frp arc gn av ay bh bi bo bxr cbk-zam co za dag ary se pdc dv dsb myv ext fur gv gag inh ki glk gan guw xal haw rw kbp pam csb kw km kv koi kg gom ks gcr lo lbe ltg lez nia ln jbo lg mt mi tw mwl mdf mnw nqo fj nah na nds-nl nrm nov om pi pag pap pfl pcd krc kaa ksh rm rue sm sat sc trv stq nso sn cu so srn kab roa-tara tet tpi to chr tum tk tyv udm ug vep fiu-vro vls wo xh zea ty ak bm ch ny ee ff got iu ik kl mad cr pih ami pwn pnt dz rmy rn sg st tn ss ti din chy ts kcg ve
Portal di Ensiklopedia Dunia