DEV Community

Cédric Teyton for Packmind

Posted on • Updated on

Easily share best coding practices from your IDE with your team

🤝 Why sharing best coding practices?

Each developer has their own experience and their favorite ways of writing source code. Some have been influenced by reading the Clean Code book from Uncle Bob. Others have been shaped thanks to mentoring or training with a specific developer. In any case, we can assume each developer writes code while trying to apply best practices.

Thus, developers have heterogeneous knowledge. Ask 100 developers to implement the same feature, and you'll be likely to get a majority of different implementations.

Within a team, developers should align their best coding practices to ensure source code uniformity and quality. While source code remains in the company over the years, developers are volatile. Best practices should remain the same for whoever works on the project, so they need to be persisted, documented, and known by developers.

Let's an example of how you can use Promyze to reach that purpose in a simple 3-steps process.

🔎 1. Identify practices in your IDE

Have you ever been in a situation where you're reading a source code and thinking, "Mmmh, I think this should be done in another way"? Or inversely, you could think "Oh, this is exactly the right way to do it." What do in such a case? Send it to Slack but with the risk of few considerations from the team?

Assume this function in JS, and take a look at the for loop :



async getUsersProfilesData() {
    const users = await this.APIService.getAllUsers();

    const usersWithProfile = [];

    for (let i = 0, iMax = users.length; i < iMax; i++) {
        usersWithProfile.push(await this.getUserProfiles(users[i]));
    }

    this.$scope.$apply();
}


Enter fullscreen mode Exit fullscreen mode

We could be tempted to use Promise.all function to avoid blocking calls with the await keyword.

This is something you can easily do with Promyze's IDE plugins (available so far with VSCode, Visual Studio, and all the JetBrains suite). Let's see here with the VSCode plugin, we just select the snippet and create a new practice :

Best practice creation with Promyze

The plugin prompts for a little information, such as a name and some categories for the best practice. Of course, I could instead identify an existing best practice.

Set the practice name in VSCode

That's the idea, and all developers should be doing those operations 2 or 3 times a week, for instance.

You can also add a correction to illustrate how it should be done, but you can also identify positive examples if you consider that a best practice has been followed.

💬 2. Discuss and make decisions

All those contributions come to the team's space in Promyze. Once a week or every two weeks, the team gathers for an hour-session and reviews all the identified best practices. That's what we call a Craft Workshop.

Here, Bob explains the Promise.all mechanism and why it should be used in the project's code. The discussions and knowledge sharing happen, and participants give their opinions. The team will decide either to :

  • Validate the practice and add it to their repository
  • Discard the practice since it's not relevant in this context
  • Refine it and add more description
  • Start a battle to share arguments

Craft Workshop to discuss about best practices
A very useful feature is that each identified example and counter-example of practices will be kept in its documentation in Promyze.

🚀 3. Manage your practices and share them with other teams

That's how you can start creating your practices repository.

It's common to have multiple teams in an IT organization. That's why Promyze has been designed to define and share practices between teams or communities of practices.

Each team may decide to make their practices publicly available. This can be relevant if you have a team dedicated to spreading the best React or Spring practices, for instance. Craft Workshop can be run within a team or across teams on specific topics.

Best practices repository

This is just a quick introduction, but there's more you can do with this solution. In the next article, we'll see how Promyze can help developers with automatic suggestions while coding and doing code reviews.

Top comments (0)