« Back to Index

Best Practice Code Design and Architecture

View original Gist on GitHub

1. Definitions and Expectations.md

What do we want to achieve?

We want two documents:

  1. To inform developers on how they should behave and conduct themselves within a professional organisation
  2. To inform developers on what is considered to be good code design/architectural choices

We want developers to use these documents as a reference and to uphold the values they instill.

For the code quality, that doesn’t mean we are gate-keepers trying to ‘enforce’ these as hardened rules. These should be seen as guidelines and best practice recommendations.

For the document to define how developers behave, see further below for my thoughts on that (i.e. the section “What level of authority does it carry?”)

What is a “community driven model”?

Simply: developers can open a “pull request” on either document and from that start a discussion around the change they wish to make.

We would want to document a template for when opening a PR (so we ensure both consistency, as well as a well thought out proposal). What goes into that template will need to be discussed and agreed upon by tech leads/architects.

What is a “code of conduct”/“statement of values”?

As mentioned in the section “What do we want to achieve?”…

To inform developers on how they should behave and conduct themselves within a professional organisation

What is a “code quality document”?

As mentioned in the section “What do we want to achieve?”…

To inform developers on what is considered to be good code design/architectural choices

What level of authority does it carry?

Authority depends on the document being discussed…

Code Quality

Authority could mean two things here:

  1. Trust
  2. Enforcement

For the ‘trust’, this should come from the collective agreement between tech leads and architects that the items listed are good and should be adhered to wherever possible.

For the ‘enforcement’, we can’t realistically enforce teams to follow these concepts. Nor can we expect a tech lead to have their eye over every piece of code that gets committed to master; so we can’t expect to enforce this on even a ‘team by team’ basis.

The best we can hope for, or at least work hard towards, is a pro-active engineering culture where we all think and do the best we can on the project/code we’re working on/with. So following these guidelines then becomes a healthy/positive experience.

Values

The values should be enforced by the BBC and the engineering manager or someone like Robin Pembrooke (Head of News).

We should take these values seriously and every member of every team should be able to recognise when they’re being violated and take responsibility for members of our own teams. Yes this is a big ask for some people, but you can’t have one person (e.g. a tech lead) trying to handle this by themselves; least of all because they won’t be around all the time to see it happening.

How is it written?

It should be written by tech leads and architects, with contributions from the developers.

Any amendments or new additions should be discussed and at least collectively agreed upon by the tech leads/architects. But at least this will be an open discussion that developers can be involved with and feel they’re able to impact upon the outcome.

When is it used?

As mentioned in the section “What do we want to achieve?”…

We want developers to use these documents as a reference and to uphold the values they instill

The more both documents are viewed and looked at, the more common place their values will become and the need to reference them becomes less (that’s the dreamy ideal at least).

2. Best Practice Code Design and Architecture.md

Types

There are a few different types of programming languages and each has their own idioms and best practices. It would be appropriate to first identify what these types are so you can recognise roughly where your language sits.

Before we get started…

None of the following are concrete recommendations. Just ideas, things for you and your team to consider.

General comments

Code Design Best Practices

Some of these will be cliches and others painfully obvious, but such is life

Aim to…

Architecture Best Practices

Aim to…