Content deleted Content added
Jerryobject (talk | contribs) m Cut needless carriage return whitespace characters in sections: to standardize, aid work via small screens. |
|||
(12 intermediate revisions by 11 users not shown) | |||
Line 2:
{{More citations needed|date=June 2016}}
'''Programming style''', also known as '''coding style''',
Maintaining a consistent style across a codebase can improve readability and ease of software maintenance. It allows developers to quickly understand code written by others and reduces the likelihood of errors during modifications. Adhering to standardized coding guidelines ensures that teams follow a uniform approach, making the codebase easier to manage and scale. Many organizations and [[Open source|open-source]] projects adopt specific coding standards to facilitate collaboration and reduce cognitive load.
Line 14:
Common elements of coding style include:
* ''Indentation and [[whitespace character]] use'' – Ensures consistent block structures and improves readability.
* ''Naming conventions'' – Standardizes how [[Variable (computer science)|variables]], [[Function (computer programming)|functions]], and [[Class (computer programming)|classes]] are named, typically adhering to [[Camel case|camelCase]], [[
* ''Capitalization'' – Dictates whether keywords and identifiers are capitalized or lowercase, in line with language syntax.
* ''Comment use'' – Provides context and explanations within code without affecting its execution.
=== Indentation ===
Indentation style can assist a reader in various
For example, formatted in a commonly
<syntaxhighlight lang="c">
Line 47:
==== Notable indenting styles ====
===== ModuLiq =====
{{Further|ModuLiq}}
The '''ModuLiq''' Zero Indentation Style groups by empty line rather than indenting.
Example:
Line 60 ⟶ 61:
===== Lua =====
{{Further|Lua}}
<syntaxhighlight lang="lua">
if hours < 24 and minutes < 60 and seconds < 60 then
Line 72 ⟶ 74:
===== Python =====
{{Further|Python (programming language)}}
<syntaxhighlight lang="python">
Line 86 ⟶ 89:
===== Haskell =====
{{Further|Haskell}}
Haskell is a declarative language, there are statements, but declarations within a Haskell script.
Example:
Line 186 ⟶ 190:
=== Whitespace ===
A [[free-format language]] ignores [[whitespace character]]s: spaces, tabs and new lines so the programmer is free to style the code in different ways without affecting the meaning of the code. Generally, the programmer uses style that is considered to enhance [[readability]].
The two code snippets below are the same logically, but differ in whitespace.
Line 240 ⟶ 244:
== References ==
{{Reflist}}
[[Category:Source code]]
|