Questions tagged [code-duplication]

Code duplication, also sometimes known as code cloning, is a programming practice consisting in repeating the same (or similar) sequences of code statements within a software same project. Disadvantages of c.d.: bug propagation, increased code complexity, code clutter. Advantages of c.d.: reduced development effort, increased reliability (sometimes). Automatic c.d. detection tools exist including, e.g., Simian, Dude, CCFinder, Clone DR.

711 questions
-3
votes
1 answer

Need help in reducing the complexity or duplication in the function mentioned

Hi can someone please help me in reducing the complexity of the below mentioned code as I am new to this I need it to reduce the amount of code and improve the code and to improve simplicity and reduce duplications in the overall coding any any help…
-3
votes
2 answers

How to initialize map without code duplication?

I have a struct type named as game as follows: type game struct { commands map[string]*command // ... } And I want to initialize a map in a struct of this type in the init function. I do it like this func (game *game) init() { …
reflex0810
  • 908
  • 12
  • 13
-3
votes
1 answer

How to avoid duplicating the same chunk of code?

I am a beginner developer of an Android app and have a structure related question. In my app I have a few screens with buttons that allow us to switch between these screens. Right now I am setting up the SAME chunk of code with the button click…
anne
  • 29
  • 5
-3
votes
2 answers

remove or replace duplicated C++ code in one function on Linux

I am working on C++ on Linux. I need to remove some duplicated code in two functions. One function is for computing and another one is for logging. There are some code that are duplicated in logging(), which is much longer than computing(). The…
runner frank
  • 331
  • 1
  • 6
  • 13
-7
votes
1 answer

What is the difference between [^span] and (?!span) in regular expressions?

I got into a discussion with my co-worker on whether there can be only one correct regular expression for every pattern. I think that two correct regular expressions can occur. Can a pattern be associated with two different, correct regular…
c_taihei
  • 13
  • 2
-15
votes
7 answers

Is there a more efficient way to write multiple if else?

I need to match the average score to a letter grade. That means if (90 < avg && avg < 100) { return 'A'; } and so on until 'F', with 5 if-else statements. That's a lot of repetition, and the ranges I'm matching to are of the same length. Is…
L C
  • 67
  • 7
1 2 3
47
48