Skip to main content

Questions tagged [constants]

0 votes
1 answer
1k views

Given a class which has certain private, constants (e.g., configuration), should these (A) be included in the declaration of the class (in the private section) or (B) should it be "hidden" ...
Patrick Wright's user avatar
1 vote
2 answers
3k views

I'm looking at creating my first packages to clean up my codebase. Below is a very simplified version of my current project structure: my_project/ |-database.py |-app_1.py |-app_2.py |-constants.py ...
Jossy's user avatar
  • 311
1 vote
1 answer
109 views

Considering there's a map of string constants, most commonly with a key and a value being equal, e.g. in TypeScript: const itemTypes = { FOO_BAR: 'FOO_BAR', BAZ_QUX: 'BAZ_QUX', } as const; They ...
Estus Flask's user avatar
144 votes
3 answers
35k views

In code dealing with hash tables, I often find the constant 0x9e3779b9 or sometimes 0x9e3779b1. For example hash = n * 0x9e3779b1 >>> 24 Why is this particular value used?
bkgs's user avatar
  • 1,023
1 vote
1 answer
710 views

I have to work on some code that was CAST-audited. The report says that it is bad in Java to use public static and that accessors should be preferred. That is also what I was taught at school. The ...
The Once-ler's user avatar
0 votes
2 answers
622 views

I don't have a lot of experience with these kind of issues, but I feel I need to consult on this issue. The current codebase I'm working on is using what I consider to be a questionable technique to ...
Ashton Spina's user avatar
3 votes
1 answer
121 views

For example, to convert between g and kg, I have a constant 1000: public static final float G_TO_KG=1000; . . . this.result = someResult*1000; I found G_TO_KG always bind to operator '*'. So my ...
ocomfd's user avatar
  • 5,760
1 vote
1 answer
244 views

For two choices there is boolean. In my case, I have positive, negative, and neutral which are three choices and cannot be represented by boolean. I've see there's method Math.signum(x) in Java which ...
fikr4n's user avatar
  • 154

15 30 50 per page