Questions tagged [hardcode]

It is the development practice of writing data considered as configuration or input directly in source code.

Hardcoding is considered a bad practice, source code must be changed every time programmer want to change the hardcoded data. It is commonly used when writing programs that should accept user's input, to avoid complexity the programmer should prefer hardcode the input data in the source code instead handle real input.

153 questions
22
votes
4 answers

hardcode string vs @string in Java code - Android

I'm just wondering what the benefits/overheads are for using @string rather than hard coding strings within the actual Java code... For Example: // To get the string resource: getActivity.setTitle(getString(R.string.my_string)); Is this the best…
Gyroscope
  • 3,121
  • 4
  • 26
  • 33
10
votes
1 answer

Constants for resource types in Android

Are there constants for the various resource types (ie: "drawable") in Android? I want to code some conditional logic based on the return value of getResourceTypeName and I would prefer to avoid hardcoding the resource types. Example: final String…
hpique
  • 119,096
  • 131
  • 338
  • 476
6
votes
3 answers

Hard-coded URL's

I have a query regarding hard-coded url's. When making a post call from JavaScript using jquery I do it as $.post('http://localhost:8000/timer/check/' Now this works fine on my development server. When I have to deploy it on another server I have…
Aniruddha Bhondwe
  • 821
  • 12
  • 18
6
votes
2 answers

How to provide periodic table information to Python module

I'm writing a Python module, and I want many of the functions to have access to information on the periodic table; namely, atomic numbers and their corresponding atomic symbols. The information should never change. I'm struggling with how to…
pique
  • 96
  • 1
  • 1
  • 6
5
votes
3 answers

Is there any performance difference between accessing a hardcode array and a run time initialization array?

For example, I want to create a square root table using array SQRT[i] to optimize a game, but I don't know if there is a performance difference between the following initialization when accessing the value of SQRT[i]: Hardcode array int…
ggrr
  • 7,737
  • 5
  • 31
  • 53
5
votes
4 answers

Best way to initialize large amount of data into a C++ container?

For example: InitEmployee() { vector employeeList = { Employee("Clark Kent",0), Employee("Bruce Wayne",1), ... Employee("Hal Jordan",65535) } } I cannot query from file or DB as this program needs…
Nah
  • 331
  • 2
  • 9
5
votes
2 answers

Why is libtool is throwing "unsupported hardcode properties" errors and what do they mean?

I am cross-compiling gettext-0.18.2 for Windows but running into some problems. During the linking stages of one of the shared libraries, libtool gives me the following error message: /bin/bash ../libtool --tag=CXX ... libtool: link: unsupported…
Nathan Osman
  • 71,149
  • 71
  • 256
  • 361
4
votes
5 answers

.net: Hard-coded conditions or WHAT?

I have a form (form1) which contains a simple drop down list (dropdown1) and 2 textboxes (textbox1) and (textbox2). The scenario is: user enters some code in textbox1 and then based on what he has entered, "type" of the code will be appeared in…
odiseh
  • 25,407
  • 33
  • 108
  • 151
4
votes
3 answers

How to replace hardcoded string for label text in *.Designer.cs C#?

How can I correctly replace hardcoded string for labels in Form1.Designers.cs? Instead of: this.button1.Text = "TheButton"; this.label1.Text = "TheLabel"; I want to write: this.button1.Text = Resources.ButtonText; …
Skiv
  • 43
  • 3
3
votes
9 answers

Java array declaration without hard coding the size

How can I initialize an array of objects of a class in another class without hardcoding its size?
P R
  • 1,293
  • 7
  • 28
  • 58
3
votes
4 answers

Is It Okay to Hard-Code Credentials?

I'm working on a small web project with a friend. It involves a lot of MySQL queries, so I've created a ConnectToDatabase() function that connects to the server and selects our database. It looks something like this: function ConnectToDatabase() { …
Maxpm
  • 24,113
  • 33
  • 111
  • 170
3
votes
2 answers

Snowflake- how to search for a value in json values without using hardcoded keys

I have json column with keys from d1 to d32 and those keys have certain values. I want to now query rows where a value doesnt exist in any of the keys. Like - any dimension not equal to abc. So i am checking d1!=abc or d2!= abc..... d32!=abc. Is…
Ab148
  • 31
  • 2
3
votes
2 answers

How to add 1 item hardcoded into last index in list using gridview on Flutter

I have a lot of data in JSON more than 8 data. And I want to display 7 data from JSON and 1 hardcode data (for "More" feature). I managed to display 7 data from JSON as shown below. here But how can I add the last 1 data/index with the hardcode data…
R Rifa Fauzi Komara
  • 1,915
  • 6
  • 27
  • 54
3
votes
1 answer

How to export FFMPEG into my Python program?

I wrote a Python program for Windows 10 which converts audio files from any supported format to .flac, and it uses FFMPEG to do the encoding. FFMPEG is installed on my computer, so there isn't any problem when I run the program on my computer. I…
user11353612
3
votes
1 answer

iPhone - comparing a character returned by characterAtIndex with another hard coded one

I'd like to compare a character returned by characterAtIndex with some "hard" charaters, like @" ", or @"P". This may look stupid, but I don't find the way to do this...
Oliver
  • 23,072
  • 33
  • 138
  • 230
1
2 3
10 11