Skip to content

Commit

Permalink
Add C++ functions and methods section to developer notes
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatack committed May 9, 2022
1 parent 5fca70f commit 91d6d4a
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ public:
} // namespace foo
```

Coding Style (C++ functions and methods)
--------------------

- Input and in-out parameters should be ordered first and output parameters
should come last.

- Prefer returning values directly (using `std::optional`, where helpful) to
using output parameters.


Coding Style (C++ named arguments)
------------------------------

Expand Down Expand Up @@ -1390,22 +1400,9 @@ communication:
virtual boost::signals2::scoped_connection connectTipChanged(TipChangedFn fn) = 0;
```
- For consistency and friendliness to code generation tools, interface method
input and in-out parameters should be ordered first and output parameters
should come last.
Example:
- Interface methods should not be overloaded.
```c++
// Good: error output param is last
virtual bool broadcastTransaction(const CTransactionRef& tx, CAmount max_fee, std::string& error) = 0;
// Bad: error output param is between input params
virtual bool broadcastTransaction(const CTransactionRef& tx, std::string& error, CAmount max_fee) = 0;
```

- For friendliness to code generation tools, interface methods should not be
overloaded:
*Rationale*: consistency and friendliness to code generation tools.
Example:
Expand All @@ -1421,10 +1418,11 @@ communication:

### Internal interface naming style

- For consistency and friendliness to code generation tools, interface method
names should be `lowerCamelCase` and standalone function names should be
- Interface method names should be `lowerCamelCase` and standalone function names should be
`UpperCamelCase`.

*Rationale*: consistency and friendliness to code generation tools.

Examples:

```c++
Expand Down

0 comments on commit 91d6d4a

Please sign in to comment.