I think the images are inverted

It’s a safe bet that anybody trying that jump over it, through the rails routine is a junior.

I’d like all files to have a big comment on top that says wtf this is, why is it, and roughly how it works. Bonus for ascii art.

My favorite is the ‘here be dragons’ ASCII art, that’s how you know you’re in for a fun time

One of my favorites was along the lines of “An evil wizard wrote this. Attempt to replace it at your peril, but never try to modify it”.

cowsay -f dragon message works great for this.

Spzi
link
fedilink
English
181Y

The obvious solution is to abandon your project not too late; leave on a high note.

I also found it very useful to document every step of my setup procedures, right after I figured out what works. At least the respective CL.

It is well known that as soon as you document a setup procedure, it is out of date and needs redocumenting.

I have a special skill of writing terrible code, not seeing it for half a year, and then remembering exactly what the code did

Could it be the code was so scarring that the pain never left?

runeko
link
fedilink
31Y

I can see that. “This is going to be a problem in the future.” makes it memorable.

That happened to me once. Weird experience. Usually it’s writing terrible code, not seeing it until the next morning and then having no idea what it does.

Demonen
link
fedilink
51Y

There is a “Not from a Jedi” joke in here somewhere. I can feel it.

But what is “clean code”?

As little as possible,I think

When it doesn’t smell

deleted by creator

Never git blame. 9 times out of 10, pretty sure it was me and I forgot

deleted by creator

“Who wrote this shit ?”
Spends 10 angry minutes in P4 timelapse
“Oh…”

Rhaedas
link
fedilink
101Y

There’s no question I wrote the couple of things I’ve done for work to automate things, but I swear every time I have to revisit the code after a long while it’s all new again, often wondering what the hell was I thinking. I like to tell myself that since I’m improving the code each time I review it, each new change must be better overall code. Ha. But it works…

Why was this written like this? It makes no sense. I’ll git blame it and ask them what’s going on. Oh it’s me…

dementia gaming

Depression causes memory loss

That explains a lot… :(

sweats in Gitlens plugin

Gandalf: I have no memory of this place…

Rob
link
fedilink
English
11Y

Me too. But the other day, a junior developer and I were looking at some fairly old code, and I recognized the writing style in the comment as mine. We ran p4 annotate and, sure enough, I was the baddie.

I stated programming games on a school computer in the early to mid 80’s. When the tape drive broke, I still used to have the code in my head, just type it all in for others to play. Now I find code I wrote last month and can’t remember doing it. At least it tends to be, “which genius wrote this” these day. Tend to leave comments everywhere for myself now, including my own name and other messages to myself like,“don’t touch this it works, your bug will be in…”

@Aceticon@lemmy.world
link
fedilink
6
edit-2
1Y

Yeah, I’m about the same age and started noticing my ability to keep everything in memory falling at around the mid 20s. I mean, I’m still probably way better at keeping all manner of obscure details in memory compared to the average person (we exercise that so much in this profession it’s only normal), but it’s below the peak point, not enormously so but it’s kind like having once been a top “athlete”, years later you know you can’t reach that peak performance anymore.

Also once you go through the full life-cycle of enough of your projects (that got shipped and a year or two later you have to pick it up and change it), you kinda figure out that even at peak “performance” you wouldn’t be remembering much from a project from years ago and start adding comments to help you pick it back up and alert you to possible pitfalls you noticed and avoided but forgot all about in the meanwhile.

Fortunally I figured it out long ago that I’ve created a couple of principles around commenting that have repeatedly saved my ass years later: things like documention parameter assumptions in functions, actually writting down the “why we do this” or commenting before the code of especially complex algorithms (I actually design the algorithm to the comment first and only after than code it).

Yes, very similar practices here.

Picard
link
fedilink
11Y

@ProfessorPuzzleCode @Aceticon

Oh ruck. At twenty I could remember the direct way through the Zac Mc.Kracken Mazes. And all the chords of our Bands songs. And all the Beatles lyrics. But heck… no code… now I at least remember the bash scripts…

I started a practice with my team on our wiki. We have a section named the Oamonomicon, since out system is named OAM. Any sort of weird one off request or problem gets documented there. What were the symptoms? What steps did we use to find the problem? Then if we start seeing a pattern of issues, we have a better idea of how to resolve them.

Dandroid
link
fedilink
31Y

Maybe I just haven’t worked at a company long enough for this to happen, but I tend to remember what I previously worked on very well. I am still disgusted by the code I wrote sometimes. But that just means I’m learning and getting better at coding.

When I was a team lead, I was juggling 4 things every day.

Meetings, help a junior, PR a critical system, code a thing.

Repeat every day and after a month, I wouldn’t remember what I worked on the prior month.

Dandroid
link
fedilink
21Y

Yeah, I guess that’s fair. I was a team lead for only like 2 weeks before my project was canceled, and yeah, I remember it being similar. I’m not sure I wrote a single line of code during those 2 weeks, though. I was too busy. Or maybe I did and I don’t remember, but since the project was canceled, it never came back to haunt me.

I am working with an in-house “rapid development team.” They have rigorous intake, story and task break down, scheduling of sprints, QA, definition of done, integration test coverage, E2E and min 90% unit test coverage etc. etc.

They have a strict policy of “no code comments, self documenting code only.” They will go in and remove comments that my DevOps team puts in there, because it screws up that policy.

Luckily, we adopted the policy of having local branches with these comments in place. Once they move beyond the project, we’re putting them in.

The vitriol the “Clean Code” cult has against comments is unbelievable…

too many lines!!!

hoodle
link
fedilink
121Y

That’s silly. I’ve never seen comments even as a way to explain what your code is doing (the code often does do that anyway). It’s important to say WHY you’re doing it the way you are.

That way anyone else who comes in there can have the same context you did when you implemented it, which imo is where most bugs occur. People don’t realize what assumptions you made when it was first written, and then make their own (which can easily clash).

I just love it when people who have no understanding of the purposes, objectives and applicability of various parts of a famous software development process and just follow it in a blind fashion-following way.

And by “love it” I mean “get frustrated to no end even though by now I should know better”.

@AA5B@lemmy.world
link
fedilink
24
edit-2
1Y

They do have a point though. When we’ve gone through phases where the industry focuses on commenting code and other documentation, most of it is useless.

Code comments should have a reason, and are no substitute for readable code.

However you’re also right though that people jump onto “all or nothing”. I recently did a code Review that I held up for comments. In this case, they were doing something very atypical to get around a limitation so it was a clear case of comments needed. The next person through will say “what is this shit?” And “fix” it, without knowing there was a good reason

Having no comments doesn’t force code to be self-documenting. I understand the cult of code extremist, but No-Commenters are just WEAK and PATHETIC wannabes trying to immitate the true, functional extremists, such as the 16-Space-Tabbers

Yeah “why” comments are absolutely fine, “what” comments are useless at best and can be harmful at worst.

I feel like this constant flood of “write comments” posts are from CS students who are told to comment everything by their lecturers. Descriptive variable and function names help explain the “what” of code pretty well most of the time.

Sure with some old languages like C89 where you are limited in your variable name length you probably do need comments to explain wtf is going on, but most code bases aren’t as constrained.

I have this argument with other devs all the time.

Hey, you know this 200 line nested if statement that suddenly returns in the middle of the condition is “7”? Yeah, that needs a refactor or at least a fucking comment.

I get a pull request that adds a log line that reads something like “special case 7 triggered.”.

Shush
link
fedilink
21Y

Plot twist: it was a 7 Boom game.

for i in array_sometimes_we_get_ints_from_upstream_functions_and_need_to_convert_them_to_floats_or_downstream_functions_throw_exceptions: out_array.append(float(i)

An awful lot of people in here talking about automatic comment removal and I … don’t believe it. I think a lot of you are making up stories. Show me proof that a build script removed your comments, because it’s not just bad policy, it’s literally insane. Nobody would do that. Anyone that thought of doing that would spot the folly of doing it within 5 minutes, and immediately stop. GTFO

My favorite part is looking at my ancient code and thinking “Holy hell I don’t remember being that smart. What happened?”

Everyone knows that debugging is twice as hard as writing a program in the first place. So if you’re as clever as you can be when you write it, how will you ever debug it?

Brian Kernighan - The Elements of Programming Style, 2nd edition, chapter 2

A similar phenomenon is knowing you’re going to need to go back and update some older section of code and when you finally get around to it, it turns out you wrote it that way to begin with. It’s like… I didn’t think I knew about this approach before…

Punkie
link
fedilink
41Y

This right here. Plus stuff like “this is the functions section” and “this is the main script” helps make shell scripts more readable because functions have to come first, and if you just want to get to the main point, you can skip the functions section.

“I’m dumber but wiser” - me, hopefully

I’ve had a legit conversation where I just plain said “I copied the component as it was. I would ask the original developer why the thing was implemented that way, but sadly he no longer works here”

@Auzy@beehaw.org
link
fedilink
7
edit-2
1Y

Let copilot do it. Junior developers can now efficiently write useless comments like the rest of us

I’m very much a novice coder, but I often find myself doing the opposite. Write a good comment and let copilot write the actual code.

Yeah I wouldn’t rely on that, especially early in your coding journey. The less external resources helping you the better, so you’re encouraged to problem solve and figure out your own solutions, even if it takes longer.

I definitely rely on documentation more than copilot, since I’ve noticed that the code it writes is only ever as good as your own codebase.

Most of the stuff I code is API wrappers to get arbitrary data into a format our broadcast graphics system can understand. Once all the data structures are properly defined copilot is extremely useful in populating all the API endpoints.

The actual problem solving is getting the data in the first place and morphing it into the correct format.

What was that comment I’ve seen a few times online…? Something like, “This function isn’t used, but commenting it out causes everything to break,” or similar. Anyone know what I’m talking about?

I like it when people rag on their own code in comments. “This line is a kluge but I can’t think of a better way to do it right now.” Comment is dated 10 years ago.

Alien Nathan Edward
link
fedilink
6
edit-2
1Y

`/* Gets CustomerEntity from customer repository by customer ID or throws a customer not found exception */

public CustomerEntity getCustomerEntityById(String customerId){ customerRepository.findById(customerId).orElseThrow(new CustomerNotFoundException()) }`

Lower art is gudim_public on IG. Lots of clever material.

Create a post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
  • 1 user online
  • 120 users / day
  • 257 users / week
  • 744 users / month
  • 3.72K users / 6 months
  • 1 subscriber
  • 1.47K Posts
  • 32.2K Comments
  • Modlog