Skip to main content

All Questions

1 vote
1 answer
206 views

counting identifiers and operators as code size metric

I'm looking for a code metric for monitor and track over time the size of several projects and their components. Also, I would like to use it for: evaluate size reduction after refactoring compare ...
Guish's user avatar
  • 23
4 votes
7 answers
1k views

How do you know where you stopped in your codes after a 2-week break? [closed]

I just had a more than 2-week long vacation/business trip and I couldn't remember actually what was I working in my coding and where I stopped. Could someone recommend a best practice to solve this?
vyap56's user avatar
  • 175
2 votes
2 answers
213 views

Should one create shareable private class member or keep variable in method scope to pass it as a second method argument?

Recently I had to refactor some legacy code. As in most cases, I had to split big parts of code into smaller, cleaner and readable functions. I ended with many functions, that had multiple, weird ...
helvy91's user avatar
  • 29
14 votes
2 answers
3k views

Is it bad practice to create blocks of code?

In C++, is it bad practice create blocks of code inside some function, such as the following: bool f() { { double test = 0; test = // some other variable ...
Inertial Ignorance's user avatar
1 vote
1 answer
132 views

Should a loop be nested inside an unchanging conditional?

I was reviewing some old code and stumbled upon a loop nested inside a conditional like this: std::cin >> number; //number is used elsewhere, so should be preserved if (number <= 10) for (...
BrainFRZ's user avatar
  • 113
10 votes
5 answers
819 views

Is placing text markers inside of strings bad style? Is there an alternative?

I work with massive strings which need a lot of manipulation. For example, I might generate a string like this: Part 1 Boat Section A Programming Part 2 Partitioning boats for ...
Anon's user avatar
  • 3,633
12 votes
5 answers
6k views

Should I be using const more in C++?

There are some things I am pretty strict about, but const has not been one of them. For example, I might make a local variable that I use three times in a function, that does not get changed, and yet ...
Anon's user avatar
  • 3,633
3 votes
2 answers
340 views

Practice for returning a value or equivalent variable?

I think it would be easiest to explain what I'm asking with an example. function getLastNode() { let current = this.head; if (current == null) { // Here, we could either return ...
Matt C's user avatar
  • 250
5 votes
3 answers
14k views

Is it considered good practice to always have methods return a value?

Sorry for the terrible title but hopefully these snippets will give you the gist. Method 1: class Person: def __init__(self, name): self.name = name def set_name(self, new_name): ...
Tochi Obudulu's user avatar
50 votes
8 answers
17k views

When is it appropriate to make a separate function when there will only ever be a single call to said function? [duplicate]

We are designing coding standards, and are having disagreements as to if it is ever appropriate to break code out into separate functions within a class, when those functions will only ever be called ...
David's user avatar
  • 1,899
3 votes
3 answers
1k views

Refactoring previous intern's noodle code with future interns in mind [duplicate]

Background I've run across this problem as I am currently an intern at a large company's local software division. I have been given the task of extending a project that several previous interns have ...
BaronSchnitz's user avatar
3 votes
3 answers
6k views

articles in variable names and hard-coding strings

re-edited by author: no this is not 2 questions. This is one question about code review questions containing two separate points. Please do not edit my question. For naming variables, the two sides ...
Iceberg's user avatar
  • 49
136 votes
10 answers
106k views

Why do most of us use 'i' as a loop counter variable?

Has anyone thought about why so many of us repeat this same pattern using the same variable names? for (int i = 0; i < foo; i++) { // ... } It seems most code I've ever looked at uses i, j, k ...