165 points
*

Refactoring is something that should be constantly done in a code base, for every story. As soon as people get scared about changing things the codebase is on the road to being legacy.

permalink
report
reply
44 points

Been with a lot of codebases that had no unit tests at all and everyone was afraid to change anything because the QA process could take weeks to months.

The result is you have a codebase that ages like milk.

permalink
report
parent
reply
29 points
*

Only if the code base is well tested.

Edit: always add tests when you change code that doesn’t have tests.

permalink
report
parent
reply
3 points

And also try to make tests that don’t have to change if you refactor in future (although there are some exceptions)

permalink
report
parent
reply
13 points

Doesn’t everybody agree with this? I really never thought of it as a hot take.

permalink
report
parent
reply
15 points

I highly doubt most corps do

permalink
report
parent
reply
5 points

Corps != people.

People just pass the buck and nobody stands up for what is most correct

permalink
report
parent
reply
8 points

Today I removed code from a codebase that was added in 2021 and never ever used. Sadly, some people are as content to litter in their repo as they are in the woods.

permalink
report
parent
reply
8 points

Our company motto is: “leave it cleaner than you found it”

permalink
report
parent
reply
3 points

Who is in the wrong? Your manager, for not giving you time to refactor? Or you for giving him the option?

permalink
report
parent
reply
7 points

Why do you need time to refactor? It is just part of the work you need to do and should be accounted for when doing any other work. IMO a big mistake people make is thinking refactoring is some separate thing they need permission to do. You don’t, if you need to make a change in some area refactor it first to make it easier to accept your change, then add your change then refactor to clean up. This is not three separate tasks, just three steps in one task. You should be given enough time to do the whole task, not just part of it.

permalink
report
parent
reply
2 points

I guess I need to refactor for readability. What you just explained is the entire point of the comment I posted. Refactoring is part of the job. Don’t give your manager a choice on whether or not it needs done.

permalink
report
parent
reply
2 points

Yes please. Many times when I add a feature I end up refactoring some of the code first to better accommodate it.

permalink
report
parent
reply
1 point

We used to call this ‘Code is Cheap’ at my last job - you’re spot on about the value of it

permalink
report
parent
reply
1 point

thank_you_michael_scott.gif

permalink
report
parent
reply
134 points
*

Until you know a few very different languages, you don’t know what a good language is, so just relax on having opinions about which languages are better. You don’t need those opinions. They just get in your way.

Don’t even worry about what your first language is. The CS snobs used to say BASIC causes brain damage and that us '80s microcomputer kids were permanently ruined … but that was wrong. JavaScript is fine, C# is fine … as long as you don’t stop there.

(One of my first programming languages after BASIC was ZZT-OOP, the scripting language for Tim Sweeney’s first published game, back when Epic Games was called Potomac Computer Systems. It doesn’t have numbers. If you want to count something, you can move objects around on the game board to count it. If ZZT-OOP doesn’t cause brain damage, no language will.)


Please don’t say the new language you’re being asked to learn is “unintuitive”. That’s just a rude word for “not yet familiar to me”. So what if the first language you used required curly braces, and the next one you learn doesn’t? So what if type inference means that you don’t have to write int on your ints? You’ll get used to it.

You learned how to use curly braces, and you’ll learn how to use something else too. You’re smart. You can cope with indentation rules or significant capitalization or funny punctuation. The idea that some features are “unintuitive” rather than merely temporarily unfamiliar is just getting in your way.

permalink
report
reply
36 points

Please don’t say the new language you’re being asked to learn is “unintuitive”. That’s just a rude word for “not yet familiar to me”…The idea that some features are “unintuitive” rather than merely temporarily unfamiliar is just getting in your way.

Well i mean… that’s kinda what “unintuitive” means. Intuitive, i.e. natural/obvious/without effort. Having to gain familiarity sorta literally means it’s not that, thus unintuitive.

I dont disagree with your sentiment, but these people are using the correct term. For example, python len(object) instead of obj.len() trips me up to this day because 99% of the time i think [thing] -> [action], and most language constructs encourage that. If I still regularly type an object name, and then have to scroll the cursor back over and type “len(”, i cant possibly be using my intuition. It’s not the language’s “fault” - because it’s not really “wrong” - but it is unintuitive.

permalink
report
parent
reply
14 points
*

If you only know C and you’re looking at Python, the absence of curly braces on code blocks is temporarily unfamiliar to you.

But if you only know Python and you’re looking at C, the fact that indentation doesn’t matter is temporarily unfamiliar to you.

Once you learn the new language, it’s not unfamiliar to you anymore.

“Unintuitive” often suggests that there’s something wrong with the language in a global sense, just because it doesn’t look like the last one you used — as if the choice to use (or not use) curly braces is natural and anything else is willfully perverse on the part of the language designer.

permalink
report
parent
reply
9 points

“Unintuitive” often suggests that there’s something wrong with the language in a global sense

I mean only if you consider “Intuition” to be some monolithic, static thing that’s also identical for everyone. Everyone has their own intuition, and their intuition changes over time. Intuition is akin to an opinion - it’s built up based on your own past experiences.

just because it doesn’t look like the last one you used — as if the choice to use (or not use) curly braces is natural and anything else is willfully perverse on the part of the language designer.

I don’t think it’s that deep. All people mean when they say it is that “[thing] defied my expectation/prior experience”. It’s like saying “sea food tastes bad”. There’s an implicit “to me” at the end, it’s obvious i’m not saying “sea food factually tastes bad, and anyone who says they like it is wrong or lying”.

permalink
report
parent
reply
6 points

No programming language is “natural/obvious/without effort”.

permalink
report
parent
reply
5 points

You could say that about anything. Of course you have to learn something the first time and it’s “unintuitive” then. Intuition is literally an expectation based on prior experience.

Intuitive patterns exist in programming languages. For example, most conditionals are denoted with “if”, “else”, and “while”. You would find it intuitive if a new programming language adhered to that. You’d find it unintuitive if the conditionals were denoted with “dnwwkcoeo”, “wowpekg cneo”, and “coebemal”.

permalink
report
parent
reply
2 points

Languages also have inner consistency. E.g. the mentioned python len function is inconsistent with the rest of the same language - and that is a statement that is true in itself, without an external reference point.

permalink
report
parent
reply
1 point
*

But there are languages that require varying degrees of effort to become natural. Something like Malbolge will pretty much never be natural while something like Python can become natural to you in a few days.

permalink
report
parent
reply
11 points
*

Idk, I don’t see a problem with saying a new language is unintuitive. For example, in js I still consider the horrible type coercion and the “fix” with the triple-equals very unintuitive indeed. On the flip side, when learning C# I found the multiple ways of making comparisons to be pretty intuitive, and not footguns.

permalink
report
parent
reply
6 points

Please don’t say the new language you’re being asked to learn is “unintuitive”. That’s just a rude word for “not yet familiar to me”.

Yeah. I’ve written in six or so different languages and am using Go now for the first time. Even then, I’m trying to be optimistic and acknowledge things are just different or annoying for me. It doesn’t mean anything is wrong with the language.

permalink
report
parent
reply
4 points

ZZT-OOP is fun to work with though, definitely not meant for doing anything more complex than light gameplay, and yet people have done ridiculous things with it.

Though I personally did most of my coding in that vein in MegaZeux with their Robotic language, which is basically ZZT-OOP++.

permalink
report
parent
reply
2 points

I still think ruby is a bad language, even though I agree with you

permalink
report
parent
reply
2 points

I found ruby horribly confusing until I got over the intial learning bump.

Now I love it. It really is lovely. In terms of design that is. Not sure about the monkeypatching

permalink
report
parent
reply
1 point

I really don’t like how rails brings things into scope and you just have no idea what’s there or how it got there unless you know all of the conventions. I guess that’s a rails issue and not ruby though.

I learned in python and C++ so I’m biased towards things that are extremely specific. Definitely doesn’t mean ruby is necessarily bad, I just don’t like it.

permalink
report
parent
reply
1 point

This is very true! Languages being unintuitive also becomes less of an issue the more languages you look into. There will be many concepts that multiple languages have since ultimately they are all trying to do similar things and the more you learn the more you will recognize making it easier to get into even more languages.

permalink
report
parent
reply
1 point

Until you know a few very different languages, you don’t know what a good language is, so just relax on having opinions about which languages are better. You don’t need those opinions. They just get in your way.

This is wise advice for ANY domain of knowledge.

Lotta people get a little fragment of knowledge on something, then shut down their brain and stop accepting new input. But life is change, and to be able to change and learn new things you need to keep your mind open. Being able to relax on having opinions and keep learning and moving along is very important.

permalink
report
parent
reply
131 points

Dynamic typing is insane. You have to keep track of the type of absolutely everything, in your head. It’s like the assembly of type systems, except it makes your program slower instead of faster.

permalink
report
reply
27 points

Nothing like trying to make sense of code you come across and all the function parameters have unhelpful names, are not primitive types, and have no type information whatsoever. Then you get to crawl through the entire thing to make sense of it.

permalink
report
parent
reply
7 points

I’m not sure that’s a hot take outside early uni programmers.

permalink
report
parent
reply
4 points
*
Deleted by creator
permalink
report
parent
reply
3 points

You can do typing through the compiler at build time, or you can do typing with guard statements at run time. You always end up doing typing tho

permalink
report
parent
reply
1 point
*

I like it in modern PHP, it’s balanced. As strict or as loose as you need in each context.

Typed function parameters, function returns and object properties.

But otherwise I can make a DateTime object become a string and vice-versa, for example.

permalink
report
parent
reply
1 point

What happens when you coerce a string to a date-and-time but it’s not valid?

Where I’m from (Rust), error handling is very strict and very explicit, and that’s how it should be. It forces you to properly handle everything that can potentially go wrong, instead of just crashing and looking like a fool.

permalink
report
parent
reply
1 point

My point is, you won’t ever try. You’d only use “weak” variables inside the function you’re working on.

It’s explicit when you absolutely need it to be, when the function is being called and you need to know what arguments to pass and what it’ll return

permalink
report
parent
reply
99 points
*

If you don’t add comments, even rudimentary ones, or you don’t use a naming convention that accurately describes the variables or the functions, you’re a bad programmer. It doesn’t matter if you know what it does now, just wait until you need to know what it does in 6 months and you have to stop what you’re doing an decipher it.

permalink
report
reply
92 points

Programing is a lot less important than people and team dynamics

permalink
report
reply
-16 points

People can always be replaced, they’re irrelevant.

permalink
report
parent
reply
22 points

The code can always be rewritten, it is irrelevant.

permalink
report
parent
reply
1 point

And it will change next week anyway. 😁

permalink
report
parent
reply
1 point

Sure try to replace the one or two people that hold the whole team together. I’ve seen it a couple times, a good team disintegrates right after one or two key people leave.

Also, if you replace half the team, prepare for some major learning time whenever the next change is being made. Or after the next deployment. 🤷‍♂️

permalink
report
parent
reply

Programming

!programming@programming.dev

Create post

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



Community stats

  • 2.6K

    Monthly active users

  • 1.8K

    Posts

  • 28K

    Comments