TIL (about the Dark Arts of HTML)
-
@remi said in TIL (about the Dark Arts of HTML):
And if you've broken this into methods and each of those methods takes the 8 variables as arguments (because if I'm using those 8 variables across 300 lines, that's because I need them), you have the exact same problem. Shorter functions won't help you.
Write some good code, maybe.
-
@Magus said in TIL (about the Dark Arts of HTML):
Write some good code, maybe.
Which doesn't say anything about whether it has long or short functions. I'm glad you're finally getting it.
-
@remi said in TIL (about the Dark Arts of HTML):
@Gąska said in TIL (about the Dark Arts of HTML):
reading carefully from beginning to end is the only way to be sure what value any given variable holds (or should hold).
Meh. With a proper IDE, highlighting all uses of the variable takes one click.
That's when values are hardcoded. What if they are based on other variables? What if they also are based on yet other variables? Often you really can't make it out without going through entire function.
Of course you can end up in the same mess with tiny methods - a sufficiently large class is indistinguishable from global state. Then you have what you talk about - jumping around the file across methods to make sense out of everything.
So yeah, if it's defined at the very start, then reused for many different things during the life of the function, you're going to have trouble following it. But again that's a readability issue (and horrible code in the first place), not a length issue (if the variable really needs to be used in all those places, then having small function would have the same issue since the variable would be passed to all of those).
Functions, like types, are tools. They're there to help you. And they help in similar ways - just like types restrict at compilation level what kinds of values you have to deal with, putting an upper limit on how many situations you need to handle, functions restrict the scopes and lifetimes of variables, putting an upper limit on how many things you need to remember at once when analysing chunks of code. Of course you can end up with very similar code without using either, but why not help yourself?
-
@remi said in TIL (about the Dark Arts of HTML):
Yeah, but that's what comments are for, no need to make a new function. What I dislike about using functions in that case is that it breaks the flow of reading. It's no longer up-to-down, line after line, but suddenly it's jumping to here and there, and when you keep doing that, at one point you get lost in your browsing history, so to speak. A linear single function makes it easier to back-track.
e_no_repro in IntelliJ, ctrl-click to open a method, mouse back button to go back to where I was.
-
@boomzilla said in TIL (about the Dark Arts of HTML):
But...you don't have less code. You actually have more (because you have the code, plus you have to call all the bits of code that you've moved out of the single function).
But since you can unit-test a small method easier than a giant method, once you've got the concrete building blocks for your previously giant method you can retool it as needed to meet changing specifications without changing large amounts of code.
-
@remi said in TIL (about the Dark Arts of HTML):
And if you've broken this into methods and each of those methods takes the 8 variables as arguments (because if I'm using those 8 variables across 300 lines, that's because I need them), you have the exact same problem. Shorter functions won't help you.
If each giant operation uses all 8 variables, then obviously you use discretion and don't refactor the whole thing. But if you have a bunch of operations in sequence, and each only uses one to two of the variables, then refactoring out into functions definitely makes cleaner code.
-
@pie_flavor said in TIL (about the Dark Arts of HTML):
mouse back button to go back to where I was.
Today I reLearned I have mouse side-buttons I could be putting to good use.
I've mapped the back button to Ctrl+Win+Tab and the forward button to left-drag.
-
@remi said in TIL (about the Dark Arts of HTML):
When you look at existing code, it's not just because you suddenly decided you'd like to read that code. It's because you're tracking a bug (or want to modify some behaviour), and when that happens, suddenly you're going to find out that actually your function name isn't telling you what happens if there is a null pointer in there, or a list with a single element, or whatever other edge case you're in
Assume functions work until proven otherwise. Inspect variables as you go and if they're not unexpected carry on to the next line. If they are then you've narrowed down your search to that function
-
@Gąska said in TIL (about the Dark Arts of HTML):
That sums up GDB experience of everyone I know who has ever used GDB.
In my case, it's probably something subtle since I've got custom builds of a lot of tools. Since I've also got lldb (which works) it's not too big a deal.
-
@remi said in TIL (about the Dark Arts of HTML):
they don't reduce the overall amount of code
That depends really on whether introducing the function exposes a better code surface. Sometimes it does, and that makes it a good decision, but merely being a place where you can cut the code in two doesn't make it a good place to do such a cut. It's far more important to have good conceptual integrity to each function than it is to limit the number of lines (or any other arbitrary metric).
Arbitrary metrics are easier to measure. But they can only ever be canaries for detecting trouble, not actual things that should be followed religiously.
-
@pie_flavor said in TIL (about the Dark Arts of HTML):
@boomzilla said in TIL (about the Dark Arts of HTML):
But...you don't have less code. You actually have more (because you have the code, plus you have to call all the bits of code that you've moved out of the single function).
But since you can unit-test a small method easier than a giant method, once you've got the concrete building blocks for your previously giant method you can retool it as needed to meet changing specifications without changing large amounts of code.
That doesn't follow at all. More granular tests should help you spot where you broke something when you made a change, but that's a different thing. But again, you're likely to have to change more code, not less. Again, because you have more code. So, for instance, instead of changing a few lines, you still have to change those lines, but maybe also a function signature and all the places it's called.
-
@pie_flavor said in TIL (about the Dark Arts of HTML):
e_no_repro in IntelliJ, ctrl-click to open a method, mouse back button to go back to where I was.
Maybe you're an über-mensch and can keep track mentally of where you are, but me, after going back and forth a few times in a call structure of 10 functions nested into each other, I get lost and can't remember whether I have to go back two times or three to get back to where I was, nor into which function I was when I saw that crucial bit of information that I need to remember to understand what happens next. To me, it's just adding one more thing I need to keep track of in my head, and that makes things more difficult, not less. By comparison, those same methods written into a single one mean I just need to scroll a bit up or down, and my screen always shows a lot of context around the few lines (i.e. the equivalent to a single short function) that I'm currently looking at.
(also, an analogy here might be quotes in posts... there is a reason we usually keep quotes when replying, even when we could just say "just click the link on top of my post to see what I'm replying to". The same cognitive principles are at play when looking at code.)
But if you have a bunch of operations in sequence, and each only uses one to two of the variables, then refactoring out into functions
definitelyin my opinion makes cleaner code.There is nothing absolute about this. A bunch of tiny functions shown in random order in the source code (because obviously the order in which functions are written in the file don't matter) are to me much less readable than a single function that gathers them all and shows them in the right order. Which, again, shows that smaller functions is not necessarily better (cleaner, more readable...).
(and again, yes you can make it cleaner, but my point is not that short functions are always bad, just that they are not always good)
That you might prefer it is perfectly fine, but this is a matter of individual preference and case-by-case.
-
@remi said in TIL (about the Dark Arts of HTML):
also, an analogy here might be quotes in posts... there is a reason we usually keep quotes when replying, even when we could just say "just click the link on top of my post to see what I'm replying to". The same cognitive principles are at play when looking at code.
-
@boomzilla now his obsession with Discourse suddenly makes sense!
-
It's all in the gut!
-
-
@boomzilla if you go to the article, you can read that the duo in question is that asshole in the back facing away from camera, and this sucker who's about to get slammed into ground.
-
@Gąska Actually the duo is Herakles and some giant
But really the "unlikely duo" is the art teacher, the nerdy guy grinning on the left of the picture in the onebox, and the wrestling coach being thrown by the assistant wrestling coach (who presumably did something to insult the art teacher, and whose name will be left off the paper)
-
Under the article:
I very much do.
-
@Gąska
I would never trust those you would also like links before you know it you are knee deep in guacamole
-
https://www.yahoo.com/lifestyle/secret-reason-why-people-hide-210314472.html
What’s strange is that the custom supposedly derives from Germany, where it’s called Weihnachtsgurke (which literally translates to Christmas Pickle), and yet it doesn’t seem to be particularly popular there.
In 2016, YouGov polled 2,057 Germans and found that 91 percent were unaware of this mysterious gherkin. Instead, the holiday tradition enjoys its greatest popularity in the American Midwest, which was initially settled largely by German immigrants
As a descendant of Germans immigrants to the American Midwest, I've never heard of this before.
-
@boomzilla
I think Yahoo got taken by a Rick&Morty subreddit or 4chan board...
-
@boomzilla said in TIL (about the Dark Arts of HTML):
As a descendant of Germans immigrants to the American Midwest, I've never heard of this before.
I'm half-German and I live in the Midwest and this is news to me, too.
-
@boomzilla said in TIL (about the Dark Arts of HTML):
Weihnachtsgurke
Must be false. A word like that can't be German when it appears far too short to describe what the pickle is actually for.
-
-
@Zecc said in TIL (about the Dark Arts of HTML):
@mott555 said in TIL (about the Dark Arts of HTML):
I'm half-German
You're a man.
I'm a G
eir!
-
@boomzilla said in TIL (about the Dark Arts of HTML):
https://www.yahoo.com/lifestyle/secret-reason-why-people-hide-210314472.html
What’s strange is that the custom supposedly derives from Germany, where it’s called Weihnachtsgurke (which literally translates to Christmas Pickle), and yet it doesn’t seem to be particularly popular there.
In 2016, YouGov polled 2,057 Germans and found that 91 percent were unaware of this mysterious gherkin. Instead, the holiday tradition enjoys its greatest popularity in the American Midwest, which was initially settled largely by German immigrants
As a descendant of Germans immigrants to the American Midwest, I've never heard of this before.
I've heard of it — I think I even have a pickle somewhere among the Christmas ornaments I've not yet found in storage — but only fairly recently. Well, recently in that it wasn't a tradition in my family, which has German heritage in many branches, but as an adult. I think I heard of it from my then-wife; I don't remember whether it was something in her family, or just something she heard about and thought sounded fun.
-
Selecting part of a post and pressing "Reply" automatically quotes that bit.
-
@kazitor without formatting.
-
@Gąska Hm, so it doesn't.
-
-
@pie_flavor which doesn't let you quote at all. Unless you put a hefty dose of original content. Or padding text for the sake of having text.
-
-
@pie_flavor now, click "Reply".
-
@Gąska What, and spam someone else's thread? What will that accomplish?
Also, I just realized that the first response by someone other than me to a thread was to check compatibility with two of my plugins. This makes me immeasurably happy.
-
@pie_flavor said in TIL (about the Dark Arts of HTML):
@Gąska What, and spam someone else's thread? What will that accomplish?
Show that you can indeed do what I said you cannot. Or show that you indeed cannot do what you said you can. Because that video shows nothing.
-
Imagine that, forum software that someone actually sat back and designed instead of adding features willy-nilly C++ style.
-
@pie_flavor it looks like you still have to do ugly hacks exploiting bugs in the parser if you want to do basic stuff! It's good to know nothing changed on that front. Though it seems the hacks get uglier and uglier.
What happens when you post 3389dae361af79b04c9c8e7057f60cc6?
-
@Gąska said in TIL (about the Dark Arts of HTML):
@pie_flavor it looks like you still have to do ugly hacks exploiting bugs in the parser if you want to do basic stuff! It's good to know nothing changed on that front. Though it seems the hacks get uglier and uglier.
I assume you're referring to the markdown inline link hack? That's what I use here too, so there's nothing to compare to.
What happens when you post 3389dae361af79b04c9c8e7057f60cc6?
-
@pie_flavor so they fixed that too. Awesome! Though I wonder what else they've broken in the process.
-
@pie_flavor said in TIL (about the Dark Arts of HTML):
@Gąska said in TIL (about the Dark Arts of HTML):
@pie_flavor it looks like you still have to do ugly hacks exploiting bugs in the parser if you want to do basic stuff! It's good to know nothing changed on that front. Though it seems the hacks get uglier and uglier.
I assume you're referring to the markdown inline link hack? That's what I use here too, so there's nothing to compare to.
-
@pie_flavor yes there is.
-
TIL why plastic screw caps have this rubber circle inside, and that peeling it off before finishing the drink isn't a good idea.
-
@boomzilla said in TIL (about the Dark Arts of HTML):
https://www.yahoo.com/lifestyle/secret-reason-why-people-hide-210314472.html
What’s strange is that the custom supposedly derives from Germany, where it’s called Weihnachtsgurke (which literally translates to Christmas Pickle), and yet it doesn’t seem to be particularly popular there.
In 2016, YouGov polled 2,057 Germans and found that 91 percent were unaware of this mysterious gherkin. Instead, the holiday tradition enjoys its greatest popularity in the American Midwest, which was initially settled largely by German immigrants
As a descendant of Germans immigrants to the American Midwest, I've never heard of this before.
Wrong!
-
TIL that Russian word for cooking ingredients is "ingredienty". I find it particulary weird because it feels like a fairly basic words, and most of basic Russian words
were stolen fromsound very similar to Polish. But not here. For whatever reason, they ignored our "składniki" and went with cyrillization of Latin.
-
@Gąska there's only so many little things infesting the letters a language can stand.
-
@pie_flavor said in TIL (about the Dark Arts of HTML):
Imagine that, forum software that someone actually sat back and designed instead of adding features willy-nilly C++ style.
Where?
-
-
-
@pie_flavor said in TIL (about the Dark Arts of HTML):
@Gąska said in TIL (about the Dark Arts of HTML):
@pie_flavor yes there is.
what?