DEV Community

Nwanguma Victor
Nwanguma Victor

Posted on

4 2

#1 Tip for Readable Code Across Teams and Personal Projects

Have you ever written code and months later you come back to that same code and be like "what the heck was I thinking".

💡 Tip: You can easily put links referencing the documentation, site or stack overflow question from where you got that cool and fancy one-liner, solution or concept.

It helps if you think someone else would have a hard time understanding your code

// https://laravel.com/docs/9.x/collections#method-collapse
// https://stackoverflow.com/questions/62872479/laravel-incorrect-json-response-structure-when-using-unique

$collection = collect([
    $abc,
    $validated['abc']
])->collapse()->unique()->values();
Enter fullscreen mode Exit fullscreen mode

Advantages of this approach

  • Team members can easily understand what's going on in the code directly from the source or from other examples.
  • It helps Junior developers understand the codebase better.
  • It's easy to adopt into any team or project.
  • Easy adoption ensures consistent comments across teams.

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay