DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 963,673 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Jose Tomas Gonzalez
Jose Tomas Gonzalez

Posted on

What little things make you happy while coding?

I must say refactoring code to make it look beautiful is my guilty pleasure

Top comments (92)

Collapse
 
alainvanhout profile image
Alain Van Hout • Edited on

Deleting code.

(The context here being: working with problematic legacy code and getting to the point where you have new code (paths) that do(es) the same thing but without the issues, so that the old code, and its issues, can just be discarded)

Collapse
 
ben profile image
Ben Halpern

Yes!

Collapse
 
ejbroeders profile image
EJBroeders

Agreed!

Also, deleting code you wrote earlier in the project because you've made a more general applicable implementation, hence the old code isn't used any longer.

Collapse
 
alainvanhout profile image
Alain Van Hout

Yeah I saw that as included in the previous, since I don't see 'legacy code' as inherently being 'code written by somebody else' :-).

Collapse
 
zx8754 profile image
Tokhir Dadaev

When we come up with this kind of comments:

//When I wrote this, only God and I understood what I was doing
//Now, God only knows

I would suggest just comment out codes rather than delete (or have versioning in place).

Collapse
 
alainvanhout profile image
Alain Van Hout

I see some kind of VCS as a baseline project requirement, and in that case commenting out code is a very big anti-pattern.

And even without it, should an obsolete version of a codepath forever remain in your codebase, even long after it's become sufficiently inconsistent as to be irrelevant?

Collapse
 
buinauskas profile image
Evaldas Buinauskas

Or deleting old code that just exists, is no longer used!

Collapse
 
bizzy237 profile image
Yury

yes. I've been deleting a lot of unused code recently and it feels so good. except for that moment when you realize that the code you deleted is used in another module but this is not documented anywhere

Collapse
 
themulti0 profile image
Multi

ikr

Collapse
 
rommik profile image
Roman Mikhailov

oh so true...

Collapse
 
carlitosx profile image
Carlitos-X

Yep... This too XD

Collapse
 
ben profile image
Ben Halpern

If I have momentum on something and I'm locked in with my ideal monitor setup I feel like Batman at his dashboard. So much power at my fingertips.

When things aren't going so smoothly:

Collapse
 
chrisvasqm profile image
Christian Vasquez

I'm a big fan of both having a calm + non-interrupted refactoring session or discussing with colleagues about alternatives of how to implement something or just naming conventions to plan to use.

Collapse
 
lewismenelaws profile image
Lewis Menelaws

The pleasure of finally being able to get it or to make something work. Having all those tabs open to just have them closed is some of the best feelings ever... Especially when it looks like this:

Collapse
 
jitheshkt profile image
Jithesh. KT

True story. Pleasure of clicking on "close tabs to the right" 😁

Collapse
 
yokim profile image
Yokim Pillay

The good-old picket fence!

Collapse
 
yanhan profile image
Pang Yan Han • Edited on
  • Refactoring code to make it look good
  • When new code works on the first try and passes all the tests
  • Putting into practice knowledge that I've recently acquired
  • When I finally "get" something that I've been using but don't understand in depth
  • Reading good code written by others and getting mindblown by what I've learnt from them
Collapse
 
davidhbeck profile image
david

+1 for the last one. I've been working as a junior/front end dev on a freelance project with a C#/asp.net developer who has 12 years of experience. Reading his code and studying it until I understood how all the functions worked was a complete game changer!!

Collapse
 
nektro profile image
Meghan (she/her)

It doesn't happen often because there's usually a catch when it does, but when code works the first time, I get really giddy :D

Collapse
 
moopet profile image
Ben Sinclair

I usually feel extra nervous...

Collapse
 
databasesponge profile image
MetaDave πŸ‡ͺπŸ‡Ί

Yes, if all the tests pass immediately, that's a moment to step back and think reaaaaalllll hard.

Collapse
 
bardware profile image
Bernhard DΓΆbler

True. The feeling when you write code and the computer does what you intended.

Collapse
 
andy profile image
Andy Zhao (he/him) • Edited on

I really like writing code comments, although I don't do it too often. I'm still learning how to make them meaningful first.

Collapse
 
gonzalezanguita profile image
Jose Tomas Gonzalez Author

I was taught that you should not use comments. To avoid comments your code should be written in a way that can be read like a comment.

I wrote a little article showing the difference of code that needs comments and other that it doesn't.

Collapse
 
6temes profile image
Daniel • Edited on

There are comments and comments. The comments explaining what the code does are usually a symptom that the code is convoluted and difficult to understand even for the person who is writing it.

On the other hand, there are comments like:

# This solves a bug in the library Fubar that prevented the Baz 
# from being executed. See: https://github.com/fu_bar/baz/issues/454

Or:

# Temporalirly removed as per request in Issue #1243

Those make perfect sense to me.

Thread Thread
 
slavius profile image
Slavius • Edited on

Works very well in commit messages when you have Bitbucket integrated with Jira. Hell of a difference!

Collapse
 
ethan profile image
Ethan Stewart

A lot of truth to this, but an exception can and should be made when something merits an explanation of why it is the way it is. Comments should be few and far between in well-written code, but still used when there's an actual need. For me that's usually just when I had to dig to find a way to make something work when a more intuitive solution wouldn't work in that specific case.

Thread Thread
 
gonzalezanguita profile image
Jose Tomas Gonzalez Author

Indeed, some business concerns are just impossible to explain by code itself and as you've said, logic that by some black magic doesn't work.
The key is to know if comments are up-to-date with the code as refactors come and go and not everyone updates the comments.

Thread Thread
 
ethan profile image
Ethan Stewart

With this I fully agree, that's something I've been trying to improve on myself.

Collapse
 
moopet profile image
Ben Sinclair

While I agree with not using comments where the code can demonstrate its own purpose and mechanism, I don't like absolutes like "don't use comments". An RFC number or something can be very helpful, or a link to where you found the code you just copy-pasted.

Collapse
 
thinkhuang profile image
Third_Thinker

So am i.While i agree with Jose Tomas that try to make your code self-interpretation as possible.I'm trying!

Collapse
 
aurelkurtula profile image
aurel kurtula

I read Stephen King's book On Writing, he described the development of the story as carving something out of stone. You just start hammering the hell out of the block then it just starts resembling an image (something like that).

My reaction was "Haha, that's what I do when I write code"

Only when I read that book I realised that that might be the reason why I don't look forward to finishing projects - hammering away is fun.

I love working on the heavy parts.

Collapse
 
rhymes profile image
rhymes

Refactoring, getting rid of code, Visual Studio Code that sometimes does magical stuff, having tests passing and how easier things are now that I'm using a 24" inch monitor again instead of the Macbook's 13" :D

Collapse
 
ethan profile image
Ethan Stewart

I absolutely love getting to build things from the ground up. Some of my favorite things I've done at my job were things I had to start from scratch. I enjoy most coding tasks, even fixing bugs, but my favorite by far is seeing a feature or product I helped make with no code to start out with.

Collapse
 
eljayadobe profile image
Eljay-Adobe

An office with a door, so I can focus.

My guilty pleasure is I enjoy fixing bugs. Each bug is like a mini-puzzle, and (usually) is apparent whether or not it is fixed or still broken.

Two large monitors. And I'm super particular about keyboards. (IBM Model M forever!)

Clean code makes me happy. I wish there were refactoring tools for C++, like I had JetBrains ReSharper for C#.

The one surprise I had was how much I enjoyed TDD using C#, NUnit, and the awesomely amazing test-runner NCrunch. I really miss that now that I'm back in C++.

Endless supply of Diet Mountain Dew.

Collapse
 
rhymes profile image
rhymes

Love fixing bugs too!

If it's not a trivial bug you usually learn A LOT chasing a bug. Sometimes you end up with patches to third party libraries, sometimes you end up with more insight about the framework or the language or even parts of your own code you forgot about :D

Collapse
 
eljayadobe profile image
Eljay-Adobe

My two favorite bugs was finding a bug in the compiler (can't remember which compiler anymore, too many years ago - I'm sure it was not GCC), and finding a bug in the gdb debugger.

Thread Thread
 
rhymes profile image
rhymes

so "meta" :D

Collapse
 
cjbrooks12 profile image
Casey Brooks

Lining stuff up vertically. Whether it's the values in key->value literals, wrapped method parameters, class members, or anything else, everything is just so much nicer to look at when it's all lined up vertically.

Collapse
 
mikerg profile image
mikerg

Getting a pull request merged

Collapse
 
jackharner profile image
Jack Harner πŸš€

Just had my first one yesterday and holy shit I'm still riding that high.

Collapse
 
zx8754 profile image
Tokhir Dadaev
Collapse
 
erikthered profile image
Erik Nelson

Fixing up brittle, archaic tests so that they're fast and much easier to follow and iterate on.

In general just getting things to a more maintainable state for the future (probably due to joining teams where the codebase I have to grok is nearly impenetrable).

DEV has this feature:

Settings

Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. πŸ›