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
1
vote
0 answers

Android - More elegant way of declaring customs components in XML files

Currently I have a class called CustomizedGallery that extends the default Gallery. I include it in my XML layout files like this:
0
votes
2 answers

UIView code vs interface builder

I have defined a UIView in the header file named rectangle0 I got a question in regards to IB vs coding a view. Please see the following code example: rectangle0.frame = CGRectMake(0.0, 70.0, 320.0, 190.0); Now I can re-create the look of the view…
jwknz
  • 6,598
  • 16
  • 72
  • 115
0
votes
1 answer

struts2: avoiding hardcode in struts tags, jsp

When using struts2 I can access my session attributes inside struts2 tags using OGNL expression like this: #session['object_key'] The problem is that I use this expression on different pages, every time hardcoding that 'object_key' string. Is there…
pavel_kazlou
  • 1,995
  • 4
  • 28
  • 34
0
votes
0 answers

How can i fix spam filtering with recaptcha integration?

Two devs who previously worked at the company I now worked for implemented ReCaptcha into a hard coded site. They did not document how they did this for the company. The implementation does not seem to be working as hundreds of spam submissions are…
0
votes
0 answers

How do I fix Veracode Security Flaw in C# Windows App

I performed a Veracode scan on my Windows EXE. It reported following security vulnerabilities on the code in BOLD below: certificate = new X509Certificate2...................... Use of Hard-coded Password (CWE ID 259)(8 flaws) string GoogleSecID…
Gags
  • 827
  • 2
  • 13
  • 29
0
votes
1 answer

Best way to initialize a variable and use it in 2 service classes in java , as thread safe

This is first class: @Service public class ServiceA{ @Autowired ServiceB serviceB; String neededString; public void methodSome(){ //uses neededString } } This is second @Service public class ServiceB{ String neededString; public void…
asdasasd
  • 81
  • 1
  • 9
0
votes
1 answer

Avoiding hard coding a path and error handling

I am new to VBA and just can't seem to get my head around this. So I have a source excel file where I copy the necessary data from a selected worksheet and then paste it to a main workbook (everyday use) to the exact worksheet using my macro. What I…
Aml_Bob
  • 11
  • 1
0
votes
0 answers

How to secure hardcoded fields in flutter

I need to make targetEmail, username, password secure with the flutter_secure_storage package but I do not know how to do it. class ContactBloc extends Bloc { late final SmtpServer smtpServer; final String targetEmail…
Armagan GOK
  • 81
  • 1
  • 7
0
votes
1 answer

Leveraging for loop to run slices of dataframe through supervised model based on one column value

I have the following dataframe and would like to group the data by cluster number to generate 5 new dataframes (the clusters go from 0-4), and then further split them up into training and test sets based on the Date column and run each train/test…
Hefe
  • 421
  • 3
  • 23
0
votes
0 answers

Why is this NOT unreachable in the if-statement?

In testOne: Why is the "else if" not unreachable (aNumber is final so the compiler should know it can't get past the "if" part, but it only gives a warning)? Since "else if" apparently is reachable, why then is the "else" part not unreachable…
0
votes
0 answers

A parameter of constructor is "constants", is there a design-pattern / elegant solution?

This is mostly an imaginary problem, no real life situation, but it's simply do depict with. In this example we cache a point to a directory. I used to have common.php define('PATH_TO_CACHE', '/var/www/cache'); pixel.php class Pixel { private…
John Smith
  • 6,129
  • 12
  • 68
  • 123
0
votes
2 answers

What is the idiomatic way to hardcode a byte vector with some metadata in a Rust module?

I am following the Rust wasm tutorial. in which you build a game-of-life clone and am currently doing the "Initialize the universe with a single space ship" exercise. To implement the ship I started a module which holds the ship data and associated…
Darvan42
  • 53
  • 1
  • 4
0
votes
1 answer

How to pass variables to parameters within a script. I.e. hardcode parameters

I am looking to pass a bunch of variables to the parameters of a function but since the script needs to be run unattended I will need to pass these variables within the script. i.e via invoke-expression or otherwise. Below is the functions I am…
0
votes
1 answer

Can we use django filter with a variable?

Here are my codes: Models.py class Members(models.Model): first_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100) username = models.CharField(max_length=100) email = models.EmailField() …
0
votes
1 answer

Cannot Send Whatsapp Message using Java

I need your help to solve this question, My approach is want to send Whatsapp message using Java and use Whatsapp Gateway please find the java code below import java.net.*; import java.io.BufferedReader; import java.io.OutputStream; import…