DEV Community

Cover image for What coding concept or practice seem commonly understood, but you never learned?

What coding concept or practice seem commonly understood, but you never learned?

Ben Halpern on March 21, 2022

Let's say you work independently and you get by, but maybe you're a little afraid that if someone were looking over your shoulder you might be exposed — even if you're a senior dev?

Collapse
 
sherrydays profile image
Sherry Day

git rebase — I barely understand how to use it, and really hope nothing goes wrong.

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀 • Edited

Imagine a literal tree 🌲 like that.

Now get a saw and cut a branch off

Next change the colour of the leaves of this branch to purple 💜

Next take your glue and climb up 🌲 the tree, and stick it right on the tip.

Where you cut the branch off, go there and paint some bark over it like it never happened but actually pretend it was always at the top

The base is the tree branch

You are re base ing the branch at the top of the tree, I think of it as magical time travel

Collapse
 
thumbone profile image
Bernd Wechner

Except that this picture explains nothing to me about what happens. It begs questions:

  1. What is a commit? Is it a diff? Or is it a whole copy of the repo?
  2. If it's a diff, how is rebasing it at the tip different to merging it there, I mean essentially it works fine if there are no conflicts if the diffs can automatically be applied without any ambiguity, but if not ... all the same merge issues arise.
  3. If it's not a diff, what does this rebase do to the tip and the (new) next commit. How do they relate, what's going on?

You see the confusion I (and I expect many) have around rebase is not the nice imagery of what it means (moving a branch somewhere else) it's the devil of the detail, about what happens to the changes between the point of divergence and the tip of both the branch being rebased and the place it's being rebased to.

Thread Thread
 
fjones profile image
FJones • Edited

For simplicity's sake, you can consider a commit a diff to the commit before it (called the "parent"). How git actually works under the hood is a fair bit more complicated (it actually stores blob data of specific states), but that's the surface-level workings.

When you merge, you're creating a new commit that applies the necessary changes to the two commits that are being merged together (the target branch's current commit, as well as the source branch's current commit). Here, again for simplicity's sake, you can consider that merge commit to be two diffs, one on either side, which produce the new merged state.

Rebase instead takes the diffs from the oldest divergence between the two branches, and moves them onto the current commit of the target branch. For that, it applies the same diff onto the current commit as its new parent (instead of whatever was the original parent), changing (ideally) only the parent relationship of the commit.

Thus, where a merge maintains two different routes which converge in the merge commit, the rebase maintains only one route to the same target state. This means that either of the merge commit's parents have their own parents until they reach back to the divergence, whereas the rebased branch only has a single line of parentage going first to the other branch's most-recent commit, which itself then has the parentage back to the original point of divergence (which is now no longer related to the rebased branch directly at all).

So where merge glues two sticks together in parallel, the rebase glues them together in sequence.

Edit: re what the actual differences are after-the-fact, operationally: if you go back to an earlier commit, it will only follow its own parent relationships. So if you check out a commit specifically on either of the merged branches, you won't have the changes from the other branch. As for conflicts, you do indeed get them either way, though rebase makes it a tad easier to ensure that an individual commit is consistent and can, for example, compile correctly for the expected state at the time. Rebase often cuts the conflicts into smaller chunks that are somewhat time-coded to the commit it is currently working on, before moving to the next in the rebase chain.

Thread Thread
 
adam_cyclones profile image
Adam Crockett 🌀

I appreciate your wanting to get technical and I do see your point of view, but my little story is for people who have literally no idea what to think about rebasing, it's what I think about it and I do it all the time with no major fires for almost 5 years of rebasing 🔥🚒🚨. The details you crave and I suspect may know, are best learned / shown not told. Like can you describe an interactive rebase? It's not very easy on paper or in a comment text box ☺️

What I would say is that it offers a jumping off point to allow people to talk about things they would otherwise not know how to find the words

Thread Thread
 
adam_cyclones profile image
Adam Crockett 🌀

Thanks for helping FJones!

Thread Thread
 
fjones profile image
FJones

Was slightly confused there for a minute, thought the other comment was directed at me :D

DEV still can't handle deep threads too well.

Thread Thread
 
adam_cyclones profile image
Adam Crockett 🌀

It confuses me too 🤣

Collapse
 
erickgonzalez profile image
Erick

Love it. Thanks.

Thread Thread
 
adam_cyclones profile image
Adam Crockett 🌀

Your most welcome, of course as it's been highlighted it's more complex than said but I think that's need to know

Collapse
 
spo0q profile image
spO0q

The relevant usages are pretty rare and rebase can be risky, so, in doubt, not using it might be wiser.

It's not uncommon to set it as a global pull strategy (which is the same as git pull --rebase) to prevent useless merges of the same branch in the git history every time you pull the remote branch for updates (e.g., "merge master into master").

However, I would not recommend git rebase between different branches unless you perfectly know what you're doing (e.g. git rebase master develop). Otherwise, it can turn really nasty. I've already seen it, really hard to resolve.

I find the interactive rebase git rebase -i more helpful and less risky provided you use it only locally BEFORE pushing anything to the remote. It allows reorganizing and editing commits, which can improve readability.

Collapse
 
thumbone profile image
Bernd Wechner • Edited

I'm not sure anyone understands git rebase. Every single time someone mentions it I am back to the tutorial pages and it'll cost me some minutes of reading before, if I'm lucky I go "a ha, I think I get that".

Collapse
 
leob profile image
leob

Lol that's one I have to look up EVERY time to understand how it works again ... used it a few times, once it went horribly wrong, not using it anymore every since ... plain "git merge" is your friend!

Collapse
 
dinerdas profile image
Diner Das

Raise your hand if you only use print statements for debugging.

Debugging tools — not even once.

Collapse
 
ben profile image
Ben Halpern

raise hand

Collapse
 
marcello_h profile image
Marcelloh

I admit, I do use that from time to time, only if the "normal" way of debugging is out of the question. But a debugger can really be of help, if you can step through code you didn't write for example. Then you understand what flow the program does and why "x" is suddenly 4. or when you can immediately go to the function with line where the error occurred, and start your investigation from there.
(A stack-trace might be helpful too, and some debuggers do share this info with you)

Collapse
 
thumbone profile image
Bernd Wechner

Nah, browser debugging tools are your friend. Just plain awesome.

Collapse
 
shoeib_shargo profile image
Shoeib Shargo

Present, sir.

Collapse
 
anitpeter8 profile image
anitpeter8

glad i am not alone

Collapse
 
leob profile image
leob

For me that's only the case for Javascript debugging - any other language that I use, I don't have an issue using a debugger.

Collapse
 
calsch profile image
CalSch

🤚

Collapse
 
kayis profile image
K

Estimation 😭

Collapse
 
webbureaucrat profile image
webbureaucrat

He said "commonly understood" not "entirely impossible." 🙃

Collapse
 
jonrandy profile image
Jon Randy 🎖️

I wouldn't worry too much about that. It's not worth doing, a total waste of time

Collapse
 
marcello_h profile image
Marcelloh

Yeah, like you want a house to be build and pay them by the day. How long is it going to take.
"we don't know" is not a valid answer. Estimation is very handy in order to start the process, or not.

Thread Thread
 
jonrandy profile image
Jon Randy 🎖️

When was the last time you had a remotely reliable estimate from a builder? 😂

Collapse
 
marcello_h profile image
Marcelloh • Edited

Estimation is always a bit of a challenge because you might need to do something you've never done before. So estimating that is based on your own experience.Which can be hard if you have never done something before. But based on what you have done can be helpful in finding out a rough estimation, which is of course better than saying that you don't know.

Look for known facts:
You (don't) know

  • the "surroundings"
  • similar parts
  • if it is done by others before
  • if it is complex

Give all of these a score. based on that score, give an estimation, but with the context why you came to that score / estimation.
If it still is hard, see if you can slice it into smaller pieces and do this piece by piece.
But in the end it's an estimation, right? So if you deliver in that time, should not be the question.
Also, estimate for yourself, if you have 10% or 25% ready. Then multiply that to a 100%. Keep track of the next 10% or 25% and see if you're still on schema. If not, tell and adjust your estimation. (and so it becomes more accurate in the end, but also along the way).
Good luck :-)

Collapse
 
booleanhunter profile image
Ashwin Hariharan • Edited

Oh, there's a lot of things I'd be uncomfortable with doing, if someone were looking over my shoulder:

  1. CSS: Not when I'm using a library, but when I'm using just regular CSS, especially when writing styles that are supposed to be pixel-perfect and responsive. I have considerably improved in CSS in the last one year but I'm still not confident enough.
  2. Regexes
  3. Doing a search on the CLI, especially when debugging server logs. Or using Bash terminal commands like tail, chmod, ps, grep etc

If someone is staring at my screen when I'm doing the above, the pressure to not make mistakes can be overwhelming. 😅

Collapse
 
ben profile image
Ben Halpern

Oh man, +1 on the CLI – my array of terminal commands is pretty limited.

Collapse
 
leob profile image
leob • Edited

Regex - beyond the really basic ones I have to look them up EVERY time - in practice when there's a simple way to do a task without a regex, I'll do so ...

Collapse
 
nishrico0098 profile image
Nishant Mishra

Totally Agree! Especially when it is your Nerd Sibling aka Brother/Sister

Collapse
 
ben profile image
Ben Halpern

Personally, having worked from home for years now — there are a lot of things you just only learn when in a physical space with people.

Collapse
 
leob profile image
leob

Examples?

Collapse
 
andypotts profile image
Andy Potts

How to make small talk

Collapse
 
matpk profile image
Matheus Adorni Dardenne

Dependency injection. It always rubbed me the wrong way.

Collapse
 
darthbob88 profile image
Raymond Price

Yeah, I understand the basic concept of passing dependencies in as a parameter, but the frameworks for doing that are always too magic for my taste.

Collapse
 
matpk profile image
Matheus Adorni Dardenne

Exactly how I feel. I know how to use it, but it feels............ wrong.

Collapse
 
marcello_h profile image
Marcelloh • Edited

it is a good way of not hard-wiring dependencies into parts of the code.
That code should work independently, which makes testing far less complex.

To explain it a bit more:
we want to travel so we take a vehicle to do that.
the vehicle should be able to steer, break and so on.
As a dependency, I give it a car to work with, and the vehicle is now a car and does satisfy its needs, but a plane, a truck, a bike etc. also can do that.
To actually test the software for "the break()" function, you can feed it a mocked-vehicle, that will help you in testing the behaviour. But you can also choose to have a "real" vehicle, up to you.

But if you wrote it by just accepting a car, then that's all it can work with.

Collapse
 
matpk profile image
Matheus Adorni Dardenne

SOLID, specifically the "L", implies that a function that requires a "vehicle" must work with cars, bikes, and planes without breaking the application. Dependency injection is not needed.

Collapse
 
drmikecrowe profile image
drmikecrowe

Amen

Collapse
 
kachidk profile image
Nwanguma Victor

same too

Collapse
 
auroratide profile image
Timothy Foster

Caching. When's it automatic, when do I invalidate it myself, why is this asset not refreshing, what are all these cache headers, something something redis??

Collapse
 
ben profile image
Ben Halpern

Oh man, caching is bad because every layer of the stack uses it in some way, so people use the same word to refer to a lot of different things happening.

It's a general-purpose computer science-y idea, so it would make sense that it's used in a lot of places, but then in web dev we generally mean very specific things in different contexts as well.

So yeah, it's a thing.

Collapse
 
warwait profile image
Parker Waiters

I installed a bunch of starter plug-ins in my editor when I first got started and haven't added another one since. I'm pretty sure I'm doing some stuff really unproductively. My flow works, but I'm pretty sure I'm doing it wrong.

Collapse
 
theaccordance profile image
Joe Mainwaring

The last time I encountered this type of question it was around 100% Code Coverage.

I had several years of exposures to tests but our team and products didn't fully embrace the strategy; I wasn't seeing the value in terms of code quality, rather just a check that what you wrote isn't broken upon a later revision.

After our company was acquired, the new engineering org embraced a standard of 100% code coverage. That is a very high bar, and we do allow exceptions, but overall the team has been able to meet that standard with ease.

With our projects having 100% code coverage, we saw improvements in Frequency of Deployments, Lead Time for Changes, MTTR, and Change Failure Rate (Read the book Accelerate if you're unfamiliar with these metrics), ultimately allowing us to build a product at scale - in terms of collaborators (~50 engineers) and deployment stability/consistency.

Collapse
 
marcello_h profile image
Marcelloh

Unfortunately, 100% code coverage doesn't say much if done the wrong way.
We aim as high as possible, but the complex code before the simple code.
And anything added should be covered by a test.

Collapse
 
theaccordance profile image
Joe Mainwaring

Read the book I reference in the original comment, if your engineering org adopts those practices, 100% code coverage makes a significant difference.

Thread Thread
 
marcello_h profile image
Marcelloh

Which book is that. Tried to find you book reference, but can't find it.
BTW: if we write a test for a simple getter (or for generated code for that matter), that will be the day that all other significant tests are written :-)

Thread Thread
 
theaccordance profile image
Joe Mainwaring

Accelerate

Collapse
 
hassnainabass profile image
Hassnain Abass • Edited

redux in react

Collapse
 
jensmou profile image
Jens Mouridtsen

All the files needed is confusing indeed. Take a look at Redux Toolkit. I find it much simpler to use. Still not super easy, but better.

Collapse
 
odysseaspapadimas profile image
Odysseas Papadimas

Most of the time I find the Context API to be enough. That said I used Redux Toolkit once and it was pretty cool

Collapse
 
maxart2501 profile image
Massimo Artizzu

Big-O notation.
I didn't graduate in CS, so I never had the chance to learn it academically. And while I could have taken some time to learn it on my own, in my everyday job it's not really that important to aim for the best performance.

It's not like I couldn't see common performance pitfalls, mind you. But if you ask me to compute the big-O value of a function, it's very possible I could be wrong.

And sometimes it bit me when doing Advent of code challenges.

Collapse
 
bugmagnet profile image
Bruce Axtens

Today it hit me hard that I still haven't quite got my head around async/await and Tasks in C#. With 3rd party libraries all going the async direction, I'm getting even more behind than I usually am.

Collapse
 
tinussmit profile image
Tinus Smit

Same here. They always say it's as simple as adding async / await in your method, but I always seem to get stuck at a method that just has no logical async-ness to it. Then, do I just add an

await Task.Delay(100);

to make it async just for the sake of it?

Collapse
 
bugmagnet profile image
Bruce Axtens • Edited

How about this?

           Task task = GoogleWebAuthorizationBroker.ReauthorizeAsync(
                userCredential,
                CancellationToken.None
            );
            task.Wait();
Enter fullscreen mode Exit fullscreen mode

which seems to be how to make an async Task act in a sync way(???) The Wait appears to mean "wait (that is 'block') until the Task has finished."

Collapse
 
m0nm profile image
m0nm

Design patterns since iam using JavaScript the functional way

Also async/await. Sometime they're simple sometimes they aren't

Collapse
 
dagr8 profile image
DAGr8

I failed so bad at it ended up setting global var and settimeout

Collapse
 
darthbob88 profile image
Raymond Price
  • Multi-threading; I can copy'n'paste other people's work, and sometimes change it, but I can't write it myself.

  • Web animations; I can write very basic transitions for like moving from one location to another, but I can't do anything complex.

  • (Large) System design and architecture, particularly WRT the cloud. I can build and run small projects, but anything big enough to make money off of is beyond me.

Collapse
 
twigman08 profile image
Chad Smith

Honestly a couple, but one that was mentioned already but always confuses me is caching.

Like I get it and know what it is all about. But how do you always make sure people see the latest info on something when they NEED to see the latest info? Then how do you make sure and even handle people that are experiencing a cached version of something and not the latest version? Can’t just tell everyone to force reload without cache.

Every time I think about caching I just get so overwhelmed with it and overthink it.

Collapse
 
tinussmit profile image
Tinus Smit

Unit Tests. It comes from years of inheriting code that did not follow proper OOP guidelines, and thus not easy to write tests for. When entire swaths of business logic sits behind Button1_Click in Blah.aspx.cs, then there's just no easy way to introduce testing.

I've since learned that it's easier to put such logic in a Class Library project, and I even sometimes just have an additional Console Application that references it and I can easily step through without all the manual steps of the UI. I understand the concept, but I just don't have the practical experience 😅

Collapse
 
nicm42 profile image
Nic

Recursion. When I read about it I understand it, then forget everything 5 minutes later.

Collapse
 
dagr8 profile image
DAGr8

Read(something){
something.forget;
Read(something);
}

Collapse
 
hello10000 profile image
a

memoization

Collapse
 
atulcodex profile image
🚩 Atul Prajapati 🇮🇳

CSS Positions

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

10 years on... SQL 😱 please don't tell anyone

Collapse
 
dagr8 profile image
DAGr8 • Edited

/me googles all the things. /me using self made cheat sheet /me not know why he should be uncomfortable copy paste anything wether its an ssh cmd or git cherry-pick head tilden 2. So yea im not. But if any dev would see me coding live they would have a blast watching how lazy I can be googling for getAttributeBysomething[something=something] or if rhe areayname goes first or last in pregmatch strpos etc

Collapse
 
jpoly1219 profile image
Jacob Kim

Looking up how to manipulate strings.

I swear to god I've done it so many times and yet I always seem to forget xD

Collapse
 
odysseaspapadimas profile image
Odysseas Papadimas

For suuure, I usually remember them but I definitely google them more than I should

Collapse
 
k_penguin_sato profile image
K-Sato • Edited

CSS Grid Layout.........😢

Collapse
 
dagr8 profile image
DAGr8 • Edited

Grid aera is so fun its all u need and pretty easy

Collapse
 
pavelloz profile image
Paweł Kowalski

TypeScript. I fail to see a profit in obfuscating the code so much for better linting.

Collapse
 
qureshi81 profile image
qureshi81

Javascript Document object model.

Collapse
 
oricohen profile image
OriCohen05

Meaning of pseudo code

Collapse
 
marcello_h profile image
Marcelloh

invented to make something complex more understandable without the burden of being totally syntactically correct.

if I would write a part in real code, and make one typo, probl. 50% of the people is complaining about "it doesn't compile" instead of getting the idea behind it.

Collapse
 
dagr8 profile image
DAGr8 • Edited

Favorite thread ever

Collapse
 
rajvirsingh1313 profile image
Rajvir Singh

Design Patterns, they are little hard to understand but when you understand them. It is like when you have hammer everything looks like a nail.

Collapse
 
highcenburg profile image
Vicente G. Reyes

CSS and ReactJS in general 😆