-1

I will describe two development and code review processes, both describing the upsides and downsides to each version. Ideally we want to have a process that has no downsides and as much upsides as possible:

We have two environments, the acceptance environment (main branch) for the customer to access and check whether the features they requested are correctly implemented, and the development environment (development branch), which is an internal environment for developers to merge all their finished code to, to test it as a whole both as a developer as well as the product owner.


Process 1: The developer creates a feature branch from the development branch and implements their code and writes unit tests for it. Once they deem the feature complete, they merge it to the development branch and create a merge request from their feature branch to the main branch. This merge request is reviewed by a second developer and once the review is complete and they have merged the feature branch into the main branch, they archive the branch and merge the main branch into the development branch.

Upsides:

  • A review is small and only contains changes required for that feature
  • If fix comments are required to be resolved, nothing else is blocked and it will only be merged into the main branch if everything is complete and deemed correct.

Downsides:

  • The development environment never fully mirrors the acceptance environment as there could be features on the main branch separately when they were only tested on the development environment with other feature branches included.
  • The requirement for reviews per feature requires developers to switch focus more often during a working day, switching from developing to reviewing possibly multiple times a day.

Process 2: The developer creates a feature branch from the development branch and implements their code and writes unit tests for it. Once they deem the feature complete, they merge it to the development branch and archive their feature branch. They then create a merge request from the development branch to the main branch if it does not already exist. Once a week a developer reviews the merge request from development to main with all the features that were completed that week.

Upsides:

  • The development environment always perfectly mirrors the main environment after a review, meaning that the acceptance environment never has unexpected behaviour.
  • The review is done once a week, allowing it to be planned and developers are not constantly switching focus.
  • Not requiring developers to review allows for more speedy development as a whole.

Downsides:

  • The review once a week has a lot of code and takes a lot of time and focus, sometimes up to half a day.
  • When features are not implemented correctly, faulty code is still pushed to the main branch to not bloat the gigantic merge request further and never having perfect code while also having everything reviewed.
  • Developers lose individual feedback on their code as it is all done in one go.
  • Tasks sometimes will remain in review for a long time as developers fix their fix comments in new feature tasks that sometimes are large and take a while to complete.

What would be an ideal solution without the requirement of a third environment, keeping the server infrastructure as is. I know there probably isn't a perfect ideal solution, but there must be something better than these two.

3
  • process 1 is flawed and shouldnt be used Commented May 28, 2024 at 9:44
  • process 2 is also flawed and shouldnt be used Commented May 28, 2024 at 9:45
  • 2
    @Ewan Thank you for your wonderful insights, feel free to also provide a non-flawed alternative Commented May 28, 2024 at 9:47

3 Answers 3

3

Isn't the "main branch" usually called the trunk? A "branch" is inherently something off to the side of whatever is the "main" thing in the context in question.

I've struggled to understand whether what you are describing is a 3-line setup with a trunk, an acceptance branch, and a development branch, or whether you are describing a 2-line setup with a trunk and a development branch.

That said, you seem to have identified the problems with each of the two approaches you describe. Effectively, you cast it as a choice between features always being reviewed individually and drip-fed to acceptance, and features always being reviewed and fed to acceptance as a block.

There isn't really much latitude between these approaches except to pick your poison.

I think a third way is to think intelligently about whether features interact or not, and either consolidate these as a unit of work handled by one person (so that the drip-feed approach still works), or decide which features developed separately occasionally might interact and have to be treated as a block (so that you deviate from drip-feeding sometimes).

It's worth saying though that when you have a multi-person team doing tests and assurance and code reviews and all the overheads of team communication and dealing with acceptance feedback from colleagues or clients, a day or even a week for a full unit of change doesn't add up to much actual substance of change.

I'd be more concerned about interactions between features that are committed months apart - for example, where one developer proceeds from an outdated understanding of workings that another developer has since changed - rather than interactions between contemporary features. Because the separation of time makes it less likely anyone will identify that the interaction exists, or will be looking at the areas where an adverse interaction would reveal.

Anyway, if something does slip through the cracks of your current process, then when you just sweep the ceremony aside and buckle down to either fix it, or to reverse the application to the last stable configuration, then it often doesn't take much time or effort.

It must be remembered that the purpose of various assurance activities is not to achieve perfection, but to ensure that the consequences and likelihood of design mistakes are limited to acceptable levels. A tetanus shot for a nail through the shoe, or a plaster for a paper cut, rather than cleaning up the fallout of a dirty bomb.

That orientation should be borne in mind.

It should also be remembered that ceremonies and checks consume valuable time and attention, and typically compete for cognitive resources against more essential activities like correct coding and intelligent risk-analysis of changes. Changes in processes, once embedded, also upset rhythms and habituation, and can lead to a spike in errors as more subtle thoughts are displaced by the attention needed to cope with the upheavals.

When considering a change to your existing process, you should think about whether you've identified a serious problem with a straightforward solution, or whether you're fussing at the margins and should relax into a system that is already reasonably well-able to cope.

1
  • 1
    Your assumption is correct in that a 2-line setup was used. Indeed the acceptance branch in my case is the trunk, aka main. Also, a thought came to my mind that possibly a separate branch for a single epic could prove fruitful, as different epics within a project usually (with exceptions), dont/won't or shoudln't touch. Then doing a review of an entire epic possibly with the team that worked on it could be an option, or instead an outsider such as a tech lead/senior on this project. Commented May 28, 2024 at 15:12
1

GitFlow is a widely used solultion to these type of branching problems and often the answer to them is "just use gitflow". However.

Process 1 : Here you have a flaw in that you are merging your feature branch into two parents, one of which is a child of the other. This will cause merge conflicts when you attempt to merge dev into main as you point out.

Process 2 : This looks better until you realise you are using main as your acceptance branch. What happens when the customer doesn't like it?

My suggestion is an abbreviated gitflow

  • devs work on feature branches, test locally and merge (with review) into dev

  • dev branch is auto deployed to dev env on build

  • Each week/sprint you ensure any bugs on dev are fixed, you create a ReleaseX branch from dev and deploy it to your acceptance test env for testing with the clients

  • Bugs from acceptance testing are fixed on the release branch and dev branch separately with feature branches and reviews. Or, you might choose to abandon a release branch and just make a new one from the latest dev

  • When the release branch is approved it is merged into main and deployed to Live.

Pros:

  • Each feature merge has its own review
  • dev branch contains all features for internal testing
  • acceptance env is stable, doesn't have the latest dev commits
  • main always contains fully tested and accepted code.

Cons:

  • The release branches are a bit floaty, you create and discard them
  • when you fix a bug in a release branch you also have to remember to fix the same bug in dev. This isn't automated.
  • when you have changes in a release branch they may cause merge conflicts which you will need to resolve by merging either the release or the main branch back up to dev.
0

Process 2 sounds better. I don't think review is needed for merging dev to main. At some point you should decide "dev is now stable" and then PR is just formality.

If anything bad happens on the acceptance environment, then this means that the testing process on the dev environment needs refinement. Not only "it passed unit tests", but also integration tests and finally some manual testing.

The divergence of two environments in the process 1 is a deal breaker for me. This is extremely important. I've worked with such setup, and I constantly had to do twice as much work to maintain both environments. The horror.

2
  • The issue is that a review is appreciated by our junior developers to allow them to learn whether their implementation is not only working but also efficient and what not. Not having the review from dev to main means that there is no code review whatsoever. Having a code review from the features branch to the dev branch means that there no longer is a branch where they can test a full integration of the system which is not running locally but rather on a node/server etc. Commented May 28, 2024 at 8:25
  • @GSerum_ I don't get it. You have dev environment, right? Test there. And perform review of a feature branch. Commented May 28, 2024 at 9:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.