
Helloooo! I am Moose! They/Them/He/Him I am a embedded software engineer with autism, depression and anxiaty ( Wooo! ). I post about... whatever I want... software things, mental health things... whatever I feel like Feel very wellcome to send me asks about... anything that strikes your fancy :3
266 posts
Ha Ha!
Ha Ha!
I did it! I got up at 3 AM to start working before going into work at 8 and I managed to do good during the code review!
I managed to teach the apprentice a good chunk of stuff embedded and C++. ( Static_cast, Steongly types enums, rule of 0/5, system clock running backwards and a bit more ) AND I managed to know a few things that my supervisor had not run into before! ( One of which was Godbolt existing... which confuses me, but oh well ).
I also picked up a bunch of good stuff (For example, I realized I was still thinking in terms of microcontrollers and so had not thought about how the fact that main() takes arguments influences the code architecture)
Now my brain is mush but I do not care! It went well! I can do this!
AHHHH!
Have to do a code review of a codebase I have had access to for 2 days... by copy... As in, I do not yet have access to the reposetory, as so cannot build the project... And so none of my tools work on it... Because massive anxiety an autism, and my supervisor asked if it was ok to have it today (Friday), rather than on Monday and so my mouth just said the words it figured the other person in the conversation wanted to hear... I do not have access to the internal communication tools either so... juuuust have to do it..... AHHHHHHHHH! I swear... I am so happy I went on tumblr, because I am just using the "Do it alone, do it scared" as a freaking mantra at this point...
(Also, sorry for not answering people or being super active... I am just focusing as much as I can on this internship)
-
frog707 liked this · 1 year ago
-
moose-mousse liked this · 1 year ago
-
sinnahsaint reblogged this · 1 year ago
-
sinnahsaint liked this · 1 year ago
-
neuroglitch liked this · 1 year ago
-
moose-mousse reblogged this · 1 year ago
-
quietmarie liked this · 1 year ago
More Posts from Moose-mousse
A beginners guide to GIT: Part 4 - How to use GIT as 1 person
Table of content: Part 1: What is GIT? Why should I care?
Part 2: Definitions of terms and concepts

Part 3: How to learn GIT after (or instead of ) this guide.
Part 4: How to use GIT as 1 person

Part 5: How to use GIT as a group.

When it comes to not getting in each other's way, working alone is the simplest (It has a lot of other drawbacks). This is the simplest way to use GIT. You can do it with an external repository as a backup or just locally on your computer. It depends on how important your project is. If your laptop crashes tomorrow, which projects would you have a really hard time losing? Better to have an external backup for that. Github is often used for this (Maybe less now that Github makes machine learning AI’s, and so ARE stealing your code to train their AI on.) but you can also use Bitbucket (Which... may also steal your code...) and there are many many others out there. GIT is often used in certain patterns, called “workflows”. These have you working in more or less rigid ways to make it simple to work together. But since you are working alone, you do not risk others changing your code while you are working, so you can do it the simplest way :D
I will be doing a step by step guide that you can follow along. I will be doing it on a completely empty project and making a tiiiiiny program in C. This is because it is super simple. You do NOT have to know C to follow. You can also follow the steps with your own already existing project.
I PROMISE you, GIT cannot hurt you. Worst case scenario is that you fiddle around and break the repository part. (Meaning the files in the .git folder). But your files will always be safe.
(If you do not have git installed, check out part 3 for that)
First, I make a folder, navigate my shell into it, and call git init:

By the way, you can get used to GIT messages like this that tell you all your options, and explain what GIT has done for you. GIT is very good about giving you as much help and info as possible,
Now I will teach you the most important command in GIT.
It is more important than any other. Ready?
git status

This makes GIT tell you what git thinks is happening right now. What issues there are and what files are tracked, untracked or have been changed. Use this command often, especially while you are new to GIT, run it after every other command. It is how you learn what GIT is doing and thinking :3
Since our repo is empty it tells you what branch you are on (master. The only branch we will need since we are working alone)
and that you have not made any commits.
It also tells you the commands git think you will want to use on files. Since our repository is empty, it tells us to create some files, and then how to add them :3 So let's do that:
I have added my tiny program, as you can see:

Now let us see what GIT thinks we did:

Now, since there have been changes, git shows us them.
Files can be untracked tracked and not changed (In which case, git status does not show them) tracked and changed.
Right now, main.c is untracket. Which basically means GIT have no idea about this file, other than it is in the folder.
Ok, let us commit(save) the file. GIT tells us this is done with git add <File> . So we will write git add main.c
Then we use git status again to see what happened git status

And yeah, our file is now ready to be committed. So lets do it! git commit -m “My first commit!”
The “-m” option is to write the git update explanation directly in the console instead of using an external program to do it. Done You have now committed your code! It is now saved!
git status shows that everything in the working tree is as it was last time we committed (Duh. We JUST committed)

I will now make some changes to the main file:

Git status shows us main.c was changed...but what if we wanted to know what was changed in more detail? How will we get status to do that for us? Let us find out! git help status
git then shows the help page for status And there we can see this part:

So if we write status with 2 -v arguments, we get all the details. Let us try:

And look! It shows us EXACTLY what lines were changed! I stage the changes and commit:

And you have now learning enough about GIT to use it.. You now have all your work saved, in different commits. If you ever want to know all the commits you have made, write git log:

And if you want to know what a specific commit did, you copy the name of the commit, and write git show:

Now, everytime you want to save your work, you
1: Write/change the files you want
2: Add the files you want as part of this commit
3: make the commit These three steps are your workflow.
If you have a remote repository, then you add them steps
4: push to remote repository
To do this step, you can actually just write
git push
If you have set up a remote repository, then it just works. If you have not, then git will tell you what to do Whichever remote repository you use will tell you if you need to do other steps, like setting up passwords or ssh keys. They will also tell you how to set up the remote repository (That is not a GIT thing, that is a bitbucket or a github thing, so refer to whichever of those sites you want to use) And that is all! Every time you commit, your project is saved (it is smart to commit often, but usually only commit when your project can be compiled.) And whether you use a remote repository or not, you now have a fully valid GIT repository, and all the git tricks can be used on your project!
Managers are mostly incompetent
I freaking hate people sometimes. Talked a bit casually with the boss of the software department at my internship. Mentioned that no one is hiring freshly educated software engineers (unemployment is at 12% after a year here). Only ones already working in firms during their study (IE, studying worse because they have to work next to it) gets hired.
This is much like the carpenter firms always bitching that they need more journeymen, while none of them take in apprenticeships. They are complaining about a problem, while THEY are creating the problem. He basically said that he agrees, but that THIS firm do not exclude newbies. But when I asked him how many newbies they hire, he had to admit the number was 0. Because they found better candidates for those jobs you see! He DID not get the point. You NEED to force your firm or industry to to hire freshly educated people as a percentage of new hires. It is called a Ulysses pact, it is NOT a new idea.
If you only judge on a job to job basis who would be best…
Then you will only hire experienced people. Experienced people are basically always better than fresh ones.
So if you do not have a policy in place, you are making a implicit choice to not hire newbies. Choosing not to do something, is STILL a choice. I know systems, software and programming, in order to be a software developer. So why do managers not know basic managing?
So starting a 4 week internship tomorrow...
My info is: Show up at 8:30, and I will help on a project to test a better method for time-stamping sonar data with time from GPS units on boats ( Well, GNSS.)
That... Is all. No clue what languages or what tech stack... protocols... system diagrams...
How did they do it before? If you have GNSS data then... you are pretty much as good as you will get... Nothing beats atmoic clocks in space, which are further calibrated with atomic clocks on the ground...So they did not use GNSS before? Why not?
Like, they know I am uninformed, but... I try to make myself calm by researching and testing stuff ahead of time... So yay massive anxiety.
Oh well... Nothing for it but showing up and doing my best.
Calling by reference in C++ Also known as STOP OVERTHINKING EVERYTHING
So I have now seen a specific type of horrible code from several programmers at my internship who really should know better. The code will look something like this:

And when I ask how on earth they managed to overcomplicate "calling a function" I get the answer "I am calling by reference!" Which... no... no you are not. So, there are two ways to feed arguments to a function. Known as calling by value, and calling by reference. When you call by value, the compiler takes a COPY of whatever you send in, and your function works on that copy. (By the way, that is faster than calling by reference when you need to send in small primitive variables, since playing with a 64bit address is harder than moving the 16 bits an int often is ) What is happening in the... abomination of a function call here, is that they use a shared pointer. And shared pointers are a great tool! It gives you all the safety and easy of use of working in a single thread environment with a statically allocated variable (IE, a variable allocated on the stack) when you are working with dynamically allocated memory in a multi-threaded environment. But when you use it on a statically allocated variable in a single threaded environment... then.... it gives you all the safety and easy of use... that you already had... When I asked why on earth they were doing this to that poor poor pointer, I got told that it was because using raw pointers was bad... Ok... first of all, yes, raw pointers are bad. Not really in of themselves, but because c++ have better tools than them for 99% of use cases... But that is not a reason to use a pointer at all! When I told him he was calling this function by value... just in a really weird complicated way, he disagreed. He was using a pointer! Yes... you are putting in a pointer... which gets copied... And together with the work on creating the pointer and the more complicated syntax of using a pointer... it is just bad. You know how you call by reference? You do it... by calling... with a reference... Not a pointer, a REFERENCE. The hint is in the name! This is the refactored code:

THAT is calling by reference. It is quick. It is clean. It is easy. The ONLY change from calling by value is in the signature. Both from the perspective of someone who uses the function and from inside the function, it works JUST like a call by value. Just like using a pointer, it allows you to work directly on a variable from an outher scope instead of copying the variable into the function. And unlike a pointer, a reference guarantees that whatever you are being feed is instantiated. You can send in a null pointer, you cannot send in a null reference (Well...Technically you can, but you have to work really hard to be able to.) Like... often in programming, the easiest way, that requires the least amount of work, is also often the most efficient and the easiest to maintain... just... just do it simply. I beg of you. Code models reality, and as a result can get really really complicated. So let us keep the simple things simple, yeah? ( By the way, I am grumping at programmers who should know better. When newbies makes weird coding choices, that is simply them learning. That is obviously fine )
A beginners guide to GIT: Part 5 - How to use GIT as a group.
Table of content: Part 1: What is GIT? Why should I care?
Part 2: Definitions of terms and concepts

Part 3: How to learn GIT after (or instead of ) this guide.
Part 4: How to use GIT as 1 person

Part 5: How to use GIT as a group.

For this, I will describe a workflow, called “feature branch workflow.” There are others that are simpler, and are sometimes better, but I will describe one that always works, for any amount of people, and most likely is what your future workplace uses.. And yes, it involves branching (which sounds scary, but it is not so bad.)
Why? Well because of 2 goals we have that somewhat clash.
1: To use GIT in a way that is easy on ourselves and will give us all the benefits of GIT. This means committing often. Pretty much every time we have made a change, and we can compile.
2: We want to sync our work with our fellow workers. But this takes effort every time we do it because we might have made changes that clashes with changes someone else have made.
(Notice though that this is not a problem originating in GIT. This is a problem that comes from people working together on the same thing. GIT just makes it easy to spot the problems and describe them in an accurate way.)
We alleviate this by only syncing up when we have made a larger chunk of self contained work. Usually we use the term "feature" for this. And they can be quite small (For example 4 commits, making a "Return to previous page" button ) or large (For example, 38 commits, which also used branches, to implement a GUI on top of the backend code we have made).
It is best to make features as small as you can, so that a feature branch does not end up being an entirely different sister project to the main branch.
The first thing we do is declare the main/master branch holy. Just like any branch, it must always compile, but now we add " May only have fully realized features". It must ALWAYS be ready to be shown to the customer/your boss/your adviser/your teacher.
So when we want to do some work, we coordinate it with our teammates so people are not working on the same thing, and thus wasting their time. ( This can be done with tickets, verbally at meetings, in group chats. Whichever fits your team )
Then we make a branch with its base at the tip of the main/master branch. We then do work, commit and push every commit onto that branch. This has all the benefits we had from working alone. We cannot get merge conflicts, as we are the only one working on this branch.
So let us show how this works! For this example I have set up a remote repository on bitbucket containing only a standard README that I have not written in at all., I then cloned it down in 2 different directories. Each of which I have opened with a console. This is how I will represent multiple people:

So first, we show off one person making a change, and the other getting it. So I add a main.c file in there, add it so it is staged for commit, and then commit it:

And if we write git status, we can see that we are 1 commit ahead of the remote repository:

We then push our commits to the remote repository:

The other user can now use git fetch (Which gets the latest information from the remote repository, but does not change anything):

We then pull the latest update from the remote repository with git pull:

This is the simple way to work. But of course, if we have changed the same file, we will get a merge conflict.
As we talked about, we will minimize those by using branches. So we will say that each of these two people now will work on a different feature. Each of which will be a function that prints something. And each will be in another c file, with a header. We will do this with branching. We want to make a branch, and then switch to it. Switching to branches is called “checkout”. We can do both in one step by checking out a branch that does not exist, with the option -b (You can as always read about checkout, by writing “git help checkout”)
git checkout -b My_Spiffy_Feature
When we then write git status, we can see that we are on the new branch:

I then add the new files. with the new function in, and we want test that they work by calling the function in main:

We then compile our program (which gets default name a.out) and run it:

It works! Great, time to commit. We add the new files, BUT NOT main.c or a.out . They were just for testing, and is otherwise not related to our feature.

And we then push to the remote repository:

As you can see, git complained, because while we have created our branch, we had not really configured it yet (Specifically, we never told git what branch this new branch should originate from from. We just created it out in the void). But GIT TELLS you what to do. So I simply wrote the recommended command, and bam, branch is working as we want it to
I update the new feature file, just so we have more than one commit. I add the changes, commit and push again:

Now that our feature is done, we want to merge the branch into the master branch.
To showcase something, I will first have the other person make a change to main, add, commit and push it:

The first person will now merge their spiffy new feature in. They do that by switching to the master branch with git checkout:

We see that we are behind 1 commit, so we pull.

But horror! Since we have the unstaged changes, we cannot pull, since we changed main.c to tests our new feature, AND the other person have changed main, those two cannot exist at the same time. So what do we do? Well, in this case, we are ok with our tiny test in main.c being lost. So we remove it like so:

Notice how EVERYTHING I did here, was just read what GIT said was the problem, then write git status, and do the actions that GIT tells me I can do, which solves the problem. Ok, now we have the latest update of the master branch. Time to merge our feature in:

This time I did not use the -m feature (Because I forgot) so I just used the external program to write the commit message.
And if we write git log, we can see every single one of the commits. Both in the branch, and in the master:

And if we want to get a bit of a graphical representation of what happened, we can use git log --graph:

Now, this is the simple way to do branching. You actually have full control over how exactly you want to merge your branch in. In this case, the two commits of the branch was added AFTER the commit on master. But we COULD have merged the branch in so that the two commits on the spiffy function was done BEFORE the changes on master. When you are still starting out, do not worry about this. But that is the workflow. You create a branch, you work on your feature in it, where you cannot get in the way of anyone else. When your feature is done, you merge it into the master. This way, the master was always ready to show to your teacher/boss, and did not have half implemented things that you would have to explain should be ignored at any point.
Half of the benefit of the feature branch workflow is that it minimizes the chance for merge conflicts. For them to happen, 1 group would have to go to the master branch and pull. AFTER they pulled, but before they managed to merge their branch in, another group must pull from master, and merged their feature in.
Unlikely.
But let us talk about merge conflicts.
Are those not horrible things that break everything?
No. Merge conflicts simply means GIT could not figure out how to merge something, and so a human will have to do it for it. GIT is nice, and shows you exactly where the problem is, and how to solve it. Let us create a merge conflict. The first person adds in the function that uses their new spiffy feature after the hello world prinf, stages the changes and commits them. But do not yet push

The other person creates 2 more printf statements in main, stages the changes for commit, and commits them:

Now we have 2 commits, that both changes main.c How should these two be merged? Should the spiffy feature be called before or after the newly added prinf lines? GIT cannot know this, and so will tell the humans to do it. And the job falls to whoever wanted to push in a change that creates the merge conflict. In our example, I will have the second person, who added the extra printf lines push first:

And now the first person with their spiffy feature pushes, and:

It fails... But we are fine. Nothing actually happened here. The remote is still fine, and we locally are still fine. But we have to figure out how to fix this. When in doubt, use git fetch to get all the info but change nothing, and then git status:

(By the way, I made an honest mistake here, and did not push the branch changes after I merged. But I am not really in trouble, because GIT saved me! :D) And as we can see, GIT is once again telling us what to do. Great!

And we are now at the place where we need to decide what to do. While you are still new, I recommend the default strategy. So we do as GIT tells us to:

And now, FINALLY, we have our merge error. But notice that we only got it this way, because we asked for it. So… what does that mean? Git status to the rescue once more!

As expected, the problem is in main.c Let us check out what is in that file:

We have our changes first, then a separation, and then the other changes. And fixing it is piss easy. We remove the lines GIT inserted to tell us where the conflict was, and put the code in order. WE decide if the spiffy feature should be put before, after or in the middle of the two printf statements. I decide to put them in the middle like so:

Merging the two versions together, is in of itself, a change to the code. So we will now do what we always do when we have made changes. Add the files that we changed, and make a commit, and then push:

We have now resolved the merge conflict.
Notice how the problems that we ran into were not GIT problems. We ran into issues that ALWAYS come up when multiple people are working on the same project. But GIT made it really clear what the issues were, and forced us to deal with them in a smart way! :D