From The Challenges - Git
Exploring the software engineering lessons we can learn from the solutions I've seen.
Hi this is John with this week’s Coding Challenge.
🙏 Thank you for being one of the 88,121 software developers who have subscribed, I’m honoured to have you as a reader. 🎉
If there is a Coding Challenge you’d like to see, please let me know by replying to this email📧
Welcome To Coding Challenges - From The Challenges!
In this Coding Challenges “from the challenges” newsletter I’m sharing some of the common mistakes I see software engineers make when tackling the Coding Challenges.
I’m sharing both the mistakes people make and some thoughts on how you can you avoid making the same mistakes when taking on the coding challenges or when writing software professionally. Sometimes we have to make mistakes to learn from them, somethings we can learn from other people’s mistakes, then make our own new ones! 😀
Recapping The Build Your Own Git Coding Challenge
In the build your own git coding challenge the goal was to write a git client.
As a software engineer, I’m sure you’ve heard of the distributed version control system that is git and the hugely popular git hosting service GitHub.
If you’ve not come across git before, I wrote about it on LinkedIn here, where I also explained why it’s called git!
The git challenge has you build a git client that can: create a new repository, add some commits and push them to GitHub.
BTW if you'd like to try a different approach to building your own git, where you have automated tests for each step, then CodeCrafters offers a grep project that includes automated tests and sample code. Right now you can get 40% off and help support Coding Challenges too!
If You Enjoy Coding Challenges Here Are Four Ways You Can Help Support It
Refer a friend or colleague to the newsletter. 🙏
Sign up for a paid subscription - think of it as buying me a coffee ☕️, with the bonus that you also get 20% off any of my courses.
Buy one of my self-paced courses that walk you through a Coding Challenge.
Join one of my live courses where I personally teach you Go by building five of the coding challenges or systems software development building a Redis clone.
Five Common Mistakes Software Engineers Make Solving The Git Coding Challenge
I’ve pulled together this list of common mistakes from the hundreds of submissions I’ve been sent privately and the many shared in the Coding Challenges Shared Solutions GitHub Repo.
Mistake 1 - Not Doing This Coding Challenge!
Alongside, building your own Redis and building your own Docker, I think git is one of the most interesting coding challenges I’ve shared. I can’t be alone in that belief. A very popular post on HackerNews recently looked at Artisanal Handcrafted Git Repositories. The article walks you through building a git repository by hand, including the commits. It’s a great read and a great supplement to this project.
So what do you learn building a git clone? Here’s the highlights:
Understanding what git is and how it works.
Learning about content addressable filesystems (git is one), this is a technique used in IPFS, git, Docker, BitTorrent and others.
Hashes and hashing.
Zlib and compression.
Diffing files.
If you haven’t already, give it a go! Build your own git client.
Mistake 2 - Take Care To Understand The Requirements
One of the reasons I pick well known tools like git is learning to recreate them also helps you learn how to use them and how they work. You potentially learn multiple things at once.
That does mean you need to invest a bit of time in understanding the software we’re cloning. You need to take care to understand what the functionality we’re cloning does. You also need to avoid assuming you know what it does. Why? Because a key part of being a software engineer is building to the specification and finding or figuring out what the specification is, if it isn’t clear.
Mistake 3 - Avoid Magic Numbers In Code
Magic numbers are unique numerical values with no obvious meaning. Magic numbers are one of the oldest anti-patterns in software programming. They’re a problem because they obscure the programmer’s intent.
Instead of magic number it’s better to use named constant variables, where the name makes it clear what the constant refers to. In this coding challenge I saw a few solutions with a number of magic numbers and it meant I struggled to follow the code.
Alternatively, sometimes a comment will do.
Mistake 4 - Finish!
It’s easy to copy the easy bits of a tutorial. It’s easy to do the easy bits of a coding challenge or project at work. The real value we create comes from finishing, which is a skill in itself and a skill that you can only build through practice!
Mistake 5 - Binary In The Repo
Source code repos are for source code. Binary files do not belong in them. It should be possible to re-create the binary from the source code so there is no need for the binary. Equally it’s not obvious from a binary if the current binary is built from the current version of the code or an earlier one.
Make sure the .gitignore for your repo includes the binaries / build / dist directories. Let your tools do the hard work for you!
Request for Feedback
I’m writing these coding challenges and this new from the challenges series to help you develop your skills as a software engineer based on how I’ve approached my own personal learning and development.
What works for me, might not be the best way for you - so if you have suggestions for how I can make these challenges more useful to you and others, please get in touch and let me know. All feedback greatly appreciated.
You can reach me on Bluesky, LinkedIn or through SubStack
Thanks and happy coding!
John
P.S. If You Enjoy Coding Challenges Here Are Four Ways You Can Help Support It
Refer a friend or colleague to the newsletter. 🙏
Sign up for a paid subscription - think of it as buying me a coffee ☕️ twice a month, with the bonus that you also get 20% off any of my courses.
Buy one of my courses that walk you through a Coding Challenge.
Subscribe to the Coding Challenges YouTube channel!