Please enable JavaScript.
Coggle requires JavaScript to display documents.
Coding Style - Coggle Diagram
Coding Style
Lexical
-
-
descriptive and meaningful names for variables, functions, and other elements of the code
following language-specific conventions for things like capitalization, spacing, and punctuation.
The goal of lexical coding style is to make code easier to read and understand for other developers who may work on the code in the future
-
Semantic
The goal of semantic coding style is to make code that is easy to read and maintain, and that can be easily understood by other developers who may work on the code in the future.
Examples
Using meaningful variable and function names that clearly describe their purpose. For example, using calculateArea instead of calc or area.
Writing code that is easy to read and understand. For example, breaking up long functions into smaller, more manageable pieces that can be more easily understood.
Following best practices for the programming language being used. For example, in JavaScript, using arrow functions for shorter, more concise code, or in Python, using list comprehensions instead of for loops for more efficient and readable code.
Using language-specific constructs in a way that is consistent with their intended purpose. For example, in JavaScript, using map() to transform arrays, or in Python, using enumerate() to iterate over a sequence while also keeping track of the index.