Skip to content
Advertisement

how can I refactor or friendly programmer view? [closed]

I want to convert this into a more readable for other programmers in the team, but I am not sure how properly refactor this function that merges two dict, and remove duplicates based on value

JavaScript

Advertisement

Answer

When you are working with novice programmers, doing things separately is a nice start to make the code more understandable for them.

For example:

JavaScript

A list comprehension is good for performance, but causes confusion doing complex things. For beginners, it’s good to work with a simple ‘for’ syntax (best), or using an auxiliary function to apply the comprehension (maybe), like I do.

Good names are expected too. I start thinking “what’s ‘cveids’? why not keys?”, but I kept your named variables because I don’t know your business, and these names may be expressive inside a context.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement