Skip to content
Snippets Groups Projects
CODING_GUIDELINES.md 4.01 KiB

Leon Coding Guidelines

Here are a few coding guidelines that should be followed when introducing new code into Leon. Existing code that do not meet these guidelines should eventually be fixed.

Development

Global state must be concurrent-friendly

Leon relies on global state at several places, it should be assumed that this global state can be accessed concurrently, it is thus necessary to ensure that it will behave consistently. Global state should be private[this] and accessor functions synchronized. Another possibility for things like counters is to rely on Java classes such as AtomicInteger.

Even though most of Leon is sequential, parts of it is concurrent (Portfolio Solvers, Web interface, Interrupt threads, ...). It is likely to become more concurrent in the future.

Code should be predictable

Leon's execution should be predictable and reproducible. Due to the complex nature of its inner-working, it is crucial that problematic executions and bug reports are consistently reproducible.

One of the main reason behind this unpredictability is the traversal of structures that are not explicitly ordered(e.g. Set, Map, ..). Please avoid that by either explicitly ordering after .toSeq, or by using different datastructures.

Documentation