Skip to main content

All Questions

Tagged with
0 votes
3 answers
1k views

Eliminate duplicate code in nested IFs without creating a function [duplicate]

Let's say we have two ifs that depend on each other: if var exists { if var is array { //Do stuff with var } else { //Resolve the problem } } else { //Resolve the ...
Mikayla Maki's user avatar
1 vote
7 answers
3k views

After how much line of code a function should be break down?

While working on existing code base, I usually come across procedures that contain Abusive use of IF and Switch statements. The procedures consist of overwhelming code, which I think require re-...
Sumeet's user avatar
  • 121
12 votes
7 answers
1k views

After writing code, why do I feel that "I would have written better" after some time? [closed]

I have been working on my hobby project in C++ for more than 2 years. Whenever I write a module/function, I code it with lot of thinking. Now see the problem, do { --> write the code in module '...
iammilind's user avatar
  • 2,232
6 votes
7 answers
209 views

Can initial inefficient solutions INSPIRE better ones and thus lead to faster problem solving?

When faced with writing an algorithm to solve a small project/problem is it better to come up with pseudo code that isn't efficient/optimum but solves the problem and then try to use the inefficient ...
rrazd's user avatar
  • 1,408
46 votes
8 answers
4k views

Code maintenance: keeping a bad pattern when extending new code for being consistent, or not?

I have to extend an existing module of a project. I don't like the way it has been done (lots of anti-pattern involved, like copy/pasted code). I don't want to perform a complete refactor for many ...
Guillaume's user avatar
  • 2,207