Davy Jones
- 29 Posts
- 34 Comments
Davy Jones@lemmy.dbzer0.comOPto Programming@programming.dev•Which software design principles do you rely on most?1·22 hours ago
Davy Jones@lemmy.dbzer0.comOPto Programming@programming.dev•Which software design principles do you rely on most?1·22 hours agoSummary 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.
Davy Jones@lemmy.dbzer0.comOPto Selfhosted@lemmy.world•How much time and money would it take to set up and maintain a server similar to disroot.org, offering the same services, for a group of ten people?English8·23 hours agoThat sounds like spam. I’ll report just in case.
Davy Jones@lemmy.dbzer0.comOPto Photon@lemdro.id•Any Lemmy web clients that show notifications from multiple accounts at once?English21·24 hours agoThat’s pretty much what I’d like. So no idea if there are any clients with that functionality?
Davy Jones@lemmy.dbzer0.comtoShowerthoughts@lemmy.world•We'll be seeing an uptick in UFO sightings soon71·1 day agoAI-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.
Davy Jones@lemmy.dbzer0.comOPto Ask Lemmy@lemmy.world•What's the weirdest hobby you've heard of?5·2 days agoYou 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.
Davy Jones@lemmy.dbzer0.comOPto Lemmy@lemmy.ml•Lemmy should support multiple default languages for posting and viewingEnglish2·2 days agoWow, finally I figured that out, thank you.
Davy Jones@lemmy.dbzer0.comOPto Lemmy@lemmy.ml•Lemmy should support multiple default languages for posting and viewingEnglish1·2 days agodeleted by creator
Davy Jones@lemmy.dbzer0.comOPto Ask Lemmy@lemmy.world•What's the weirdest hobby you've heard of?12·2 days agoThe locations, free falling and such.
Davy Jones@lemmy.dbzer0.comOPto Ask Lemmy@lemmy.world•What's the weirdest hobby you've heard of?8·2 days agoExtreme Ironing
Davy Jones@lemmy.dbzer0.comOPto Open Source@lemmy.ml•Shouldn’t Forgejo private repositories be encrypted?83·2 days agoNo? It doesn’t seem to be a use case they target.
The problem is that making a repository private makes users think their data can’t be seen so they may upload that kind of information.
If you want to use git to store sensitive data, you should encrypt it before committing / pushing it.
I’ll look into that.
Davy Jones@lemmy.dbzer0.comOPto Ask Lemmy@lemmy.world•What's the weirdest hobby you've heard of?4·2 days agoWow, I bet they don’t even bother warning their sexual partners about it. I wish I had never learned that.
Davy Jones@lemmy.dbzer0.comOPto Ask Lemmy@lemmy.world•What's the weirdest hobby you've heard of?5·2 days agoThis 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.
Davy Jones@lemmy.dbzer0.comOPto Open Source@lemmy.ml•How do I install Element (Matrix) on Android?71·2 days agoThe circular symbol on black background looks like the many ChatGPT clones.
Davy Jones@lemmy.dbzer0.comOPto Ask Lemmy@lemmy.world•What's the weirdest hobby you've heard of?2·2 days agoYou 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.
Davy Jones@lemmy.dbzer0.comOPto Ask Lemmy@lemmy.world•What's the weirdest hobby you've heard of?11·2 days agopick up artistry, penis enhancement, prejac training
Davy Jones@lemmy.dbzer0.comOPto Ask Lemmy@lemmy.world•What's the weirdest hobby you've heard of?7·3 days agoYeah, some people share their entire drives, so the people who share system files are likely to have their private files there as well.
Davy Jones@lemmy.dbzer0.comOPto Ask Lemmy@lemmy.world•What's the weirdest hobby you've heard of?161·3 days agoThat’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.
Davy Jones@lemmy.dbzer0.comOPto Ask Lemmy@lemmy.world•What's the weirdest hobby you've heard of?401·3 days agoI 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.