Summary of Clean Code by Robert C. Martin
Source: gist.github.com/wojtekluCode is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility, and maintainability.
General rules
- Follow standard conventions.
- Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
- Boy scout rule. Leave the campground cleaner than you found it.
- Always find root cause. Always look for the root cause of a problem.
Design rules
- Keep configurable data at high levels.
- Prefer polymorphism to if/else or switch/case.
- Separate multi-threading code.
- Prevent over-configurability.
- Use dependency injection.
- Follow Law of Demeter. A class should know only its direct dependencies.
Understandability tips
- Be consistent. If you do something a certain way, do all similar things in the same way.
- Use explanatory variables.
- Encapsulate boundary conditions. Boundary conditions are hard to keep track of. Put the processing for them in one place.
- Prefer dedicated value objects to primitive type.
- Avoid logical dependency. Don’t write methods which work correctly depending on something else in the same class.
- Avoid negative conditionals.
Names rules
- Choose descriptive and unambiguous names.
- Make meaningful distinction.
- Use pronounceable names.
- Use searchable names.
- Replace magic numbers with named constants.
- Avoid encodings. Don’t append prefixes or type information.
Functions rules
- Small.
- Do one thing.
- Use descriptive names.
- Prefer fewer arguments.
- Have no side effects.
- Don’t use flag arguments. Split method into several independent methods that can be called from the client without the flag.
Comments rules
- Always try to explain yourself in code.
- Don’t be redundant.
- Don’t add obvious noise.
- Don’t use closing brace comments.
- Don’t comment out code. Just remove.
- Use as explanation of intent.
- Use as clarification of code.
- Use as warning of consequences.
Source code structure
- Separate concepts vertically.
- Related code should appear vertically dense.
- Declare variables close to their usage.
- Dependent functions should be close.
- Similar functions should be close.
- Place functions in the downward direction.
- Keep lines short.
- Don’t use horizontal alignment.
- Use white space to associate related things and disassociate weakly related.
- Don’t break indentation.
Objects and data structures
- Hide internal structure.
- Prefer data structures.
- Avoid hybrids structures (half object and half data).
- Should be small.
- Do one thing.
- Small number of instance variables.
- Base class should know nothing about their derivatives.
- Better to have many functions than to pass some code into a function to select a behavior.
- Prefer non-static methods to static methods.
Tests
- One assert per test.
- Readable.
- Fast.
- Independent.
- Repeatable.
Code smells
- Rigidity. The software is difficult to change. A small change causes a cascade of subsequent changes.
- Fragility. The software breaks in many places due to a single change.
- Immobility. You cannot reuse parts of the code in other projects because of involved risks and high effort.
- Needless Complexity.
- Needless Repetition.
- Opacity. The code is hard to understand.
That sounds like spam. I’ll report just in case.
AI-made aliens of all kinds and sizes. I wouldn’t mind recreating the cantina scene from the original Star Wars trilogy by walking into a bar and, in real-time, using deepfake technology to transform everyone into a random alien species from Star Wars.
You must have made that up, there’s not even a definition on Urban Dictionary.
Also, is this a hobby or a kink, because it reminds me of kinks like chastity, plapping and such.
Wow, finally I figured that out, thank you.
The locations, free falling and such.
Extreme Ironing
Wow, I bet they don’t even bother warning their sexual partners about it. I wish I had never learned that.
This is only the second time I’ve heard about it. The first time, someone was talking about worm composting (vermicomposting), which uses worms to convert organic waste into nutrient-rich compost.
You are right, but gooning is a kink rather than a hobby as well and you didn’t mention it to the poster of the most voted comment.
pick up artistry, penis enhancement, prejac training
Yeah, some people share their entire drives, so the people who share system files are likely to have their private files there as well.
That’s just a modern term for jerking off, I don’t think it’s niche or weird, I just don’t get why it’s gotten so popular calling it that way.
I stalk random people on the Internet
I like watching people on the internet. 15y ago, I was using Shareaza, Kazaa, Emule as my music sources. For those who aren’t familiar with those software: it’s p2p file download. You install Shareaza on your computer, and give access to specific folder to the Shareaza network. Anyone using Shareaza can then download the files located on your shared folder. But, in the mid 00’, even more than today, people weren’t that tech savy and what happened, way too often, was that a user would give access to the “My Documents” folder or even worse, their whole computer. I was looking for those thoses and I was reading their MSN messenger history, looking at their pictures, their resume, their schoolwork… I was really enjoying learning everything about their life through their My Documents folder.
Fast forward to 2018. All those p2p software disappeared. But I found an alternative: 4shared. 4shared allows you to upload pictures and share them (like img). When you download the app, you can setup the app to automatically upload all your pictures (from your phone). But a lot of users don’t know that, and they end up with all they smartphone pictures on the net, with a public settings. I enjoy going to 4shared, looking for those non savy users, and learn everything about their lifes.
And I don’t even need that. I have hobbies, friends, I don’t have issues meeting women or people, but I like stalking on those strangers on 4shared.
I tried this, it got banned.
I checked some of the forums in the link (https://nodebb.fediverse.observer/list) you posted, but it’s hard to tell what most of those NodeBB instances are actually for: many lack descriptions and the forum names don’t say much. I would have to read a few posts in each forum to figure out what each one is for. I found a literature forum but it only has three posts, I don’t want to make an account just to shout into the void, so I’m trying to post to it from Lemmy.
I tried posting to the literature community I found via Lemmy but the post never showed up on the NodeBB instance. I used Lemmy’s search with the target community URL (https://community.darkscribes.com/category/2/general-discussion), it found the community, and I created a post from Lemmy (https://lemmy.dbzer0.com/post/54997372). I can see the post on Lemmy but not on the target NodeBB instance. Any idea why that might be or how to get Lemmy posts to appear on federated NodeBB forums?
I think moderating tags is the same as moderating any other content. If there’s a brigade, you can revert all tag changes made by the brigading users the same way you remove content posted by a user when banning them. That said, the moderation system could be improved. Reddit-style moderation is one of the biggest jokes on the internet.
You don’t seem to get my point. For a platform to let me reliably filter a whole topic, the majority of posts need to be tagged with that topic first. Reddit/Facebook don’t do that, they have communities and loose categories, not consistent topic tags across all posts. Twitter only partially does it with hashtags, and hashtags are neither comprehensive nor applied consistently. I’m talking about platform-level, booru-style or collaborative tagging so blocking a tag actually removes the tagged content without me having to unsubscribe from dozens of communities or build giant keyword lists.