---
title: Blog - Trusted Team Extension Partner For Europe & USA (9)
description: Empower your business with our expert team augmentation services. Scale efficiently and stay ahead in the ever-evolving tech landscape. (9)
---

[Skip to content](https://www.craftsmensoftware.com/blog/page/9#main)

\[ CLIENT STORY \]

CLOSE ✕

[![Craftsmen](https://crafty-astro-2-0.skarif2.workers.dev/_astro/logo.CZgI5u57_1oRGAt.webp)![Craftsmen](https://crafty-astro-2-0.skarif2.workers.dev/_astro/logo-dark.B-8biif6_paamB.webp)](https://www.craftsmensoftware.com)

[About us↗](https://www.craftsmensoftware.com/about-us)[Client Stories↗](https://www.craftsmensoftware.com/client-success-stories)[Case Study↗](https://www.craftsmensoftware.com/case-study)[How We Work↗](https://www.craftsmensoftware.com/how-we-work)[Blog↗](https://www.craftsmensoftware.com/blog)[Career↗](https://careers.craftsmensoftware.com/)

[![](https://www.craftsmensoftware.com/hubfs/norway.svg)NO](https://www.craftsmensoftware.com/no/)

[Get In Touch↗](https://www.craftsmensoftware.com/contact-us)MENU

[About us↗](https://www.craftsmensoftware.com/about-us)[Client Stories↗](https://www.craftsmensoftware.com/client-success-stories)[Case Study↗](https://www.craftsmensoftware.com/case-study)[How We Work↗](https://www.craftsmensoftware.com/how-we-work)[Blog↗](https://www.craftsmensoftware.com/blog)[Career↗](https://careers.craftsmensoftware.com/)

[![](https://www.craftsmensoftware.com/hubfs/norway.svg)NORSK](https://www.craftsmensoftware.com/no/)

[Get In Touch↗](https://www.craftsmensoftware.com/contact-us)

# Insights on Software, Teams*and Technology Growth*

Explore practical perspectives on software delivery, team collaboration, and technology partnerships that help growing businesses make better decisions and build with confidence.

[Discuss Your Needs](https://www.craftsmensoftware.com/contact-us)

![Craftsmen engineers and international partners on stage at Tech for Good in Bergen](https://www.craftsmensoftware.com/hs-fs/hubfs/Software%20Team%20Norway%2c%20UK%2c%20USA%2c%20Sweden.jpg?width=2000&name=Software%20Team%20Norway%2c%20UK%2c%20USA%2c%20Sweden.jpg)

Search articles

[All](https://www.craftsmensoftware.com/blog#articles) [Blog](https://www.craftsmensoftware.com/blog/tag/blog#articles)[AWS](https://www.craftsmensoftware.com/blog/tag/aws#articles)[Tech](https://www.craftsmensoftware.com/blog/tag/tech#articles)[Python](https://www.craftsmensoftware.com/blog/tag/python#articles)[Tips and hacks](https://www.craftsmensoftware.com/blog/tag/tips-and-hacks#articles)[lambda](https://www.craftsmensoftware.com/blog/tag/lambda#articles)[Software Team Augmentation](https://www.craftsmensoftware.com/blog/tag/software-team-augmentation#articles)[DynamoDB](https://www.craftsmensoftware.com/blog/tag/dynamodb#articles)[Team Augmentation](https://www.craftsmensoftware.com/blog/tag/team-augmentation#articles)[AI](https://www.craftsmensoftware.com/blog/tag/ai#articles)[Nodejs](https://www.craftsmensoftware.com/blog/tag/nodejs#articles)[serverless](https://www.craftsmensoftware.com/blog/tag/serverless#articles)[React](https://www.craftsmensoftware.com/blog/tag/react#articles)[Flask](https://www.craftsmensoftware.com/blog/tag/flask#articles)[GraphQL](https://www.craftsmensoftware.com/blog/tag/graphql#articles)[FFmpeg](https://www.craftsmensoftware.com/blog/tag/ffmpeg#articles)[Git](https://www.craftsmensoftware.com/blog/tag/git#articles)[GoLang](https://www.craftsmensoftware.com/blog/tag/golang#articles)[SQL](https://www.craftsmensoftware.com/blog/tag/sql#articles)[Transcription](https://www.craftsmensoftware.com/blog/tag/transcription#articles)[Vite](https://www.craftsmensoftware.com/blog/tag/vite#articles)

Newest firstPage 9 of 11

[![](https://www.craftsmensoftware.com/hubfs/Imported_Blog_Media/Working-With-The-Distributed-Team.webp)](https://www.craftsmensoftware.com/blog/working-with-the-distributed-team)

### [Working with the distributed team](https://www.craftsmensoftware.com/blog/working-with-the-distributed-team)

Working with the distributed team has now become a normal working process for many reasons. People are adapting it day by day and the corona pandemic act as a booster for this adaptation. The transformation was not easy for everyone. Many people lose their job only because they failed to adapt to new work cultures and processes. This adaption not only affect employee it’s also affected many organizations because of good management and working environment setup with correct technology adaption. This story is not about the effect of a distributed team, this story contained some tips and process which has adopted by many organizations. Before going further I separated this story in small pieces to point out the exact topic for further reading. Here are the pieces Misconception About Distributed Team Tips For Employee Organizational Roles and responsibility in Distributed Tea Misconception About Distributed Team Many misconceptions and myths are there about the distributed working process. The first step to create or adopt a productive and efficient team, those myths and misconceptions about the remote working processes should dispel. Here are some of them with small explanation against it Distributed Team are not productive It’s been a very common conception for many businesses and organizations that a remote team is not productive. But it is also proven wrong on every decade that a new working environment or even new technology sometimes makes people afraid of it. Some 15 years before we can’t think the Internet as a necessary thing in life and now its became oxygen for all of us. The remote team will not be productive without supervision and on-site management this misconception now is proven wrong with a help of new technology like Slack (most popular), Status Hero, Zoom, Skype, etc. Teamwork and productivity can be monitored very efficiently with that new treading technology Remote employees are not skilled or scope of it less : Another misconception is that most skilled persons will be available only informal office, while distributed workers are those that simply could not qualify for the leading positions. Having a distributed team can increase the scope of having skilled people from all over the world regardless of geographical restrictions. Skill development and training becoming very popular. Most of the people now depended on online for training and learning.so team-wise development became so easy with the help of Coursera, EDX, Udemy, Udacity like platform. Communication and Management are difficult with Remote Workers: A common issue with a distributed team is a lack of communication and management across distances and time zones. Common question like “How do I know what my team member is doing, and what progress is being made?” There might be some people who are not skilled in self-management, but it can happen in formal office life too. But here we are talking about a working environment where everything fully depends on technology.there are many advanced apps and tools available that can overcome this potential problem. organization wise best practices like the working model and status wise work tracking can be helpful for a distributed working environment. 2. Tips For Employee Most of the organization now moved the Distributed working environment in this corona pandemic suddenly. Most of the employee were not skilled and ready enough to fit in this working environment, so many people failed to keep up their best performance, in the worst case, they lose their job this adaption does not stick to employee or organization it’s an overall process. Here are some tips that might help to fit in this new working environment quickly Always prepare yourself : Don’t think you can hide and only your work will talk for you. Presentation and how you talk to your team it’s very much important always in the office. And it’s now more important in the virtual working environment. Expressing your emotion and thought is very difficult in a virtual environment. So try to open your webcam so that you can express your emotion and thought as much you can, so prepare your self if you feel shy. Make sure you are caring about your dress up as you cared earlier like, in an office environment, it will make you confident in all meetings. Take a break and Chit chat : In-office environment the fun part of it mostly the chit-chat with your teammate and college. But when you started to work in a distributed team you going to feel it’s always a private window and you can relax anytime but in the life scenario is different.you will be always busy with your work and no one will there for you to force you for a cup of coffee and talk about climate. Try to take a break at least every two-hour, and make a plan for virtual coffee with your teammates.even many apps are there which might help you in this like virtual coffee in slack. Ensure your Privacy : In a Distributed working environment mostly you will be working from home or in group-wise, maintaining privacy for yourself is very difficult in this. You might not always prepare for what can happen with your home environment.so using a webcam protector and background filter helps you in this. Many tools like Chromacam, Personify, etc can help you in this. Ensuring disk protection is also important when your system might be used by other Beware of malware and ransomware, so that you can save yourself from many threats that might happen in a virtual environment. Always careful with email and other messenger spam and link. Plan your day and synchronization with the team : Try to plan your day you can use the app or other tools which can save you lots of time tools like Microsoft TO DO, slack TO DO, Evernotes, etc can you useful option on every step of your work try to synchronize with your team so that work in progress can visible to everyone 3. Organizational Roles and responsibility in a Distributed Team The role of the organization is as equal as an employee in this environment. Whatever the working environment we transform well planing and management can solve the hardest problem. Training up your employee : Training is very important in this working process to bring the best of the employee and keep consistent performance. Online training is very much available in all platform today Most of the employees either not ready for the distributed team or just pretend so better to give all equal opportunities for this. Working Hour management : In the distributed team, employees mostly working from home or even form a group but both of the case time flexibility brings the best out of it. But over flexibility on timing can cut team synchronization. It will be very helpful if the meeting can divide by topic trough out the day so that if someone lacks behind than can catch up on the next meeting. Provide team required technological support : Technology is the main key in this environment. Selecting the correct technology is very essential. The technology uses training support required in this case. Providing software license and internet data plan will productive for organization and employee Virtual event : A common problem for the distributed team, people forgot to talk. They only talk about their work and this can cause serious mental and health issues. To overcome this kind of thing, an online event is a very good option. Comedy night, online meet up or even pub night can adopt in a remote environment. Conclusion Covering all the aspect and the topic are not possible in this short story but thinking about improvement is one step forwarder than stay standing backward. Changing in working environment was never easy in any decades and whom doesn’t adopt the changes eventually they disappear from history.

**Satej Sarker**10 Mar 2023 Read →

[![](https://www.craftsmensoftware.com/hubfs/Imported_Blog_Media/Gilded-Rose-Kata_Ubuntu.png)](https://www.craftsmensoftware.com/blog/refactoring-and-unit-test-demystifying-gilded-rose)

### [Refactoring and Unit Test – Demystifying Gilded Rose](https://www.craftsmensoftware.com/blog/refactoring-and-unit-test-demystifying-gilded-rose)

Demystifying Gilded Rose is a very popular refactoring exercise that is intended for practicing your test case writing and refactoring skills. It represents the dreaded situation we have to face as software engineers when we have to work on a legacy codebase and add a new feature to it. Soon after implementing the feature, we discover that some part of our system starts to malfunction even though we have not touched it. Refactoring becomes a necessity then. And refactoring without writing unit tests is a pain in the neck because you do not know what side effects you are going to introduce that may eventually make the whole system grind to a halt. What is the story? Gilded Rose sells some finest goods belonging to the following categories: Normal Items Aged Bries Sulfuras Backstage passes You are given the task of implementing a new feature to an existing legacy system so that they can sell a new category of Conjured items. But the system is nothing short of a complete mess of unmaintainable spaghetti code with a bunch of if-else statements. Furthermore, there are no test cases! Please take your time and read the Gilded Rose Requirements Specification here. How to do the refactoring? Before you refactor a codebase, you must make sure: You do not alter the behavior of the system in any way. The system must continue to function the same way it used to function i.e. the correct behaviors must be retained. You do not make any change that forces the consumer code to change as well. When you refactor your codebase, you must make sure: Your code is SOLID-compliant. You can read this beautifully crafted article on SOLID principles- SOLID: The First 5 Principles of Object-Oriented Design Avoid nested conditionals, instead use guard clauses. Avoid comments. Make your code as readable and expressive as possible. Comments only indicate your lack of ability to express your code correctly. Instead document your code. In Python, we use docstrings for code documentation. Docstrings are not separate from the actual code, they are a part of the code itself. Avoid duplicating code. If you find yourself repeating something, better wrap that logic in a helper function and reuse it. Write unit tests, and write them a lot. Aim for high cohesion and low-coupling. Let’s start solving the kata now. The Unit Tests Guess what? You are given a system that does not have test cases and is very tightly coupled. First thing first, let’s write some unit tests for all the categories of items that Gilded Rose will sell. (I am assuming that you have already read the requirement specification of Gilded Rose) There are several libraries in Python for writing unit tests. The most popular ones are being unittest and pytest. In this tutorial, I will be using the built-in unittest library. We want to update the quality of an item multiple times. So it’s better to have a bulk updater. Let’s implement a static method for that. Here is the complete test case suite for the items sold by Gilded Rose. import unittest from gilded\_rose import Gilde Copy class GildedRoseTest(unittest.TestCase): @staticmethod def bulk\_updater(obj: GildedRose, times: int = 1) -\> None: for \_ in range(times): obj.update\_quality() def test\_normal\_item(self) -\> None: item = Item("Mountain Dew", 20, 40) gilded\_rose = GildedRose(\[item\]) gilded\_rose.update\_quality() self.assertEqual("Mountain Dew", item.name) self.assertEqual(item.sell\_in, 19) self.assertEqual(item.quality, 39) GildedRoseTest.bulk\_updater(gilded\_rose, item.sell\_in + 1) # sell by date passed self.assertEqual(item.sell\_in, -1) # Quality degrades twice as fast now self.assertEqual(item.quality, 18) GildedRoseTest.bulk\_updater(gilded\_rose, 10) self.assertEqual(item.quality, 0) # never be less than 0 self.assertEqual(item.sell\_in, -11) def test\_aged\_brie(self) -\> None: item = Item("Aged Brie", 20, 20) gilded\_rose = GildedRose(\[item\]) gilded\_rose.update\_quality() self.assertEqual("Aged Brie", item.name) self.assertEqual(item.sell\_in, 19) self.assertEqual(item.quality, 21) GildedRoseTest.bulk\_updater(gilded\_rose, item.sell\_in + 1) # sell by date passed self.assertEqual(item.sell\_in, -1) # Quality increases twice as fast now self.assertEqual(item.quality, 42) GildedRoseTest.bulk\_updater(gilded\_rose, 10) self.assertEqual(item.quality, 50) # never be more than 50 self.assertEqual(item.sell\_in, -11) def test\_sulfuras(self) -\> None: item = Item("Sulfuras, Hand of Ragnaros", 20, 80) gilded\_rose = GildedRose(\[item\]) gilded\_rose.update\_quality() self.assertEqual("Sulfuras, Hand of Ragnaros", item.name) self.assertNotEqual(item.sell\_in, 19) self.assertEqual(item.sell\_in, 20) # does not change self.assertEqual(item.quality, 80) # never alters GildedRoseTest.bulk\_updater(gilded\_rose, item.sell\_in + 1) # sell by date passed self.assertEqual(item.sell\_in, 20) # still same self.assertNotEqual(item.sell\_in, -1) # it is not equal so passes def test\_backstage\_passes(self) -\> None: item = Item("Backstage passes to a TAFKAL80ETC concert", 20, 20) gilded\_rose = GildedRose(\[item\]) gilded\_rose.update\_quality() self.assertEqual("Backstage passes to a TAFKAL80ETC concert", item.name) self.assertEqual(item.sell\_in, 19) self.assertEqual(item.quality, 21) GildedRoseTest.bulk\_updater(gilded\_rose, 9) # sellin approaches to 10 or less self.assertEqual(item.sell\_in, 10) self.assertEqual(item.quality, 30) GildedRoseTest.bulk\_updater(gilded\_rose) self.assertEqual(item.sell\_in, 9) self.assertEqual(item.quality, 32) # sellin approaches to 5 or less GildedRoseTest.bulk\_updater(gilded\_rose, 4) self.assertEqual(item.sell\_in, 5) self.assertEqual(item.quality, 40) GildedRoseTest.bulk\_updater(gilded\_rose) self.assertEqual(item.sell\_in, 4) self.assertEqual(item.quality, 43) GildedRoseTest.bulk\_updater(gilded\_rose, 2) self.assertEqual(item.sell\_in, 2) self.assertEqual(item.quality, 49) # corner cases: never gets beyond 50 and drops to 0 once sellin passed GildedRoseTest.bulk\_updater(gilded\_rose) self.assertEqual(item.sell\_in, 1) self.assertEqual(item.quality, 50) GildedRoseTest.bulk\_updater(gilded\_rose, 2) self.assertEqual(item.sell\_in, -1) self.assertEqual(item.quality, 0) def test\_conjured(self) -\> None: item = Item("Conjured Mana Cake", 20, 50) gilded\_rose = GildedRose(\[item\]) gilded\_rose.update\_quality() self.assertEqual("Conjured Mana Cake", item.name) self.assertEqual(item.sell\_in, 19) self.assertEqual(item.quality, 48) GildedRoseTest.bulk\_updater(gilded\_rose, item.sell\_in + 1) # sell by date passed -- will decrease twice as fast as normal items (-4) self.assertEqual(item.sell\_in, -1) self.assertEqual(item.quality, 6) GildedRoseTest.bulk\_updater(gilded\_rose) self.assertEqual(item.sell\_in, -2) self.assertEqual(item.quality, 2) GildedRoseTest.bulk\_updater(gilded\_rose) self.assertEqual(item.sell\_in, -3) self.assertEqual(item.quality, 0) # never less than 0 if \_\_name\_\_ == '\_\_main\_\_': unittest.main() class GildedRoseTest(unittest.TestCase): @staticmethod def bulk\_updater(obj: GildedRose, times: int = 1) -\> None: for \_ in range(times): obj.update\_quality() def test\_normal\_item(self) -\> None: item = Item("Mountain Dew", 20, 40) gilded\_rose = GildedRose(\[item\]) gilded\_rose.update\_quality() self.assertEqual("Mountain Dew", item.name) self.assertEqual(item.sell\_in, 19) self.assertEqual(item.quality, 39) GildedRoseTest.bulk\_updater(gilded\_rose, item.sell\_in + 1) # sell by date passed self.assertEqual(item.sell\_in, -1) # Quality degrades twice as fast now self.assertEqual(item.quality, 18) GildedRoseTest.bulk\_updater(gilded\_rose, 10) self.assertEqual(item.quality, 0) # never be less than 0 self.assertEqual(item.sell\_in, -11) def test\_aged\_brie(self) -\> None: item = Item("Aged Brie", 20, 20) gilded\_rose = GildedRose(\[item\]) gilded\_rose.update\_quality() self.assertEqual("Aged Brie", item.name) self.assertEqual(item.sell\_in, 19) self.assertEqual(item.quality, 21) GildedRoseTest.bulk\_updater(gilded\_rose, item.sell\_in + 1) # sell by date passed self.assertEqual(item.sell\_in, -1) # Quality increases twice as fast now self.assertEqual(item.quality, 42) GildedRoseTest.bulk\_updater(gilded\_rose, 10) self.assertEqual(item.quality, 50) # never be more than 50 self.assertEqual(item.sell\_in, -11) def test\_sulfuras(self) -\> None: item = Item("Sulfuras, Hand of Ragnaros", 20, 80) gilded\_rose = GildedRose(\[item\]) gilded\_rose.update\_quality() self.assertEqual("Sulfuras, Hand of Ragnaros", item.name) self.assertNotEqual(item.sell\_in, 19) self.assertEqual(item.sell\_in, 20) # does not change self.assertEqual(item.quality, 80) # never alters GildedRoseTest.bulk\_updater(gilded\_rose, item.sell\_in + 1) # sell by date passed self.assertEqual(item.sell\_in, 20) # still same self.assertNotEqual(item.sell\_in, -1) # it is not equal so passes def test\_backstage\_passes(self) -\> None: item = Item("Backstage passes to a TAFKAL80ETC concert", 20, 20) gilded\_rose = GildedRose(\[item\]) gilded\_rose.update\_quality() self.assertEqual("Backstage passes to a TAFKAL80ETC concert", item.name) self.assertEqual(item.sell\_in, 19) self.assertEqual(item.quality, 21) GildedRoseTest.bulk\_updater(gilded\_rose, 9) # sellin approaches to 10 or less self.assertEqual(item.sell\_in, 10) self.assertEqual(item.quality, 30) GildedRoseTest.bulk\_updater(gilded\_rose) self.assertEqual(item.sell\_in, 9) self.assertEqual(item.quality, 32) # sellin approaches to 5 or less GildedRoseTest.bulk\_updater(gilded\_rose, 4) self.assertEqual(item.sell\_in, 5) self.assertEqual(item.quality, 40) GildedRoseTest.bulk\_updater(gilded\_rose) self.assertEqual(item.sell\_in, 4) self.assertEqual(item.quality, 43) GildedRoseTest.bulk\_updater(gilded\_rose, 2) self.assertEqual(item.sell\_in, 2) self.assertEqual(item.quality, 49) # corner cases: never gets beyond 50 and drops to 0 once sellin passed GildedRoseTest.bulk\_updater(gilded\_rose) self.assertEqual(item.sell\_in, 1) self.assertEqual(item.quality, 50) GildedRoseTest.bulk\_updater(gilded\_rose, 2) self.assertEqual(item.sell\_in, -1) self.assertEqual(item.quality, 0) def test\_conjured(self) -\> None: item = Item("Conjured Mana Cake", 20, 50) gilded\_rose = GildedRose(\[item\]) gilded\_rose.update\_quality() self.assertEqual("Conjured Mana Cake", item.name) self.assertEqual(item.sell\_in, 19) self.assertEqual(item.quality, 48) GildedRoseTest.bulk\_updater(gilded\_rose, item.sell\_in + 1) # sell by date passed -- will decrease twice as fast as normal items (-4) self.assertEqual(item.sell\_in, -1) self.assertEqual(item.quality, 6) GildedRoseTest.bulk\_updater(gilded\_rose) self.assertEqual(item.sell\_in, -2) self.assertEqual(item.quality, 2) GildedRoseTest.bulk\_updater(gilded\_rose) self.assertEqual(item.sell\_in, -3) self.assertEqual(item.quality, 0) # never less than 0 if \_\_name\_\_ == '\_\_main\_\_': unittest.main()   Refactoring the codebase If you look at the current state of Gilded Rose’s codebase, especially the update\_quality method of the GildedRose class, you’ll see how messy it is. You cannot implement a new feature to this codebase without refactoring it first. So, how to refactor this chaos without affecting the behavior of the system? Don’t do this You may be tempted to make the Item class a subclass of ABC – the abstract base class in Python and have a update\_quality abstract method. Any class that inherits from the Item class will require to implement the update\_quality method of their own. from abc import ABC, abstractmethod Copy class Item(ABC): MAX\_QUALITY = 50 MIN\_QUALITY = 0 def \_\_init\_\_(self, name, sell\_in, quality): self.name = name self.sell\_in = sell\_in self.quality = quality def \_\_repr\_\_(self): return f"{self.name}, {self.sell\_in}, {self.quality}" @abstractmethod def update\_quality(self): pass class NormalItem(Item): def update\_quality(self) -\> None: cls = self.\_\_class\_\_ if cls.MIN\_QUALITY \<= self.quality 0 else self.quality - 2 self.quality = max(quality, cls.MIN\_QUALITY) self.sell\_in -= 1 # so on ... ... ... class Item(ABC): MAX\_QUALITY = 50 MIN\_QUALITY = 0 def \_\_init\_\_(self, name, sell\_in, quality): self.name = name self.sell\_in = sell\_in self.quality = quality def \_\_repr\_\_(self): return f"{self.name}, {self.sell\_in}, {self.quality}" @abstractmethod def update\_quality(self): pass class NormalItem(Item): def update\_quality(self) -\> None: cls = self.\_\_class\_\_ if cls.MIN\_QUALITY \<= self.quality 0 else self.quality - 2 self.quality = max(quality, cls.MIN\_QUALITY) self.sell\_in -= 1 # so on ... ... ...   But there is something terribly wrong. Although you have successfully separated items and retained their behavior, you have failed to comply with the stated requirements not to alter the Item class: However, do not alter the Item class or Items property as those belong to the goblin in the corner who will insta-rage and one-shot you as he doesn't believe in shared code ownership (you can make the UpdateQuality method and Items property static if you like, we'll cover for you). You were not given access to the consumer code, which only instantiates objects of type Item, so the system will fail altogether. Do it the right way Let’s implement some free functions and let them update the items. First, refactor the update\_quality method of the GildedRose class. class GildedRose: Copy class GildedRose: def \_\_init\_\_(self, items): self.items = items def update\_quality(self): for item in self.items: if item.name == "Aged Brie": aged\_brie\_updater(item) elif item.name == "Backstage passes to a TAFKAL80ETC concert": backstage\_passes\_updater(item) elif item.name == "Sulfuras, Hand of Ragnaros": continue elif item.name == "Conjured Mana Cake": conjured\_updater(item) else: normal\_item\_updater(item) class GildedRose: def \_\_init\_\_(self, items): self.items = items def update\_quality(self): for item in self.items: if item.name == "Aged Brie": aged\_brie\_updater(item) elif item.name == "Backstage passes to a TAFKAL80ETC concert": backstage\_passes\_updater(item) elif item.name == "Sulfuras, Hand of Ragnaros": continue elif item.name == "Conjured Mana Cake": conjured\_updater(item) else: normal\_item\_updater(item)   This is cleaner compared to what we have started with. We have removed all the nested \`if conditionals. Let’s define constants for MAX and MIN quality. MAX\_QUALITY = 50 MIN\_QUALITY = 0 Normal Item Updater In general, all items have the following properties as specified in the requirement specification: All items have a SellIn value which denotes the number of days we have to sell the item All items have a Quality value which denotes how valuable the item is At the end of each day our system lowers both values for every item But there is a special condition: Once the sell by date has passed, Quality degrades twice as fast Let’s convert all these requirements into code. def normal\_item\_updater(normal\_item: Item): Copy if MIN\_QUALITY \<= normal\_item.quality 0 else normal\_item.quality - 2 normal\_item.quality = max(quality, MIN\_QUALITY) normal\_item.sell\_in -= 1 if MIN\_QUALITY \<= normal\_item.quality 0 else normal\_item.quality - 2 normal\_item.quality = max(quality, MIN\_QUALITY) normal\_item.sell\_in -= 1   Aged Brie Updater There is an interesting fact about the Aged Brie items. “Aged Brie” actually increases in Quality the older it gets Copy def aged\_brie\_updater(aged\_brie: Item): if MIN\_QUALITY \<= aged\_brie.quality 0 else aged\_brie.quality + 2 aged\_brie.quality = min(MAX\_QUALITY, quality) aged\_brie.sell\_in -= 1 def aged\_brie\_updater(aged\_brie: Item): if MIN\_QUALITY \<= aged\_brie.quality 0 else aged\_brie.quality + 2 aged\_brie.quality = min(MAX\_QUALITY, quality) aged\_brie.sell\_in -= 1   Sulfuras Updater If we read the requirement specification, we will see that we don’t even need an updater for the Sulfuras items. “Sulfuras”, being a legendary item, never has to be sold or decreases in Quality Ahh! Good riddance! Backstage Passes Updater This is a little bit tricky to implement. Let’s revisit the special condition of Backstage passes items. “Backstage passes”, like aged brie, increases in Quality as its SellIn value approaches; Quality increases by 2 when there are 10 days or less and by 3 when there are 5 days or less but Quality drops to 0 after the concert Now, let’s convert this into code: Copy def backstage\_passes\_updater(backstage: Item): if MIN\_QUALITY \<= backstage.quality \<= MAX\_QUALITY: if backstage.sell\_in \<= 0: backstage.quality = 0 else: quality = backstage.quality + 3 if 0 \<= backstage.sell\_in \<= 5 else \\ backstage.quality + 2 if 5 \< backstage.sell\_in \<= 10 else backstage.quality + 1 backstage.quality = min(MAX\_QUALITY, quality) backstage.sell\_in -= 1 def backstage\_passes\_updater(backstage: Item): if MIN\_QUALITY \<= backstage.quality \<= MAX\_QUALITY: if backstage.sell\_in \<= 0: backstage.quality = 0 else: quality = backstage.quality + 3 if 0 \<= backstage.sell\_in \<= 5 else \\ backstage.quality + 2 if 5 \< backstage.sell\_in \<= 10 else backstage.quality + 1 backstage.quality = min(MAX\_QUALITY, quality) backstage.sell\_in -= 1 Conjured Updater We are done refactoring the codebase. It’s time to implement a new feature for the Conjured items. “Conjured” items degrade in Quality twice as fast as normal items   Copy def conjured\_updater(conjured: Item): if MIN\_QUALITY \<= conjured.quality 0 else conjured.quality - 4 conjured.quality = max(quality, MIN\_QUALITY) conjured.sell\_in -= 1 def conjured\_updater(conjured: Item): if MIN\_QUALITY \<= conjured.quality 0 else conjured.quality - 4 conjured.quality = max(quality, MIN\_QUALITY) conjured.sell\_in -= 1 Verification We have added unit tests, refactored the legacy codebase and also implemented the new feature. Let’s run the tests to verify if we have been able to retain the behavior of the systems. Hooray! All the five test cases passed!

**Saimon hossain**09 Feb 2023 Read →

[![](https://www.craftsmensoftware.com/hubfs/Imported_Blog_Media/Terra-forming-Medialive-Resources.webp)](https://www.craftsmensoftware.com/blog/terra-forming-medialive-resources)

### [Terra-forming Medialive Resources](https://www.craftsmensoftware.com/blog/terra-forming-medialive-resources)

We’ve all been there. Learning to use terraform, writing beautiful code to manage our cloud infrastructure; it’s all sunshine and rainbows. Until you realize you work with video and need to use Medialive resources. Now sure, you can create these resources from the aws console like a nomad and pass in the arn to make your CD pipeline do what it needs to do but unfortunately we are not nomads. We are engineers and hackers and problem solvers. This article talks about how I had to use terraform to deploy medialive resources and why I started to appreciate terraform even more than I already did. 1,2,3 Solve The problem: Terraform does not support Medialive resources Tools available to us: Terraform uses a state file to remember what it did the last time you ran terraform apply on an s3 bucket (other options are also available) Terraform has local-exec provisioner to run scripts on your behalf Boto3 supports Medialive resources Terraform can trigger specific commands for when it runs create and destroy Terraform can easily use data source to read s3 files The plan: Write python scripts that will use boto3 to create, update and delete medialive resources but also keep track of what it did in an s3 in a parsable format (json/xml) etc. Use terraform’s local-exec to run the python script and specify what it needs to do (This will become clearer when we write the terraform code) We will skip writing python scripts but all it needs to is know when it needs to update a resource (by checking if the resource identifier/user given name is the same and the update action’s input i.e the config is different); when it should create a new resource (by checking if the given s3 bucket contains a file with the given resource identifier) and when to delete (if terraform tells it to delete) Code: Module code Module code Copy So what’s happening here? The following diagram should be able to explain things The first local\_file resource is creating a simple json file from the given EML input config for our python script to be able to parse it (Yes we can also just pass json string directly into the command line) The next null\_resource is where all the magic happens. We have a local-exec provisioner that will be executed when terraform decides that the required action is a “create” action; hence the when = create value. The second local-exec will be triggered when terraform deems that the resource should be “destroyed”. And it “decides” all this from the triggers block where we tell it to depend on the md5 of the data that the user has given us as an input or the name of the bucket that we use to store these states or the resource identifier that we use. Do notice that for “destroy” we are using data from self because remember when this is being executed, things that need to be deleted are not a direct part of your given input, instead it’s a part of the original state that terraform created on its last run. There are some dependes\_on blocks which are pretty self explanatory. We also need a way to receive information about the resource that we just created. Luckily terraform has data\_source to read from s3. Which we are using in the last two blocks to get and parse data into outputs. Voilà, you now have a terraform module that is pluggable, extendable and maintained just like how a regular terraform resource would. You can use any code that you want through this technique. The universe is your limit since you can make the deployments as robust as you want in python/any other language that you like. I hope this was helpful to everyone reading. Keep Terra-forming guys. .

**Sakib Alam**26 Sep 2022 Read →

[![](https://www.craftsmensoftware.com/hubfs/Imported_Blog_Media/AWS_Lambda_on_steroids.webp)](https://www.craftsmensoftware.com/blog/aws-lambda-but-on-steroids)

### [AWS Lambda! But On Steroids](https://www.craftsmensoftware.com/blog/aws-lambda-but-on-steroids)

Do you ever feel like AWS LAMBDA is great but they are just not enough for what you need to do? Maybe you need more horsepower, perhaps a core or two and maybe the TASK you want to do might not be done within 15 minutes? I know what you’re thinking; duh! We have Ec2 for larger tasks and yes but do you not feel that it gets a little tricky maintaining Ec2 sometimes cause you just want a LAMBDA ON STEROIDS? Well Ecs might just be the solution you need. Ecs works very similar to Ec2 except this is a task based solution where you Create Docker images Create Containers out of the docker images Define a basic layout of the sort of tasks you might be doing Use anything you like to initiate a task all the while replacing the original parameters that you defined your tasks with Yes, it’s that simple. Docker Image Aws lets you use custom images to run your tasks on. Which means you can have your scripts or binaries or applications in the image that you want. Once built from Dockerfile, you will tag and upload this image into your AWS accounts ECR. Pretty simple to do; you can follow the official docs here. You can also use public images available in docker hub; all you need is the tag. For this example we will use the python:3.8 image available publicly in docker hub. Creating ECS Clusters Once you have a docker image in your hands, head over to your AWS account and go into ECS. Then find clusters and then hit Create cluster. Follow along. Using fargate as the cluster template We will use the first option to use the cluster as Fargate (Serverless compute for containers) Hit Next step. Give it a name and make sure to enable Cloudwatch insights cause they are always helpful. We are not creating a VPC because this account already has one, you can create one if you still need it. Hit Create. Creating Task Definition Once complete, we will create a Task definition, this will lay down the ground rules for our tasks. Find the Task Definition option from the sidebar and hit Create new Task Definition. We will use FARGATE here too to manage our clusters and tasks. Click Next step. Give your task a name. You can select the amount of default resources you want your container to have; for example, we will use 2 gigs of ram, and a single vCpu but you can always change these for each task you run. Task Execution Role You can create a custom task execution role if you want; this role will be used to pull images from ecs, and manage ecs and cloudwatch logs for your task. The console will create one by default, for us that’s okay so we are going with ecsTaskExecutioinRole. Task Role The task role is crucial for services using sdks like boto3 or aws-sdk. As this is the role that aws ecs will use to inject permissions into your container for your task to be able to use aws apis. For us the default ecsTaskExecutioinRole role will do just fine. Container Definition Click Add container. The major two settings we will use are these ones. But you can do loads of things with it but for us these two will suffice for a demo. Hit Add and then hit Create. Everything else will be default. Now that you’ve created a task definition, You can head over to the task definition page and select on your task definition and hit Run Task. Creating Tasks Let’s make this image do something. Create a task with the following steps. For this account, we already have a vpc and subnets, we are just selecting them and the console automatically assigns a security group for us. You can always create your own. Our launch type will be Fargate. As you can see it automatically picked up the cluster we made in step one otherwise you would have to choose a cluster. Since we are using public images, Auto-assign public ip must be ENABLED. Container settings for each task In the Advanced Options, we can override any task definition settings we created, for example, we are overriding the command for our task definition. Note that you must provide the commands in comma separated manner and then hit Run Task. It will take you to your cluster’s tasks option and you will see a task being Provisioned. Click on it and then hit Logs. Wait for the logs to appear and voila; The Logs are conveniently placed along with the execution. Now, ecs is not meant to be a lambda substitution, this can be used for tasks that require custom applications and scripts or heavy resources or when you are just not comfortable with the 15 minutes timeout. Caveats Not many; It is slower than a lambda to start up; from my experience it takes around a minute for the container to spin up but it’s faster than ec2 It’s a little pricier than a lambda but cheaper than ec2 That’s all folks. Hope this tutorial was useful for all reading. Take care.

**Sakib Alam**01 Aug 2022 Read →

[![](https://www.craftsmensoftware.com/hubfs/Imported_Blog_Media/Integrating-Namecheap-to-AWS-Route-1.webp)](https://www.craftsmensoftware.com/blog/integrating-namecheap-domain-to-aws-route-53)

### [Integrating Namecheap Domain to AWS Route 53](https://www.craftsmensoftware.com/blog/integrating-namecheap-domain-to-aws-route-53)

In today’s rapidly evolving digital landscape, the importance of establishing a robust online presence cannot be overstated. Whether you’re an aspiring entrepreneur launching a startup, a seasoned business owner expanding your market reach, or an individual seeking to share your passions with the world, your website acts as the virtual gateway to your brand, products, or ideas. It serves as the primary interface through which visitors engage with your offerings, learn about your mission, and potentially become loyal customers or followers. Integrating Namecheap Domain to AWS Route 53 ensures a seamless and reliable connection, enhancing your website’s performance and accessibility.” However, in the vast and ever-expanding realm of the internet, simply having a website is not enough. To ensure that your digital presence is not lost in the sea of competing voices, it’s essential to optimize your website’s accessibility and visibility. This is where the Domain Name System (DNS) comes into play. Think of DNS as the backbone of the internet—a sophisticated system that translates human-readable domain names (like www.yourwebsite.com) into machine-readable IP addresses, allowing users to locate and access websites with ease. Without DNS, navigating the internet would be akin to trying to find your way in a vast, uncharted wilderness. By leveraging DNS effectively, you can enhance the discoverability of your website, making it easier for users to find and access your online content. Whether you’re running an e-commerce store, a blog, a portfolio website, or a corporate platform, optimizing your DNS configuration is key to maximizing your online visibility and attracting the right audience. In the following sections, we’ll delve deeper into Integrating Namecheap Domain to AWS Route 53 step by step. What is AWS Route 53 If you have a domain like “example.com” and you’re using AWS Route 53 as your DNS service, Route 53 would manage the DNS records for your domain. When someone enters “example.com” into their web browser, their computer sends a DNS query to resolve the domain name to an IP address. Route 53 translates “example.com” to the public IP address of the server or resource associated with that domain. For example, you might have an EC2 instance hosting your website, and you would set up DNS records in Route 53 to point the “example.com” domain to the public IP address of that EC2 instance. When someone accesses “example.com” in their browser, Route 53 will return the IP address associated with that domain, allowing the browser to connect to the EC2 instance and load the website. DNS acts as an online GPS, guiding users to your website with precision and efficiency. In this guide, we’ll explore the seamless integration of your Namecheap domain with AWS Route 53, a robust DNS service offered by Amazon Web Services. By leveraging Route 53’s capabilities, you can enhance your website’s performance, reliability, and scalability, elevating your online presence to new heights. A Step-by-Step Guide to Integrating Namecheap Domain with AWS So, you’ve got your eyes set on integrating your Namecheap domain with AWS Route 53, huh? Great choice! Let’s dive deep into the process step by step: Step 1: Acquire Your Domain from Namecheap Before embarking on the integration journey, you need to secure your domain name through Namecheap, a reputable domain registrar known for its user-friendly interface and competitive pricing. Select a domain name that aligns with your brand identity, resonates with your target audience, and reflects your unique value proposition. Once you’ve chosen the perfect domain, proceed with the registration process on the Namecheap platform and acquire it. Step 2: Log in to AWS Management Console & Go to Route 53 Dashboard With your domain in hand, it’s time to initiate the integration process. Head over to the AWS Management Console, your gateway to the myriad of services offered by Amazon Web Services. Log in to your AWS account, and from the console dashboard, locate the Route 53 service. Route 53 serves as the centralized hub for managing DNS configurations and domain routing within the AWS ecosystem. Step 3: Create a Hosted Zone Within the Route 53 dashboard, navigate to the “Hosted Zones” section and initiate the creation of a new hosted zone. A hosted zone serves as a container for DNS records associated with a specific domain. Enter the domain name acquired from Namecheap into the designated field and proceed to create the hosted zone. Ensure that the type is set to “public” to facilitate external accessibility. Step 4: Verify DNS Records Upon creating the hosted zone, Route 53 automatically generates two essential DNS records – NS (Name Server) and SOA (Start of Authority). These records play a pivotal role in facilitating DNS resolution and domain management within the Route 53 environment. Verify the presence of these records to ensure the seamless functioning of your DNS configuration. Step 5: Head Back to Your Namecheap Dashboard Now, transition back to the Namecheap dashboard to configure DNS settings for your domain. Locate the domain you intend to integrate with AWS Route 53 and access the management options available for that domain. Step 6: Configure Custom DNS Settings In the domain management interface provided by Namecheap, navigate to the “Nameservers” section and select the option for “Custom DNS” from the dropdown menu. This selection enables you to specify custom DNS configurations tailored to your requirements, thereby facilitating seamless integration with external DNS providers like AWS Route 53. Retrieve the NS (Name Server) records generated by Route 53 during the creation of the hosted zone. These records typically comprise a set of four or more DNS server addresses associated with AWS infrastructure. Copy the NS records provided by Route 53 and paste them into the designated fields within the Namecheap dashboard. Step 7: Save Configuration Changes Once you’ve entered the AWS Name Server information into the Namecheap dashboard, proceed to save your configuration changes. This action ensures that the updated DNS settings take effect, establishing a robust connection between your Namecheap domain and AWS Route 53. Conclusion: Congratulations! By following this step-by-step guide, you’ve successfully integrated your Namecheap domain with AWS Route 53, unlocking a world of possibilities for your online presence. With Route 53’s advanced DNS management capabilities, you can optimize the performance, reliability, and scalability of your website, ensuring a seamless experience for visitors across the globe. As you continue to evolve and expand your digital footprint, remember to leverage the synergies between Namecheap and AWS Route 53 to propel your online endeavors to new heights. As you continue to evolve and expand your digital footprint, remember that the integration of your Namecheap domain with AWS Route 53 is just the beginning of your online journey. Stay curious, stay innovative, and never hesitate to explore new ways to leverage technology to achieve your goals. With the power of Namecheap and AWS Route 53 behind you, the possibilities for your online presence are truly limitless.

**Harun Or Rashid**02 Apr 2022 Read →

[![](https://www.craftsmensoftware.com/hubfs/Imported_Blog_Media/Configure-Your-React-Vite-Application-for-Tailwind-CSS.webp)](https://www.craftsmensoftware.com/blog/configure-your-react-vite-application-for-tailwind-css)

### [Configure your React + Vite Application for Tailwind CSS](https://www.craftsmensoftware.com/blog/configure-your-react-vite-application-for-tailwind-css)

Introduction Tailwind is a sizable collection of tiny CSS utility classes for rapidly and reliably creating attractive websites. Frameworks like Antd, Bootstrap and Material Design have high-level components like buttons, cards, grids, menus and forms to create different components, Tailwind provides a more practical approach by giving you utility classes that can be used to create components similar to these. This approach gives you significantly more creative freedom than other CSS frameworks while still sticking to a design structure that you wouldn’t obtain with pure CSS. \[Ref\]

**Abdus Sayef Reyadh**18 Mar 2022 Read →

[![Improving cost and efficiency by using AWS Lambda’s cache](https://www.craftsmensoftware.com/hubfs/Improve%20Cost%20%26%20efficiency.webp)](https://www.craftsmensoftware.com/blog/improving-cost-and-efficiency-by-using-aws-lambdas-cache)

### [Improving cost and efficiency by using AWS Lambda’s cache](https://www.craftsmensoftware.com/blog/improving-cost-and-efficiency-by-using-aws-lambdas-cache)

In this blog, we’re going to discuss how global variables inside AWS Lambda work and how you can use them in your serverless applications to increase performance and cache values. Let’s first start with the definition of cache. According to AWS official documentation, “In computing, a cache is a high-speed data storage layer that stores a subset of data, typically transient in nature, so that future requests for that data are served up faster than is possible by accessing the data’s primary storage location. Caching allows you to reuse previously retrieved or computed data efficiently”. What are global variables in AWS Lambda? A global variable in AWS Lambda is one that is defined outside of the scope of your main lambda handler function. It remains consistent between lambda invocations since it exists outside of the handler. To understand this, you must first understand how an AWS Lambda works in order to comprehend the global variable. When you initially receive a request for our lambda, AWS will spin up a container with all of the environment settings that you require for your lambda to download the code into that container, and then execute it. This is something which is also known as a cold-start of an AWS lambda. If you have variables declared outside of the main handler function, they are declared in a global space. Once your first request has been completed, the lambda container will still exist for a certain period of time, so if you receive a second lambda request, that new request will execute in the same container and therefore you have access to that global variable and it’s contents that were declared. Deep dive with a NodeJS Lambda example Here is an example of an AWS Lambda function that is responsible for handling AWS DynamoDb requests. On each request, it will create a new connection with AWS DynamoDB and try to fetch the user information from the AWS DynamoDB table. This implies that the database connection will be re-instantiated for each lambda invocation. Now let’s look at a different approach where we do not re-instantiated the AWS DynamoDB connection by applying Singleton Design Pattern for the AWS DynamoDB connection instance. On the above modification did you notice something 🤔? Yes, you are right, we are actually fetching the same user with id = \`dummy-user-id\`. In this scenario, although we managed to limit the database connection we are actually making a database fetch call in each request when in all cases the value is the same. So let’s see what we can do about it, shall we? Now, here we now make a cache global variable that will store the database result corresponding to the id and whenever a request comes it will try to find the user in the cache and thus return the result. If the user is not found in the cache, it will call the AWS DynamoDB to get the user and then put it in the cache and finally return the result. Here we can see that we have successfully optimized the number of AWS DynamoDB connections and calls per request along with minimizing the lambda compute time in total. This strategy can be greatly utilized where the data is consistent and can be cached inside lambda’s global space. Some considerations you need to know about Although the idea is great, it’s not ideal for all the use cases. In the above example, we have worked with data that is consistent in the database. But if the scenario is like the data is changing frequently then we need to think of a different approach. Now let’s talk about some lambda considerations as well, think about what will happen when there are numerous concurrent requests? You might think that all the requests will be handled inside the same container and the global variables will be persistent but that’s not the case here. AWS will spin up numerous containers operating at the same time to process those concurrent requests. Because there are distinct containers, they are isolated, which means that inside one of your containers, your global variable may be set to one value, but in another, it may be a different value. In this case, it’s a waste of resources to cache additional values when your database is most likely to be called in each container. Another consideration is cache size and how much memory does the Lambda function require, and how much memory is allocated? If the Lambda cache continues to expand, it may create memory exhaustion issues and prevent the function from functioning at all. These are some of the items to think about while constructing your AWS Lambda and utilizing these global variables. Thank you for your time.

**Abdus Sayef Reyadh**02 Oct 2021 Read →

[![](https://www.craftsmensoftware.com/hubfs/Imported_Blog_Media/software-development-in-bangladesh.webp)](https://www.craftsmensoftware.com/blog/craftsmen-thrives-at-goodfirms-by-offering-scalable-robust-software-solutions-developed-with-quality-by-maestros)

### [‘Craftsmen’ Thrives at GoodFirms by Offering Scalable & Robust Software Solutions Developed With Quality by Maestros](https://www.craftsmensoftware.com/blog/craftsmen-thrives-at-goodfirms-by-offering-scalable-robust-software-solutions-developed-with-quality-by-maestros)

Rendering premium technology solutions to the leading companies worldwide endows ‘Craftsmen’ as one of the top software solutions providers in Bangladesh at GoodFirms. About Craftsmen: Headquartered in Dhaka, Bangladesh, Craftsmen Ltd. comprises globally- experienced software engineers’ who have worked with the world’s top software businesses for over ten years. The expert group provides premium software development solutions to leading companies globally. ‘Craftsmen’ aims to achieve operational efficiency and excellence for the clients’ businesses. Its mission is to improve customers’ business value chain through highly productive automated settings. The professionals continuously engage themselves in inventing new ways to optimize customers’ operations through the most advanced tools and technologies. Besides this, the expert and qualified team is always committed to adding value to the clients’ business. Furthermore, the skilled team strives to simplify and streamline business workflows by saving customers’ time and cost irrespective of their business domain. Due to a highly proficient team rendering quality service offerings, ‘Craftsmen’ was awarded as one of the best startup companies of 2020 by BASIS (Bangladesh association of software & information services). GoodFirms’ Research Process: GoodFirms is a B2B online evaluation and reviews platform that appraises different businesses cataloged with it through its overall assessment process based on three principal aspects viz Quality, Ability, and Reliability. GoodFirms with this research helps the business people get their perfect associate that satisfies their business requirements. Same way, the researchers also assessed ‘Craftsmen’ and found that the firm is recognized as the leading business in software development and testing services in Bangladesh at GoodFirms. The researchers also concluded that ‘Craftsmen’ would soon get dubbed amongst the prominent IT service agencies at GoodFirms. The below-mentioned erudition from the evaluation illustrates Craftsmen’s working policies and its booming services. Software Development: At ‘Craftsmen,’ the experienced engineers hold expertise in cloud computing and complex backend server application development. The skilled software engineers at ‘Craftsmen’ design complex enterprise solutions by distinguishing and analyzing any design flaws in advance. Moreover, ‘Craftsmen’ hold an experienced software Quality Assurance (QA) department specializing in automated software quality assurance and manual testing. Since its inception, ‘Craftsmen’ creates and delivers enterprise-grade software solutions and is labeled as a reputed software agency amongst global enterprises. Thus, guaranteeing the delivery of software solutions that meets clients’ business needs focusing on feasibility, stability, reliability, and security endows ‘Craftsmen’ as one of the top software development companies in Bangladesh at GoodFirms. Testing Services: ‘Craftsmen’ hold a different team for web, mobile, desktop, and cloud applications along with the QA team to render the best quality products. ‘Craftsmen’ is a one-stop-shop for all of the clients’ QA needs. Without a single line of code written, clients can use the Static Testing services provided by the expert testers’ team to perform earlier testing and ensure quality from the start. The qualified QA team makes sure that clients get the overall quality of the application, performance improvements, and scalability. Moreover, the expert testers keep themselves apprised of all emerging trends, new technologies, and customer needs to provide bug-free products. Thus, outfitted with a qualified and skilled team of testers, ‘Craftsmen’ get dubbed as one of the leading software testing agencies in Bangladesh at GoodFirms. IT Services: At ‘Craftsmen,’ the team deploys up-to-minute methodology and the in-depth knowledge of technology to choose highly qualified candidates. The proven best practices ensure clients get professionals who will grow & shine like gems. Besides focusing on the talent, the team also carefully checks & verifies the background for total satisfaction. The organization provides IT Consultancy for mission-critical projects to drive the customers towards their goal. The expert professionals at ‘Craftsmen’ display, attract and relocate experienced IT and engineering talent from different countries to their service centers. Alternatively, the group also facilitates the smooth relocation of top talent to the customers’ offices. Thus, furnished with such talented team providing bespoke IT services & solutions to global clients would endow ‘Craftsmen’ as one of the best IT services and solutions providers at GoodFirms. About GoodFirms: Washington, D.C. based GoodFirms is an innovative B2B Research and Reviews Company that extensively combs the market to find software development, software testing, and IT services agencies amongst many other technology firms that offer the best services to their customers. GoodFirms’ extensive research process ranks the companies, boosts their online reputation, and helps service seekers pick the right technology partner that meets their business needs. About the Author: Anna Stark is a staff writer with GoodFirms – a Washington D.C. based B2B Research Company that bridges the gap between service seekers and service providers. Anna’s current role includes gauging companies’ performances and their key attributes and putting them into words. She firmly believes in the magic of words. She is always looking for new strategies and ideas that companies have gladly embraced and exclusively shines a light on those to make their identities shine brighter on GoodFirms and the World Wide Web.

**Craftsmen Research Team**11 Jun 2021 Read →

[![](https://www.craftsmensoftware.com/hubfs/Imported_Blog_Media/Gzip-Internal-Decomporess-02.png)](https://www.craftsmensoftware.com/blog/gzip-internals-how-to-implement-gzip-decompression)

### [Gzip internals: How to implement gzip (de)compression](https://www.craftsmensoftware.com/blog/gzip-internals-how-to-implement-gzip-decompression)

Introduction Gzip (typically files with .gz extension) is a file format that contains compressed data blocks. It is used in web protocol such as http to compress data being communicated which saves bandwidth, for example, compressing the message body (webpage) of an http response. The interesting thing about gzip is that gzip decompression can be implemented as a streaming algorithm which makes it a good candidate for compression in web protocols. For example, if you go to wikipedia and look at the GET http network call in your web browser, you will see that there is a response header “content-encoding” with the value “gzip”. This means your browser is decompressing the http response’s message body using gzip decompression at the same time it is receiving the response so that it can render the webpage. The browser doesn’t need to get the whole message body before it can start decompressing. The gzip file format specification is described in rfc 1952 and the compressed blocks specification (deflate) is described in rfc 1951. Gzip decompression To decompress, let’s simply think that we have read the .gz file into memory so that we have a buffer of “bytes” and we have a position marker that indicates which “byte” we are currently at (starting with 0). Essentially what we want to do is iterate through this buffer of bytes and interpret the bytes according to the gzip/deflate specification. Note: All multi-byte numbers are written with the least significant byte first in the gzipped file. So if the spec talks about a 2 byte field the field’s number value is = byte0 + 2^8 \* byte1. Similarly, a 4 byte field’s number value is = byte0 + 2^8 \* byte1 + 2^16 \* byte2 + 2^24 \* byte3 Member header and trailer Gzip file can contain multiple “members” (typically if you gzip a file it will contain only one member) and every member has the following format. It starts with some header fields which are described by this table (size in bytes in the parenthesis): ID1 (1) ID2 (1) CM (1) FLG (1) MTIME (4) XFL (1) OS (1) Every member will at least have 10 bytes of header. ID1 (Identification 1) – must have value 31 (0x1f) ID2 (Identification 2) – must have value 139 (0x8b). These magic numbers specify the file as being gzip file format. CM (Compression Method) – This byte must have the value 8 as gzip only supports deflate as its compression method. So if we see that the third byte is not 8, we can error out saying we don’t recognize the compression method. FLG (Flag) – 1 byte of FLG (Flag) depending on its bits, we can have some extra header fields. MTIME (Modification Time) – We can just skip these 4 bytes XFL (Extra Flags) – We can skip this 1 byte OS (Operating System) – We can skip this 1 byte Now FLG byte’s bits are described as below (starting with bit 0 on the left and bit 7 on the right total 8 bits): FTEXT FHCRC FEXTRA FNAME FCOMMENT RES RES RES If the RES (reserved) bits are set, we need to indicate error to be standard compliant. If FTEXT is set, that means the file is probably ASCII text. If FEXTRA bit is set to 1 ((FLG \>\> 2) & 1 == 1) we will have the following extra header bytes after the OS byte: XLEN (2) XLEN bytes of extra fields So, if FEXTRA is set we will read the next 2 bytes from the buffer and whatever value we get from these two bytes as a number (byte order from lsb to msb – so XLEN = first byte + 256 \* second byte) we need to read XLEN number of bytes from the buffer which we can simply skip If the FNAME bit is set, we need to keep reading the next bytes until we reach a zero byte. This subset of bytes denotes the original filename which we can also just skip. Zero terminated filename… If the FCOMMENT bit is set, we also need to keep reading the next bytes until we reach a zero byte. This subset of bytes can denote some information about the file which we can also just skip. Zero terminated file comment… If FHCRC is set, we have to read the next 2 bytes as a CRC16 value which is the cyclic redundancy check value for the member header (upto and not including the CRC16 bytes) (which we can use for checking validity of the header bytes) but we will simply also skip them (we don’t need to verify the validity of the member header if CRC16 \_is\_ present to be standard compliant decompressor, so we will just skip) CRC16 (2 bytes) So we have now read through a member’s header bytes, after which the “compressed blocks” start Compressed blocks… And after the compressed blocks, 8 bytes of member trailer bytes start at the next byte boundary (blocks can end at any bit position of a byte, not necessarily ending at a byte boundary). CRC32 (4 bytes) ISIZE (4 bytes) So, after we decompress the blocks we \_do\_ need to read these 8 bytes just to make sure they are present (because standard compliant .gz file \_will\_ contain these bytes) but we don’t need to verify the CRC32 of the decompressed blocks or if the size % 2^32 == ISIZE to be standard compliant. Compressed blocks After the header bytes of a member, the compressed blocks start. Except the first compressed block, any other compressed block can actually start at any bit position (0 – 7) of any byte. So from now on we also need to keep a bit marker position along with the current byte position. Whenever the bit position reaches 7, we will increase the byte position by 1 and make the bit position 0 again. Note: all the bit sequences of any data element other than huffman codes are inserted with the least significant bit first. That means if we are at a byte boundary and we have a data element of 2 bits the 0th bit of the “data element” is put into the 0th bit of the byte and the 1st bit of the data element is put into the 1st bit of the byte. Huffman codes are inserted starting with the most significant bit first. That means if a huffman code is 110 (msb being 1 and lsb being 0) and we are at a byte boundary then the 0th bit of the byte will be 1, the 1st bit 1 and the 2nd bit 0. The compressed blocks specification is described in rfc 1951 which describes the deflate compressed data format. All compressed blocks start with 3 header bits. The first bit denotes BFINAL which if set (1) means we are at the final compressed block (meaning after the end of this block we have the member trailer bytes). So we need to keep decompressing blocks until we reach a block which has the BFINAL bit set. The next 2 bits represent what type of compressed block we are dealing with. (we need to remember the note: data elements other than huffman codes are inserted with least significant bit first). So the 2 BTYPE bits have the following meaning: 00 – no compression 01 – compressed using fixed huffman codes 10 – compressed using dynamic huffman codes 11 – error type So we read the next 2 bits (from the current bit position of the current byte) and according to the above description, if the first bit is 0 and second bit is 0, we need to decompress block type 00, if the first bit is 1 and the second bit is 0, we need to decompress block type 01 and if the first bit is 0 and the second bit is 1, we need to decompress block type 10 and if both are 1 we need to indicate error. Decompressing block type 00 If we encounter block type 00, we move to the next byte boundary skipping the unread bits from the previous bit position of the previous byte if any. Block type 00 looks like this: LEN (2 bytes) NLEN (2 bytes) LEN bytes of literal data Where the next 2 bytes determine the number of literal data bytes in this block. NLEN is the one’s complement of LEN. so LEN == (unsigned) ~NLEN should be true. If this equality doesn’t hold we can indicate error. After these 4 bytes in the buffer, we simply read the next LEN bytes from the buffer and can just write them to the output file because they are simply literal data bytes. This is the end of decompressing block type 00. Prerequisites Before we start on the other 2 block types, we need to understand how deflate compresses data. Compressed data blocks use a combination of LZ77 and huffman coding. So if you have some input data bytes you want to compress, first you run the data bytes through LZ77 which then outputs literal bytes + length distance pairs. The length distance pair means that at that point length number of bytes should be copied starting at distance bytes before. So essentially you find matches of subset of bytes in the previous bytes (you can use any string matching algorithm for that) and instead of literal bytes, use length distance pairs to replace those matching bytes. Deflate limits length between 3 and 258 and distance from 1 to 32768. Then you create huffman codes for this alphabet (literal, length, distance) and write the huffman codes (bit sequences for the literal, length and distance data) as the compressed blocks. Huffman codes are generated based on the frequency of “symbols” from the alphabet we are working with. The symbols with more frequency get a smaller bit length sequence and the characters with less frequency get a longer bit length sequence. For example, if you have the string “ABBAAC” and you want huffman codes for A, B, C first you count the frequency of the alphabet symbols A = 3 B = 2 C = 1 Then you take the 2 lowest frequencies C(1) and B(2) and add a node on top of them with 0(left) and 1(right) as the path. Then you insert CB (1 + 2 = 3) into the frequency table instead of the old two A = 3 CB = 3 And you again take the 2 lowest frequencies A(3) and CB(3) and add a node on top of them. You keep doing this until all the symbols have been added to the tree. So you finally get so huffman codes are A = 0 B = 11 C = 10 Note that huffman codes for deflate must not exceed bit length of 15. Now deflate imposes 2 restrictions when generating huffman codes: All codes of a given bit length have lexicographically consecutive values, in the same order as the symbols they represent which means in the above example B should have huffman code 10 and C should have 11 Shorter codes lexicographically precede longer codes which means it shouldn’t happen in the above example that A has huffman code 1 and B has 01 and C has 00 Because of these restrictions, you can generate only one huffman tree from given alphabet frequencies and you can simply generate the huffman codes given the bit lengths of the symbols in the alphabet. Otherwise, you would need to provide the huffman codes themselves along with all the symbols which would take up more bits. Given the huffman code lengths for the symbols, you can generate the huffman codes following this algorithm from rfc 1951 section 3.2.2 This generates the next code for a bit length (index in next\_code) and you can just keep adding 1 when generating all the huffman codes for the symbols that have the same bit length for their huffman codes. Why this works?: This algorithm works because of the 2 restrictions imposed on the huffman tree which makes the binary tree (assuming the left path of any node is 0 and the right path is 1) such that any leaf node that is on the “right”, must be at a height greater than or equal to the height of any leaf node on its “left” (because of the 2nd restriction). So, if we want to add the first leaf node at the next greater height, we will go to the next non-leaf node on the right and add a path 0 on that node and then add the leaf node there, which is where the \<\< 1 comes from. Left shifting by 1 adds a ‘0’ bit at the end. And if there are multiple leaf nodes on the same height or level, that means they will be sequentially positioned (because leaf nodes with greater heights will be on the right if any) and to get the code of a node we are currently at, we can simply add 1 to the leaf node’s code on its immediate left, which is where the (code + bl\_count\[bits – 1\]) is coming from. (code + bl\_count\[bits – 1\]) is adding the total number of leaf nodes at a level to the code for the first leaf node at that level which is the code for the next non-leaf node on that level. Now we know how to generate huffman codes for symbols if we are given the bit lengths of the huffman codes for those symbols. So Deflate compressed blocks contain 3 distinct alphabets which are literal bytes, length and distance and uses “codes” to determine if we are encountering a literal byte or length or distance. The codes for literal bytes are 0 – 255. The length codes follow the below table from rfc 1951: This means if we encounter a code of 266 from the huffman tree when reading the bits of a compressed block the length value is either 13 or 14 depending on the next bit (1 extra bit for length code 266). If the next bit is 1 length is 14 otherwise 13. Same goes for all the codes given in this table. Similarly, we have a table for distance codes: After the length code and its extra bits, we will have to read the distance code (how the distance code is read depends on the block type 01 or 10). If the distance code is 8 we need to read the next 3 bits and calculate the actual distance value is 17 + value of next 3 bits. So the value for distance code 8 can range from 17 – 24. Note that now we know the concept that there can be length distance pairs in the compressed blocks that means we need to keep a data structure of back references of the decompressed bytes of at least size 32768 (maximum distance) from the beginning when we start decompressing any block. And we need to keep updating this back reference as we keep decompressing bytes. So when we encounter a length distance pair we will simply copy length bytes from distance from the back references data structure to our output buffer for later writing to output file. Decompressing block type 01 Block type 01 uses fixed huffman codes which are given in rfc 1951. The length of the literal and length codes are as follows: We can simply use the bit lengths here to get the huffman codes for codes 0 to 287 according to the algorithm in section 3.2.2 (also given above). (although codes 286 and 287 will never appear in the compressed blocks we still need to form the huffman tree with them otherwise we will get wrong huffman codes for the literal length codes. Something to keep in mind). After we generate the huffman codes for these literal, length codes, we need to form the huffman tree from the huffman bit sequences of these huffman codes which is just a binary tree with paths either 0 or 1 and the leaf nodes of the tree denote a “code”. The tree must be formed with the huffman codes’ most significant bit first as stated earlier. So after the header bits, we keep reading the bits from the input buffer and we keep walking the huffman tree starting from the root node. If we are at a node that is a leaf node, we see if it is a literal code or a length code. If it’s a literal code (0 – 255) we can simply copy this byte in our output buffer. If it’s a length code we need to read any extra bits if necessary and calculate the length value according to the length/extra-bits table. After the length code, we need to read 5 bits for the distance code. And after the 5 bits we need to read extra bits if any according to the distance/extra-bits table and calculate the distance value. For this length distance pair, we need to copy length bytes from distance from the back references data structure that we are maintaining. If we encounter the code 256 which is the block end marker, it means we have decompressed a block of type 01. So we need to keep reading bits and keep walking the huffman tree from root node until we reach the code 256 i.e., until the block ends. Decompressing block type 10 Block types 10 use dynamic huffman codes as opposed to block type 01’s fixed huffman codes. These codes’ lengths (remember we know how to generate huffman codes from code lengths?) are specified after the header bits. Now these code lengths are not directly specified; rather these “code length alphabet” are themselves huffman coded and the lengths of the huffman codes of the “code length alphabet” are provided and then the literal length or distance codes’ lengths are given using these code length codes. The alphabet for the code lengths is as follows: 0 – 15 (remember huffman code lengths must not exceed 15 for deflate?): represents code lengths from 0 to 15 16: repeat the previous code length 3 – 6 times. The next 2 bits determine how many times to repeat the previous code (00 = 3 (0 + 3), …, 11 = 6 (3 + 3)) 17: repeat a code length of 0 3 – 10 times. The next 3 bits determine how many times to repeat 0. (000 = 3(0 + 3), …, 111 = 10(7 + 3)) 18: repeat a code length of 0 11 – 138 times. The next 7 bits determine how many times to repeat 0. (000 0000 = 11 (0 + 11), …, 111 1111 = 138(127 + 11)) Now the format of the compressed block type 10 after the 3 header bits is as follows: HLIT (5 bits) HDIST (5 bits) HCLEN (4 bits) HLIT = number of literal length codes – 257 (257 – 286) HDIST = number of distance codes – 1 (1 – 32) (distance codes 30 – 31 will never appear in compressed blocks but will participate in building the distance codes huffman tree if present) HCLEN = number of code lengths – 4 (4 – 19) After the HLIT, HDIST and HCLEN fields, the block contains the lengths for the code length codes 3 bits each and they are in this order: 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 This means, after the HCLEN field, there are (HCLEN + 4) numbers of group of 3 bits that denote the lengths of the code length codes according to the above serial. So, the next 3 bits are the length of the code length code 16, the next 3 bits for 17… So we need to read the next (HCLEN + 4) \* 3 bits and generate the huffman codes for the given code lengths and form the huffman tree of these code length codes. Then, there should be HLIT + 257 code lengths for the literal/length alphabet (0 – 285) given using the code length huffman codes. That means we need to keep reading bits and keep walking the code length codes huffman tree and if we hit a leaf node we need to remember the length for the “corresponding” (starting from 0 to HLIT + 256) literal/length alphabet symbol. If the leaf node has value 0 – 15 that means this is the length of that corresponding literal/length code, if its 16 we need to repeat the previous length for 3 – 6 times according to the value of the next 2 bits and if its 17 / 18 we need to repeat 0 as code lengths for the next literal/length symbols for “the corresponding extra bits value” number of times. So the first leaf node that we hit will indicate the length for literal code 0, the leaf node that we hit for 257th iteration will indicate the length for code 256 (block end marker) and similarly, the leaf node that we hit for 286th iteration (if HLIT + 257 == 286) will indicate the length for length code 285 which denotes the length value 258 (remember the length/extra-bits table?). Of course, there can be less than 286 code lengths (which will mean the latter length codes are not in use in this compressed block). After we get all the HLIT + 257 code lengths for the literal/length alphabet we need to generate the huffman codes from these lengths again using the rfc 1951 section 3.2.2 algorithm (also given above) and form the literal/length code huffman tree. After the literal/length code lengths, there should be HDIST + 1 numbers of distance code lengths specified, again, using the code length codes. So we need to keep walking the code length code huffman tree and get the distance codes’ lengths the same way as we did for literal/length codes and generate the huffman tree for distance codes. After these bits, the actual compressed data begins. So we need to keep reading bits and this time we need to keep walking the literal/length code tree. If we get a literal code (0 – 255) we just copy it into our output buffer. If we get a length code then we need to read extra bits according to the length/extra-bits table mentioned above and get the actual length value. After getting the length value, we then need to read the next bits and this time keep walking the distance code tree to determine the distance code (because after length always comes the distance) and when we get the distance code, we need to read the extra bits according to the distance/extra-bits table above to get the distance value. If we get proper length and distance values, we need to copy length bytes from distance from our back references data structure that we have been maintaining. The compressed block ends when we encounter the code 256 in the literal/length huffman tree. Thus block type 10 is decompressed. Conclusion So, to summarize, we need to read member header, keep decompressing the 3 block types till we reach a block that has BFINAL header bit set, write decompressed bytes to the output file, read the member trailer and keep doing this if there are multiple members present. Rfc 1952 and 1951 must be read thoroughly if you are planning on implementing gzip as the rfcs contain all the quirks, which need to be kept in mind when developing. This post contains the things that I found harder to fully understand from the rfcs but this post is definitely not the full specification which the rfcs \_are\_. You can look at my gzip decompression implementation alongside for reference: https://github.com/dorjoy03/ungzip Peace out! References https://en.wikipedia.org/wiki/Gzip https://www.rfc-editor.org/rfc/rfc1952.txt https://www.rfc-editor.org/rfc/rfc1951.txt

**Dorjoy Chowdhury Bappy**05 Jun 2021 Read →

[←](https://www.craftsmensoftware.com/blog/page/8#articles) [1](https://www.craftsmensoftware.com/blog/#articles) … [8](https://www.craftsmensoftware.com/blog/page/8#articles)

9

[10](https://www.craftsmensoftware.com/blog/page/10#articles) [11](https://www.craftsmensoftware.com/blog/page/11#articles) [→](https://www.craftsmensoftware.com/blog/page/10#articles)

## Looking for A Trusted AI-native Partner?

Our engineers work inside your product team, bringing broadcast experience and AI-native workflows. Let’s talk about your platform, your roadmap and where you need support.

[Book a Strategy Call →](https://www.craftsmensoftware.com/contact-us)

[![Mahmudul Haque Azad](https://www.craftsmensoftware.com/hs-fs/hubfs/Azad_bhai_new_DP__grey_BG.png?width=58&height=58&name=Azad_bhai_new_DP__grey_BG.png) Book Free 1:1 with Mahmudul Haque Azad CEO & Janitor, Craftsmen](https://www.craftsmensoftware.com/contact-us)

![](https://www.craftsmensoftware.com/hs-fs/hubfs/Azad_bhai_new_DP__grey_BG.png?width=46&height=46&name=Azad_bhai_new_DP__grey_BG.png)

Book Free 1:1 with Mahmudul Haque Azad

CEO & Janitor, Craftsmen

Loading calendar…

### ABOUT CRAFTSMEN

[The Team](https://www.craftsmensoftware.com/about-us)[Our Partnership Model](https://www.craftsmensoftware.com/how-we-work)[Client Stories](https://www.craftsmensoftware.com/client-success-stories)[Career](https://careers.craftsmensoftware.com/)[FAQ](https://www.craftsmensoftware.com/faq)[Privacy Policy](https://www.craftsmensoftware.com/privacy-policy)

<https://www.linkedin.com/company/craftsmensoftware/><https://www.youtube.com/@craftsmensoftware>

### HEADQUARTERS

Craftsmen UK

One Sovereign Quay, Bridge End, Leeds, West Yorkshire LS1 4AG, United Kingdom

### OPERATIONAL HUB

Craftsmen Bangladesh

Plot # 316, Lane # 4, DOHS Baridhara, Dhaka 1206, Bangladesh

### SALES & PARTNERSHIP

Craftsmen Norway

Kong Oscars gate 66, 68, 5017 Bergen, Norway

Craftsmen France

6 Avenue Pierre Grenier, 92100 Boulogne-Billancourt, Paris, France

### A TEAM YOU CAN TRUST

[![ISO 9001 certified](https://crafty-astro-2-0.skarif2.workers.dev/_astro/iso-9001.rB3N1YoH_19riAQ.webp)](https://www.craftsmensoftware.com/trust-centre)[![ISO 27001 certified](https://crafty-astro-2-0.skarif2.workers.dev/_astro/iso-27001.Ds31wC1E_Z2lNtpQ.webp)](https://www.craftsmensoftware.com/trust-centre)[![ISO 27701 certified](https://crafty-astro-2-0.skarif2.workers.dev/_astro/iso-27701.qBI_Bjkt_Z1J5MRi.webp)](https://www.craftsmensoftware.com/trust-centre)

[![Glassdoor reviews](https://crafty-astro-2-0.skarif2.workers.dev/_astro/glassdoor.C76Qo6k3_Z1Br5vs.webp)](https://www.glassdoor.com/Overview/Working-at-Craftsmen-EI_IE3004266.11,20.htm)[![GoodFirms, top software development company in Bangladesh](https://crafty-astro-2-0.skarif2.workers.dev/_astro/goodfirms.CJaHzqAg_1xfRU9.webp)](https://www.craftsmensoftware.com/blog/craftsmen-thrives-at-goodfirms-by-offering-scalable-robust-software-solutions-developed-with-quality-by-maestros)

© 2026 Craftsmen. All rights reserved.

```json
{
  "@context" : "https://schema.org",
  "@id" : "https://www.craftsmensoftware.com/#organization",
  "@type" : "Organization",
  "address" : {
    "@type" : "PostalAddress",
    "addressCountry" : "GB",
    "addressLocality" : "Leeds",
    "addressRegion" : "West Yorkshire",
    "postalCode" : "LS1 4AG",
    "streetAddress" : "One Sovereign Quay, Bridge End"
  },
  "alternateName" : "Craftsmen Software",
  "areaServed" : [ "Norway", "Sweden", "United Kingdom", "Germany", "Spain", "United States" ],
  "contactPoint" : {
    "@type" : "ContactPoint",
    "availableLanguage" : [ "English", "Norwegian" ],
    "contactType" : "sales",
    "url" : "https://www.craftsmensoftware.com/contact-us"
  },
  "description" : "Craftsmen is an AI-native software engineering partner. We build dedicated engineering teams for companies in Europe and the US, and have worked with media and broadcast technology companies since 2011.",
  "founder" : {
    "@type" : "Person",
    "jobTitle" : "Founder & CEO",
    "name" : "Mahmudul Haque Azad"
  },
  "knowsAbout" : [ "Software team extension", "Dedicated software engineering teams", "Media and broadcast software", "Live streaming engineering", "Cloud-native engineering on AWS", "Legacy software modernisation" ],
  "legalName" : "Craftsmen Ltd.",
  "location" : [ {
    "@type" : "Place",
    "address" : {
      "@type" : "PostalAddress",
      "addressCountry" : "GB",
      "addressLocality" : "Leeds",
      "addressRegion" : "West Yorkshire",
      "postalCode" : "LS1 4AG",
      "streetAddress" : "One Sovereign Quay, Bridge End"
    },
    "name" : "Craftsmen UK (headquarters)"
  }, {
    "@type" : "Place",
    "address" : {
      "@type" : "PostalAddress",
      "addressCountry" : "NO",
      "addressLocality" : "Bergen",
      "postalCode" : "5017",
      "streetAddress" : "Kong Oscars gate 66, 68"
    },
    "name" : "Craftsmen Norway"
  }, {
    "@type" : "Place",
    "address" : {
      "@type" : "PostalAddress",
      "addressCountry" : "FR",
      "addressLocality" : "Boulogne-Billancourt",
      "postalCode" : "92100",
      "streetAddress" : "6 Avenue Pierre Grenier"
    },
    "name" : "Craftsmen France"
  }, {
    "@type" : "Place",
    "address" : {
      "@type" : "PostalAddress",
      "addressCountry" : "BD",
      "addressLocality" : "Dhaka",
      "postalCode" : "1206",
      "streetAddress" : "Plot # 316, Lane # 4, DOHS Baridhara"
    },
    "name" : "Craftsmen Bangladesh (operational hub)"
  } ],
  "logo" : "https://www.craftsmensoftware.com/hubfs/Craftsmen%20Logo_Black.png",
  "name" : "Craftsmen",
  "sameAs" : [ "https://www.linkedin.com/company/craftsmensoftware/", "https://www.facebook.com/craftsmenltd", "https://www.youtube.com/@craftsmensoftware" ],
  "url" : "https://www.craftsmensoftware.com/"
}
```

```json
{
  "@context" : "https://schema.org",
  "@id" : "https://www.craftsmensoftware.com/#website",
  "@type" : "WebSite",
  "inLanguage" : [ "en", "nb" ],
  "name" : "Craftsmen",
  "publisher" : {
    "@id" : "https://www.craftsmensoftware.com/#organization"
  },
  "url" : "https://www.craftsmensoftware.com/"
}
```