Davy Jones
- 7 Posts
- 7 Comments
Davy Jones@lemmy.dbzer0.comOPto Programming@programming.dev•Which software design principles do you rely on most?0·5 days ago
Davy Jones@lemmy.dbzer0.comOPto Programming@programming.dev•Which software design principles do you rely on most?0·5 days 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?English10·5 days agoThat sounds like spam. I’ll report just in case.
Davy Jones@lemmy.dbzer0.comOPto Fediverse@lemmy.world•Looking for federated NodeBB instancesEnglish4·13 days agoI 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?
Davy Jones@lemmy.dbzer0.comOPto Fediverse@lemmy.world•A fediverse platform that lets you block whole topics, not just communities?English4·16 days agoI 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.
Davy Jones@lemmy.dbzer0.comOPto Fediverse@lemmy.world•A fediverse platform that lets you block whole topics, not just communities?English51·16 days agoYou 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.
Davy Jones@lemmy.dbzer0.comto Fediverse@lemmy.world•Seeking recommendations for federated Q&A forums on Linux and software issuesEnglish1·18 days agoHonestly, I wouldn’t recommend adding the feature to mark comments as solutions. Websites like StackOverflow often have many answers that aren’t the best marked as solutions, and I believe platforms like Codidact have learned from those mistakes.
Reputation is a key factor that motivates people to contribute answers. However, StackOverflow suffers from over-moderation due to the reputation gained from moderating. I’m curious about how Codidact has addressed this issue.
Instead, consider allowing users to mark questions as solved rather than comments. Implementing a voting system similar to Slashdot, where users can categorize responses as helpful, funny, or other descriptors, might be more effective. This way, contributors are incentivized to help, as they can gain reputation points. Then a leaderboard showcasing the most helpful contributors on a weekly or monthly basis could further encourage participation.
Feature Description Benefits User Profiles with Reputation Points Allow users to earn points for asking questions, providing answers, and receiving upvotes. Encourages participation and rewards knowledgeable contributors. Question Marking System Enable users to mark questions as solved, rather than comments. Simplifies the process of identifying resolved queries. Voting System Implement a voting mechanism for answers (e.g., helpful, insightful, etc.). Helps surface the best answers and encourages quality contributions. Leaderboards Create weekly or monthly leaderboards showcasing top contributors. Fosters competition and motivates users to engage more actively. Categorization and Tagging Allow users to categorize questions and tag them for easier navigation. Improves searchability and organization of content. Search Functionality Develop a robust search feature that allows users to find questions and answers quickly. Enhances user experience by making information easily accessible.