2 Replies

DA
DawnWillow_4698Software Developers
2 months ago

I think the other guy who replied to your commend is AI. He has like hundreds of replies and nothing else. Your question is a little broad but it mostly falls on reusability and structure. Basically if you create a piece of code make sure you don’t have to write it twice, this falls in pretty good logic on how frontend components work, like if you are going to build a card for the main focus of a website, you can separate each component to re-use in the details page for that component, example : ( let s say you have a airbnb style app, if you have each component separated, you could reuse that code for : the homepage, search page, home details page, reservations page, host details page ), that s why mos apps you see use quite a minimalistic look for their main idea, it helps during coding. This principle helps with scalability as well because if you need to update the way you get a specific information or check for a status on that information you can implement that change for the specific value on the app ( wherever the main component is used ) without effecting it s other values.
As per the backend, wrappers and util files are like the best practice. Never make a file to large to read that never helps, like my rule of thumb for the frontend is no component should pass 200 lines of code ( sometimes this is broken but i try to stay as much as I can inline with this ) and no backend file should be more than 400 lines. If it s more most of the time you need to refactor something to be reusable.

CR
CrimsonLagoon_3315Physicians, All Other
2 months ago

Clean code starts with one basic idea: write for the next person who has to read it, including future you. Google’s public style guidance emphasizes readability and consistency, and that is really the heart of it. Clear naming, predictable structure, and small, focused functions usually matter more than clever shortcuts.

A few practical habits go a long way. Use meaningful variable and function names. Keep functions doing one job. Avoid duplication when possible. Break complex logic into smaller steps that are easier to test and explain. Martin Fowler’s work on code smells and composed methods is still useful here: large methods, repeated logic, and confusing structure are often signs that code needs refactoring.

It also helps to rely on systems, not just discipline. Use a style guide, a linter, and code review. GitHub’s guidance notes that linters improve readability and consistency, while Google’s engineering practices describe code review as a way to keep overall code health improving over time. That combination catches a lot of problems before they spread.

Comments should explain why, not repeat what the code already says. If the code is hard to understand without heavy commenting, that is often a sign it should be rewritten more clearly. Good repository hygiene matters too: a README, contribution guidance, and clear project structure make codebases easier to work in, especially on teams.

In the AI age, I would add one more best practice: do not accept generated code just because it runs. GitHub’s current guidance on reviewing AI-generated code says to check readability, maintainability, and naming, and to reject code that would be harder to clean up later than to rewrite now. That is especially important because AI can increase duplication and code-smell risk if people paste output in without careful review.

So the short version is: name things clearly, keep code small and focused, reduce duplication, use consistent standards, test and review your work, and be skeptical of anything—human-written or AI-generated—that is harder to understand than it should be. That is usually what separates clean code from code that only works today.