Design Philosophies - Getbeans/Beans GitHub Wiki
In Beans, we have several design philosophies which each contributor should embrace when contributing source code and/or tests. This page discusses these philosophies.
Full WordPress Compliance
We strive for full compliance to the WordPress Coding Standard. Though there are some exceptions, we provide the reasoning of each exception in the rule ignore. In general, our philosophy is to comply.
Small Memory Footprint
Memory consumption is important to us. We seek to clean up after ourselves, releasing memory whenever possible or avoiding added memory if the conditions are not correct to proceed.
We use a "bail out early" pattern to avoid unnecessary operations and memory if the conditions are not right to continue.
unset variables to release memory when we're done with it.
Escape the Output Before Rendering
The HTML that is built by Beans is escaped before it renders. We have several wrapper functions which invoke a HTML builder function, such as
beans_open_markup_e and others. The escaping is done at the point where the HTML is built.
For custom content that hooks into one of the provided action or filter events, the theme or plugin developer is responsible to properly escape content that will be rendered out to the browser.
For example, when hooking into the
'_before_markup' action event,
beans_open_markup does not provide additional escaping on the returned content. Here, the developer is responsible to properly escape all output content before returning it to Beans.
Able to Pass Additional Arguments
You will notice that we use
func_get_args() throughout the Beans' APIs. In doing so, we allow developers to pass additional arguments to the functions which then are made available in the action and filter hooks.
This design gives maximum flexibility to developers when building with Beans.
Clean Global Space
In Beans, we seek to keep the global space clean by avoiding global variables and constants. In a continuing effort, we are replacing original code with functionality to avoid globals and constants.