|
Sistergodiva posted:public static String URL_SEPARATOR = "/"; Some people never met a string literal that shouldn’t be a constant.
|
# ? Feb 11, 2023 04:14 |
|
|
# ? May 13, 2024 03:51 |
|
a dingus posted:Following Clean Code is better than nothing if you're a beginner just at the point where you can create spaghetti code and have no strong opinions of your own. Once you get some experience you'll start to find examples of the book falling apart, but by then you know the rules well enough to know when to break them. If you're already a working dev then I'd read the book and let the ideas float around in your head but don't be dogmatic about anything. Granted I don't have a recommendation but is there nothing more up to date for today's beginners?
|
# ? Feb 11, 2023 04:35 |
|
prom candy posted:Granted I don't have a recommendation but is there nothing more up to date for today's beginners? ChatGPT
|
# ? Feb 11, 2023 05:11 |
|
prom candy posted:Granted I don't have a recommendation but is there nothing more up to date for today's beginners? maybe The Pragmatic Programmer, I'm not sure I'd call it more up to date but it has better advice
|
# ? Feb 11, 2023 05:25 |
|
As long as we're comparing straw men, I'd rather work with someone who takes Clean Code too far and out of context than with someone who thinks that readability is a naïve fantasy. Beginners are going to be wrong, but it matters what motivates the errors.
|
# ? Feb 11, 2023 06:11 |
|
I think you completely misunderstand the criticism of the book. When someone says "Clean Code is bad", they mean that the book is bad and does not teach you to write clean code, not the concept of readable code does not exist.
|
# ? Feb 11, 2023 06:27 |
|
Yeah I haven't read the book but the example the goon posted above the "clean" refactor is worse than the original code. I went through a phase of writing code like that and it's not easy to work with. The rigid adherence to DRY and short methods means you end up with a lot of weird/bad abstractions and splitting one perfectly good 8 line function into two 4 line functions that have no real reason to be separate.
|
# ? Feb 11, 2023 06:53 |
|
thotsky posted:Clean code as a phenomenon is more destructive than the book itself. A lot of teams will treat it as a Bible, even though a bunch of stuff in it is obviously bad or outdated advice. I never meet these developers. Instead I get the ones who see a 100 line function and go "well making it 120 lines won't hurt"
|
# ? Feb 11, 2023 09:08 |
|
Mega Comrade posted:I never meet these developers. Instead I get the ones who see a 100 line function and go "well making it 120 lines won't hurt" It might not. I don't mind a deep function. I do mind putting those extra 20 lines in another few lines of function boilerplate somewhere else, when it is only going to be called from that original function anyway.
|
# ? Feb 11, 2023 09:52 |
|
Doom Mathematic posted:Clean Code is like a recipe book where about half of the recipes will give you food poisoning. And fans of the book all say that it's actually not the recipe book writer's job to make sure that all the recipes are safe, it's the reader's job to read the recipe book carefully, and then make their own decision about which recipes will or won't give them food poisoning. Which is especially funny as a defense when the reader is a complete beginner who doesn't know how to cook at all and they're reading the book in order to learn.
|
# ? Feb 11, 2023 12:07 |
|
That's why vscode has a minimap. Maybe you could add some cool large ASCII title for different parts to spot them on the map? Maybe it's because of old-school web dev origins, but it seems like a lot of people I know really don't like breaking up things in different files etc. React components is helping because it's more obvious what should be split. Does vscode have an easy way to navigate to the definition of a function? In intellij I can just ctrl-click and navigate to it. Wouldn't survive without that, especially when you can navigate to a third party library to see the implementation. From what I see from colleagues searching and moving around in vscode seems a bit bad, but it could also be them not knowing how to do it properly.
|
# ? Feb 11, 2023 12:13 |
|
One of our first developers (no longer with us) was a Clean Code fanatic. I just refactored one of his services and reduced the number of lines literally 75%. Probably the most satisfying PR I've ever submitted. The "domain logic" module was full of one-line functions that just passed the arguments to another function. And that was only one layer out of four with most of the layers having just one or two lines. In the end I flatted it to one layer and most of the functions are still only about 4 lines. I'm sure that kind of strict architecture helps in a complex app but in this simple service it made it super tedious to trace what was supposed to happen.
|
# ? Feb 11, 2023 13:55 |
|
Sistergodiva posted:Does vscode have an easy way to navigate to the definition of a function? In intellij I can just ctrl-click and navigate to it. Wouldn't survive without that, especially when you can navigate to a third party library to see the implementation. F12 is the default for jump to definition IIRC Also ctrl-p is nice for fast navigation between files
|
# ? Feb 11, 2023 14:08 |
|
I'm always suspicious when folks talk about writing "easy to read" code because I've met folks for whom that just means they don't understand stuff unless they wrote it. Easy to read requires metrics, and short is not necessarily the best metric.
|
# ? Feb 11, 2023 14:38 |
|
taqueso posted:maybe The Pragmatic Programmer, I'm not sure I'd call it more up to date but it has better advice This is the book I was thinking of too. Better than clean code.
|
# ? Feb 11, 2023 14:42 |
|
Code Complete is good too, but it’s also a doorstop of a book.
|
# ? Feb 11, 2023 14:46 |
|
lifg posted:Code Complete is good too, but it’s also a doorstop of a book. It has a whole chapter on how to structure your if statements. (It's actually a useful chapter) It's a good book, definitely worth skimming through, but I don't think anyone has read it completely, including the author.
|
# ? Feb 11, 2023 14:54 |
|
prom candy posted:Granted I don't have a recommendation but is there nothing more up to date for today's beginners?
|
# ? Feb 11, 2023 17:14 |
|
the best thing you can do for today's beginners is to have read these things yourself and to provide practical demonstration of their good parts with code review.
|
# ? Feb 11, 2023 17:25 |
|
Uncle Bob is an alt-right creep, about what you would expect from someone whose entire identity is about playbooks for clinging to your dogma
|
# ? Feb 11, 2023 19:25 |
|
Based on this discussion it looks like a lot of my assumptions about programming best practices are either outdated or misinformed. I think I’ll load these recs up and review what I think I know.
|
# ? Feb 11, 2023 19:36 |
|
Take a look at The Programmer's Brain. I'll copy their blurb rather than try to summarize it myself:quote:Your brain responds in a predictable way when it encounters new or difficult tasks. This unique book teaches you concrete techniques rooted in cognitive science that will improve the way you learn and think about code.
|
# ? Feb 11, 2023 19:42 |
|
My take away is that good code is like pornography. I can’t explain it but I know it when I see it.
|
# ? Feb 11, 2023 19:56 |
|
Hughlander posted:My take away is that good code is like pornography. its on the screen on my work computer from 9am to 5pm
|
# ? Feb 11, 2023 21:29 |
|
I read Clean Code at a really unfortunate time in my career and became an insufferable zealot for its advice for a year or two after that. If you worked with me during that time, sorry! That said, it did get me to think about things I hadn't considered before, and now that I'm a lot older and can apply critical thinking and nuance to it, I'm glad I have those ideas to consider. Nowadays I think that it'd be a lot more valuable to just take its table of contents as a starting point for a team discussion about standards and maybe some experimentation than to actually read the whole text. Also yeah Bob Martin is a shithead which may or may not be of concern to you re: giving him money.
|
# ? Feb 11, 2023 21:49 |
|
Yeah you shouldn't be buying clean code in 2023. There are various github repos with snippets of all the actual good bits in it for free.
|
# ? Feb 11, 2023 22:02 |
|
It would be great if college programming courses just had people submit PRs and then the professors commented on them and the students had to respond and fix their stuff. I assume this is nothing like what is actually done even now. (When I went to school, we had to email programs to the professor and I guess they just ran them? It was ancient times.)
|
# ? Feb 12, 2023 01:42 |
|
A lot of it's done with autograders now. That's not ideal but the demand for CS education pretty far outpaces the supply of people who can take a more hands-on approach and are willing to do so for an academic paycheck.
|
# ? Feb 12, 2023 02:12 |
|
My alma mater created the CS department as an outgrowth of the math department, and IMHO it really, really shows even today. Source control? Pull requests? Practical applications? Wake up, you're having a bad dream, I don't know what you're talking about but you have some Formal Proofs of Algorithm performance to hand in!
|
# ? Feb 12, 2023 03:05 |
|
smackfu posted:It would be great if college programming courses just had people submit PRs and then the professors commented on them and the students had to respond and fix their stuff. The dude whose book is often recommended as an alternative to Clean Code (although the book is not really a close equivalent) does exactly that, and talks about it in this talk: https://youtu.be/bmSAYlu0NcY
|
# ? Feb 12, 2023 03:22 |
|
I just realized I was thinking of Code Complete this whole conversation, not Clean Code.
|
# ? Feb 12, 2023 06:38 |
|
smackfu posted:It would be great if college programming courses just had people submit PRs and then the professors commented on them and the students had to respond and fix their stuff. (of course good luck getting any phd-haver over the age of 40 to do this) This worked in the grad-level classes that I took but I could imagine it's trickier in undergrad classes: in my experience nobody learns how version control works until upper-level classes, which means that for the first half of one's degree you haven't been taught the background to use git (and/or the faculty member doesn't know how it works either) Dijkstracula fucked around with this message at 16:39 on Feb 12, 2023 |
# ? Feb 12, 2023 16:36 |
|
I had a class where your grade was based entirely on presenting the code you wrote and basically doing an in-person code review of your homework. This was an absolute shitload of work for everyone involved and required a big pile of TAs so it was pretty obvious why it wasn't a normal way to do things, but it was incredibly valuable. This was before pull reviews and async code reviews had become standard industry practice, so adopting that would maybe make it scale better.
|
# ? Feb 12, 2023 17:08 |
If you wanted to do the code review process in school it might be best to have the students do a fair chunk of the reviewing themselves. Learning to code review is just as important of a skill and helps learning. Since all things in school have to get tied to grade you could probably make the grading equal parts between how good your initial code is, how well you do on you on reviewing others, and how well you do at responding to reviews.
|
|
# ? Feb 12, 2023 17:31 |
|
StumblyWumbly posted:ChatGPT Helper functions can be incredibly helpful in making code more organized, readable, and maintainable. They can also make it easier to reuse code and reduce the amount of duplicated code in a project. However, there are also times when helper functions can be harmful and make code less readable and maintainable. Here are some guidelines for when to use helper functions: 1. When a block of code is used repeatedly in different parts of a program, it's often a good idea to encapsulate that code in a helper function. 2. When a block of code performs a specific, well-defined task that is separate from the main logic of the program, it's also a good candidate for a helper function. 3. When a block of code is complex and would make the main logic of the program more difficult to understand if it were included inline, it's also a good idea to extract that code into a helper function. On the other hand, it's harmful to use helper functions when: 1. When a helper function is so small and simple that it doesn't add much value in terms of readability and maintainability. 2. When a helper function is used in only one place, it might be better to simply include the code inline. 3. When the purpose of a helper function is not clearly defined or its behavior is not immediately obvious from its name, it can make the code harder to understand. In general, the goal of using helper functions should be to make code more readable, maintainable, and reusable. If a helper function doesn't achieve these goals, it may not be worth the added complexity that it introduces into the codebase.
|
# ? Feb 12, 2023 19:34 |
|
Anyone want to buy my software development book written completely by ChatGPT?
|
# ? Feb 12, 2023 19:35 |
|
I have definitely read worse.
|
# ? Feb 12, 2023 21:19 |
|
Function-local helpers are great even when called in one place only, because you can give them a semantic name.
|
# ? Feb 13, 2023 07:49 |
|
So my company is switching to "Shapeup" . Anyone got any experience with this, I've read the shapeup doc on it. And mostly seems sensible although I have concerns about this company actually sticking to some of the principles, mainly not pulling Devs of work cos some minor bug has been reported by a customer with a lot of clout.
|
# ? Feb 13, 2023 23:20 |
|
|
# ? May 13, 2024 03:51 |
|
I figured most people would have bailed from that idea after the writer’s conservative views caused a huge blowup at Basecamp, and then DHH went even farther than Ryan did in public. caused plenty of consternation in the Rails community and placed plenty of doubt whether any of their management books are actually good or were followed internally https://www.theverge.com/2021/5/3/22418208/basecamp-all-hands-meeting-employee-resignations-buyouts-implosion
|
# ? Feb 13, 2023 23:36 |