Skip to content

Commit 93b0b43

Browse files
committed
first quick draft of coding guidelines
1 parent 9a2d4e9 commit 93b0b43

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

coding-guidelines.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# GraphQL Java Coding guidelines used in GraphQL Java
2+
3+
4+
## General principles
5+
6+
- We prefer closer to zero dependencies. Dont bring in guava, apache-commons, spring-xxx, y or z however much some StringUtils method might be useful. Less dependencies makes graphql-java more applicable to everyone
7+
8+
- We prefer staying out of the HTTP stack. We are the low level engine of running graphql queries. Other concerns such as JSON and HTTP are handled better by other layers
9+
10+
- We prefer simple code to clever code. It should be readable with well named methods. Clever nested streams and lambdas are not our thing.
11+
12+
- We prefer general to specific. So the code should be generally applicable to use cases, not highly specific to just some use cases, even if it takes more setup.
13+
14+
15+
## more specific topics
16+
17+
- all tests are written in spock
18+
19+
- Optional vs Null: TBD how to move forward
20+
21+
- Non static methods/classes: the default are non static methods. Static class are fine for "small" methods (often inside util classes like `GraphQLTypeUtil`). The rule of thumb is: if you **never** want to mock it out, it is fine to be a static method call.
22+
23+
- Use @Public and @Internal to communicate what level of stability is supported.
24+
25+
- Never make a class or method package protected or protected: make it public or private and use @Internal to communicate that the class can be changed without notice. The user can decide itself about the risk when they use internal things.

0 commit comments

Comments
 (0)