Code standardization
En SelfishWe understand the critical importance of maintaining high standards in code writing and structuring. This page is dedicated to our code standardization guidelines, a set of rules and practices that we rigorously follow to ensure the quality, efficiency, and maintainability of our web development projects.
Here you will find a detailed guide to our methods and principles for code standardization, designed not only to improve the consistency and predictability of our work, but also to facilitate collaboration and understanding between our team members and our clients.
These guidelines are the result of years of experience and continuous learning, reflecting industry best practices and adapting to the latest trends and technologies in software development. Whether you're a member of our team, a contributor, or simply someone interested in coding best practices, we're confident you'll find this information valuable and enriching.
Readable and clean code.
Avoid mixing code with similar functions.
Tabulation to 4 spaces.
CRLF only to LF.
Proper use of spaces.
Output parameters at the beginning.
English code.
Although the page may be in several languages, as a standard practice it would be correct for our programming to be done in English.
Self-descriptive variables.
A variable should be understandable by its name, keeping in mind that it should be as brief as possible.
Divide and conquer
Perform functions and atomic code for repetitive tasks.
Implementing functions helps keep the program with the least amount of repeated code and granularizes functions for easier maintenance.
Ternary operators when appropriate
Encourage the correct use of ternary operators when they do not affect the readability of the code.
Notation
By convention and user preference, the notation to be used will be “Snake Case”
With the exception of class handling as it suits the programming language being used, where in most cases classes are named with CamelCase
Booleans with the prefix (is)
Following the logic of programming in English and by standard, the correct thing to do is to use the prefix "is" when declaring a boolean variable or when creating a function whose purpose is to return a similar answer.
Proper code documentation and separation
It will be necessary to provide basic comments on how the code works, as well as clues to help describe variables and easily find which part of the code is located.
Explicit comparison
As a method of error prevention, the correct approach is to use explicit comparisons within the control structures.
Validation of empty strings
As a method of risk prevention, the correct thing to do is to use the tools that language can provide us.
Avoid unnecessary variables
In both PHP and Javascript, code can be made more efficient by avoiding the creation of unnecessary variables.
Avoid multiple use of queries and DOM accesses.
In addition to the previous point, when it is necessary to perform multiple queries in any language, the correct thing to do is to perform the query only once and use a variable.
Exceptions handling
The correct use of exceptions supports error handling that does not break the functionality of the code.
Using jQuery.
By convention, the recommendation will be to use jQuery as the method for accessing the DOM when necessary.
Avoid database queries.
By convention, the recommendation will be to use jQuery as the method for accessing the DOM when necessary.
Avoid database queries.
WordPress offers a large number of data query functions, so direct database queries should be avoided whenever possible.
Avoid components dependent on third parties.
To avoid dependencies on third-party functions, whenever possible the correct approach is to try to obtain the code to be used and add it to WordPress.
KISS method.
KISS is an acronym for Keep It Simply Stupid. Simple and easy-to-understand code is much easier to maintain in the long run, so it's sometimes worth sacrificing a little performance to ensure the code adheres to this principle.
Use a standard IDE.
Due to contractual obligations, the same IDE will be used when working on projects outside of WordPress. VS Code will be used.
Implement version control software.
Git will be implemented as the version control software.










