Brownfield and Greenfield in software development

Software development is a complex project, especially if we work with something more complicated than just a simple CRUD application. If we want to cover a lot of business needs, we will have more and more requirements, new dilemmas, new use-cases and also a lot of things to monitor and check. Today I want to write about two project types: Greenfield and Brownfield. The fun fact is that nomenclature is from architectural business… and I work with software for architectural business, with AECO (Architecture, Engineering, Construction and Operation). Want to check? Visit Ingenious.BUILD on LinkedIn, we are hiring now. 

Ok, so what are the differences between them? Brownfield investment is an approach when we want to build something using existing terrains, existing buildings. We will have some existing problems to resolve, contaminations to remove or we will be removed by some law requirements related to the area we are interested in. Just imagine old buildings, maybe something like an abandoned former factory, big terrain you want to change to a new residential area. The Greenfield project is on the other hand something fresh. You have clean terrain and you can start everything from scratch, without checking anything from the past, no top-down restrictions, no complicated law processes.

The thing is similar in software development and software architecture, but with some important differences. According to what I wrote before, you can think that the greenfield project is always a better opportunity, and always gives us a better start. It is not true in the software world. Brownfield is like work with existing legacy code – and who does really like legacy, especially complicated legacy solutions? In this situation we have to rethink a lot of already existing parts of the system, we have to refactor some of them or just put them into the trash and write something again. It may be boring and it may be confusing for a lot of developers. The thing changes when we are at the point of contact between our code and our business requirements. Why?

The answer is simple: a brownfield project means we already have a lot of information. Yep, maybe we will need to adjust something, maybe remove or add something, but we already have a starting point, we already meet some business requirements and we can use that knowledge to improve our application. Just imagine building something like an Uber system from scratch and with something existing: there is a very very small chance that legacy code is completely useless: you can use it to determine requirements, check them and adjust. It’s even possible you will still use some of the parts, because they are good enough and will not require immediate refactoring. Also, if we already have some legacy solutions, we can easily add new members to our team, because we know what stack we use. It may not be super important at the start, but if we want to scale up, it will be more and more crucial for faster onboarding and verifying. Product part of our organization also has less to do, because we can reuse existing solutions. 

On the greenfield project the situation is only seemingly simpler. Of course we can start from scratch, but in most cases, we will have many more questions than answers: what are our real requirements? What business problems do we want to solve? What stack should we use for that? If everything is clear, we have all the information, then yep, it will be a piece of cake. But it’s a utopian assumption: we will not have all the information and business will verify our plans after first usage. That is why quick implementation – even if our application is not perfect, not ready for all cases – is so important: we will have feedback and it will be possible to make all required adjustments. And guess what… your greenfield project becomes a brownfield project then – you will avoid it only in very simple cases. 

Architecture Decision Record (ADR)

During software developing we often have some questions, especially when we join existing projects: why app uses that language? Why these solutions? Why we handle time or money values in such way? All these questions are very important, because it is a part of application architecture. Of course we can on team knowledge, but such method is not efficient and not possible to maintain on larger projects and when we want to scale up: new people will join, but some people will also leave project. Important knowledge distributed partially to different people will be hard to get. The solution is ADR: Architecture Decision Record.

Architecture Decision Record is just a document with information about why and when team decided to use some solutions. It can describe additional context and consequences of adopting the decision. In effect, we have one, central place with all required knowledge, with history and detailed descriptions. It helps during onboarding new people, because they can check ADRs quickly. It helps if we lost some project members, because we will not lost important knowledge. It also helps if we make changes on some modules ownership, introduce internal structure changes, because we still everything important in one place. Finally, it allows us to such documents in code, explain why we make adjustments – everything is clear then.

When should we create ADR?

As soon as possible. It is long-term solution – we will not see positive effect immediately, but after some time, it will help us. More detailed question: should we create it only for bigger things, or also smaller? It is flexible. We definitely should describe bigger decisions, in smaller it depends how they will impact our application. We can start to write ADR when we have a problem, even if we do not have any solution for that problem: it allows us to aggregate potential options, then discuss and finally decide and approve the best approach. In such case, we will have clear history what prompted us to make this decision.

ADR example

There are many different patterns of creating ADR and there is no right answer for question “which one should I use”. It depends on your needs, application structure,

NUMBER – ADR NAME

Status

(…)

Date

(…)

Context

(…)

Decision

(…)

Consequences

(…)

And real example:

1. Use standard HTTP response codes

Status

Approved

Date

26/02/2022

Context

There are many possible options to send responses – even if action will fail (for example we cant find model), it is still possible to send completely different response code (example: 200 OK). We should avoid that and make all responses clear, predictable and easy to interpret: we can use our rules, or follow global HTTP recommendations.

Decision

We decided that we will always use only valid, recommended HTTP response codes, for example 403 if access is forbidden, 404 if we will not able to find model etc.

Consequences

– All new endpoints will return only valid codes

– We will not accept custom or invalid response codes on code reviews and merge requests

– Legacy endpoints will be updated during required refactors

Where should we store ADRs?

Similar to how should ADR look like, there is no simple answer, but there is the same rule: you should define one place and use it for all ADRs. You can store them on repository and make close to code, you can use shareable notes, cloud with just txt files or anything else. The important part here is: you should backup your ADRs (or service you will use should offer that) and also, it should be possible to share ADRs for read-only. It’s required if you want to link to them in code comments, tasks descriptions or other architecture considerations.

The best investment you can make

Right now we live in somewhat difficult times: there is still a pandemic, some restrictions, rising prices and inflation. A lot of challenges, but of course also a lot of opportunities. It is normal that many people think about how to invest, to save their money, families, work etc. Some of them buy and rent houses or offices, some buy gold or silver, some invest in stock exchanges, some trying their chances on Forex (and according to research, 95% of them are bankrupt after just two months), some also trying cryptocurrencies, NFT and similar things based on new technologies. 

Each of them has a risk level: higher or level, but there is risk. Of course, we can say that investing in government bonds is a safe method, but with current inflation levels, it cannot even prevent loss. What if there is always a good method to invest? What if that method does not require a big capital, a lot of money, but in most cases provides a huge rate of return? Yep, there is such a method, and it’s very simple.

It is investing in yourself

Just that, and so much. It’s super simple, but I think some people do not or do not want to understand that. I know some people who have quite nice work and positions, and they try investing in very risky things. It is ok, it is their money and I can not decide here. But… simple observation: they often need a lot of time to track some stock changes. Sometimes they win, sometimes lose, I think it is similar to playing the lottery. I win the lottery every day. How? I do not play, so I can save that money for something different. Coming back to mentioned people – imagine they will spend just 10% of time they require to observe stock to learn new things. Just 10%, no more! I am 100% sure that after a year, their base salary will be higher. What if they decide to spend 50% of their time? No, it is not only a dream from movies, some stupidity bizarre from pep talks. It is just a simple rule. 

Remember, if you learn something new, it will be your skill till your death. No one can take it from you. That new skill may increase your chances in the labor market: because of new abilities, you will have higher chances during applying for a higher position with better salary. Even if you will not be successful, that new skill may help you in the future, or in your personal life. Nobody knows what we will do in the next ten years, so… Treat that always like the best investment you can make. In most cases, it will not require any additional money – if you can read this blog post, you have internet access and phone, tablet or computer. With such a connection, you have access to the biggest knowledge database in the human world. And what is also interesting, a lot of people share their knowledge, without any fees. So, just read, learn, then try new things to “learn truly”. 

This rule works not only for money, but also for a lot of different things. We can do what we like to do, or we liked to do in the past: sometimes I want to play old games that I loved 10-15 years ago. It is fine, but just in the first 5 minutes. After them, I feel it is nonsense, because “I already did it”. I do not regret these hours I played in the past – maybe that time was required, I also liked that, and it was fine. But right now… it is not exciting anymore. I want to gain new knowledge, new skills, new abilities, or even… something new just for relaxation. Watching the same movie two or more times is nothing interesting for me, but watching something new, especially science fiction, why not? Reading the same book a few times… it depends. If we talk about belles-lettres, no way. If it is something that I can use to improve myself, yeah, I definitely often go back to intriguing books. 

Perhaps I do not take a lot of risk, potentially someone will tell, that I am just a coward, but I do not care about that. I do not believe when someone tells me: “just invest in that, the rate of return is amazing 200%!!!”. Sorry, no way. I think even slower, but continuous growth and progress is much better. I remember I was shocked when the pandemic started. I panicked and bought a lot of EUR and USD because the Polish Zloty was so weak. It was my fault, and a good lesson: when I decided to expand my knowledge about investing, financial instruments. Bought a lot of books, built a diversified portfolio and right now I am much calmer: I do not know what will happen, but it should be fine in many situations. I do not have to track a lot of sessions, results it is not my goal. I know that I need to be up-to-date, but not with everything, it should not be too time demanding.

And it’s just one example, probably very common. 
Think about that – how much effort and money can you save though investing in yourself?

From sport to self confidence

If you know me personally you probably will not agree when someone will tell you, I was shy, very shy. Yep, it’s true. Few years ago I was a young man, introverted and shy. To be clear: I was and I am still an introvert: it is a part of our nature, we can align some things, but personality type is not the same as character. During our life, our decisions, we can change our character, but not personality. I still do not like crowds, a lot of noise, loud parties, but there is one big difference between me now and me a few years ago: I believe in myself, I trust myself. Because of that, other people see me differently and can not believe I was shy. 

Again, if you know me, you know I like sports and I do a few workouts every week. Have pretty interesting habit for almost two months: I run a half-marathon every weekend. It used to be different a few years ago. I really… hated sports. It is true, really. Hard to say, what was the reason for that, but maybe bad experiences from school time? I remember the most popular activity was football and I was never interested in football… or basketball, or volleyball. First, I was not good at any manual things that require precision. Second, I did not feel good in teams in school: with a lot of people playing for themselves, not for the team – they could always complain about others, but they did not motivate others. Because of that and a few other aspects, I was shy and I did not like sports. In effect, at 23 (and even earlier), I was obese, I was really big man.

Then, things started to change. There was not a very successful episode in my life that I am laughing at now: first fascination, I got an elbow and was depressed for about half a year. It was a hard time, but then I changed my mind: decided I would never get down on my knees again, and also started weight training. First by just push-ups, crunches and squats, then using an exercise bench in my home. It was nice, very nice and I felt better and better every week. When spring came, I started cycling my old bike – just a few kilometres, to get to know my local area. I changed that old bike quickly to a new one, a trekking bike and cycled farther and farther. It was the beginning of my adventure with bikes.

Last year I made my “final fantasy”: cycled from my home to Baltic Sea in just one day, it was about 400 km. Did it with my friend, another local cyclist. Of course right now I have a different bike, different knowledge, physical level, but it is a clue: it was a process, step by step I builded different person, a different me. During that, I gained a lot of confidence. There was a period when I wanted to start each race: two MTB races in one month, next month road race and mix using cross bike, next be a part of a triathlon team (of course on bike). Did I want to prove something to myself? Maybe, I am not sure right now. Right now it is different: I do not race, do not have plans for that, just want to have a lot of fun… and make the transition from cycling to running, because after the first, completely unplanned marathon distance, I feel I found the next milestone in my life. 

Of course during these few years, I did a lot of things not related to any sports: getting a sweetheart, working in a startup, learning new things, trying new things, all of them are great challenges but I think sport was the basic, the fundamental of all changes. It allowed me to think better about myself, to trust myself. Right now I do not have to prove anything in races: I know I can, so it is just my choice. In most cases, I will not be interested, in some cases, I will do it on my terms: right now I want to do an ultra run, but not on an official competition, just for fun. And it is amazing, it works in different areas of life: you do not have to, you just want. It can also be funny, then in the gym (I do not look strong), someone starts a conversation, we talk about sports, I mention cycling and there is a question for me: “did you ever cycled 100 km?”. I can only smile and answer: yeah… it was fine, but it was only the beginning. 

Right now sport is part of my life and I know, it will be as long as it will be possible. It is a habit, it is passion, sometimes it is a positive addiction. I believe, without sport I would not be where I am – and I am very content and happy now. Can not recommend strict sports, competitions, a lot of austerities, keep pushing forward anyway – no, all these things are not important. Important is consistency and something like discipline. Even walking can help us a lot: it is a great time to refresh our minds, meditate, and rethink important questions. If our activities become passion, it is fine, we will change our life. 

Reduce WSL and Docker disks size

I really like WSL/WSL2 in Windows – it provides a lot of features with minimal performance impact (WSL2) and I can still use Windows app. In combination with Docker, it can handle a lot of things and it’s much better for me than for example MacOS. One problem I discovered last time is space consumed by WSL, and also Docker volumes. In both cases, Windows uses Virtual Hard Disk (VHD) format, vhdx files to store all data.

The problem is Windows can extend virtual disks on demand, without asking about that, but doesn’t reclaim free space if we make bigger changes inside WSL filesystem or Docker volumes. I had few IDE versions and different instances, each about 1,5 – 2 GB, and it consumed a lot of space. After deletion them from WSL filesystem, I didn’t get any real free space on my computer disk. We have to manually compact virtual hard disks to do that. How to do this? It’s quite simple. First, we have to enable Hyper-V if it’s not enabled. Just run terminal or PowerShell with admin privileges and execute this command:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

System restart may be required after that.

Second step is to compact disks. First, close Docker Desktop if it’s running and also shut down WSL by command:

wsl --shutdown

Right now we can compact disks, command is also very simple:

Optimize-VHD -Path "path_to_disk.vhdx" -Mode Full  

The question is, where can we find these disks?

You can find disks created by Docker in:

SYSTEM_DRIVE\Users\your_username\Local\Docker\wsl // and then directories inside

Second thing is related to your WSL distro – all should be in the same main directory, but with different subdirectory. I use Ubuntu, from Canonical and in that case, data is located on:

SYSTEM_DRIVE\Users\your_username\Local\Packages\CanonicalGroupLimited(...)\LocalState\ext4.vhdx

Of course you can use search or tools like Everything to locale any *.vhdx file easily.

After execute command, file should become smaller and you will have more free space.