I’d like to hear some advice from more seasoned or expirienced devs. I’m not a professional myself and would say i only code recreationally. Until now, i did most of my stuff from scratch, but recently i found myself wanting to change existing Projects.
For the particular thing i’ve selected to look into, i’m having a go at the new Windows Terminal Github Prject
Since this is done by mostly professionals, it’s on a completely different scale than anything i’ve looked at until now. I’m able to clone the Repo and can build/debug it perfectly fine, so i have working code.
How do i tackle something like this? Lets say i want to start with something “easy” and just change something like the color of one element, or the size of something. How would i even start to find the relevant parts in the code? I’m familiar with c++ a bit by having worked on my own DWM fork, but that’s only a few lines of code in comparison.
I have Visual Studio and Code set up and can work through the code, but in most cases, there doesn’t seem to be anything done directly in place and finding where functions, references or variables come from feels nearly impossible without having programmed this myself.
Any good tips on what to focus on and where to look at first to find a certain property, element or function?
What I do at least is: I get a piece of paper and draw a graph of the major “things” and relationships while reading through code at a high level. Not necessarily classes (if OO language). Go through and/or redraw as needed until I think I understand what’s going on. If I have a colleague, I take myself and the graph to him/her, and spend a little while explaining what I learned, and he/she tells me where and if I’m right or wrong about certain things. If I don’t have a colleague, and I don’t have another way to verify, that’s my best assumption of what is going on at the time, usually enough to start doing at least some tasks. I do this whenever I’m tasked to work on something I’m not yet familiar with. Infrastructure and code alike, I do this for both.
The goal I’m trying to reach is getting a visual picture, that is much easier to comprehend. Sometimes I don’t do that to the entire project (system), but bits at the time, depends on how large it is. This is the quickest way for me to get to working. You won’t learn it all at once, though, give it time.
I’m also slowly learning to appreciate new features in Code. For C++ at least it does a really good job of moving in Code. After some time scanning i can look up references with Alt+F12, get definitions and get the corresponding functions in a popup. This helps a lot in understanding what’s going on.
I feel like i know at least which parts of the codebase are even relevant to my Platform. But it’s certainly not easy to grasp.
I’ll take your advice and sit down on Saturday and will try to create a rough outline of what is going where. Thanks for the Input!
Yep was just going to add: That reading consists of observing the components, looking where they are referenced: where created, where interacted with, where destroyed. This gives a good understanding overall, which is the goal. Detailed code comes later.
Reading unit tests is useful sometimes too, they define how application works after all. But they tend to be too detailed, as they deal with concrete component behaviour, if you have higher level tests, that’s a good place too.
Man that project is massive lol. Back in the day I would find “main” and then work from there, but as projects become more complex or larger, I’ve started finding a piece or function and working with it until I know how it works, then moving to another piece or function and working with it until I know how it works. After a few days, a week, or a month you start to get the feel for how it all works together.
Don’t be afraid to ask questions on the community either.
If you install some intellij keybind plugin (witch is how I did it), or change the buttons.
It would then be
ctrl+b to get to what you are looking at
ctrl+alt+b to go to the implementation (if what you are looking at is an interface or abstract method, youd need this to find the implementation of it)
Jetbrains seems to have a bit better shortcuts for actually using the thing. F12 is so far away… and you need that all the time.
Interfaces, abstract classes, inheritence and so forth are also some things you should be very familiar with for larger projects.
Also, keep in mind if you actually wanna commit code to the windows terminal. Microsoft has coding guidelines that you have to read and follow or your code may be rejected even if it works. You might want to have a look at those.
I watched some video about windows terminal at some point. Kinda mind blowing how much time has gone into and how many lines of code their terminal has. When you look at the gnome-terminal in comparison especially. It’s a tiny fish of a codebase if you compare the two.
Just cloned the git repos to verify
(Obviously the bigger one being the windows terminal)
(Lines of code is not necessarily lines of code though, it’s just lines of everything in the repo)
EDIT: actually looks like I goofed in that regard I ended up copying the 1.417 to the lines of code of gnome-terminal. Wow, I should go sleep I guess…
Lines of Code
That is what you get comparing those two repos
with git ls-files | wc -l and git ls-files | xargs cat | wc -l if you wonder how I got to those numbers.
How did you end up with 95 times the lines of code I ended up with for gnome-terminal though? Did I use the wrong repo? I know they have their own gitlab, but I did not doubt the github gnome-terminal, because it had a commit a 5 days ago.
NOTE: Made some random mistake in my calculator before. Copy pasting is hard sometimes.
There’s nothing to do but get on the grind, you got to understand what your peers are doing, and it takes what ever time it takes.(This is what most bosses seems not to understand).
Theres no method really basically you have to read through and understand a 500+ page paper at times, just to change the color of some text.
It does get easier with practice, but understading what you’re doing is the most important part, and if you’re new to it, just be patient.
i think one of my most ever experienced teachers said, coding is a craft, just practice practice, and more practice.