popbr / data-integration

Apache License 2.0
1 stars 4 forks source link

Remove hard-coded values #8

Closed aubertc closed 2 years ago

aubertc commented 2 years ago

As far as I can tell, the code by default looks for a particular school:

https://github.com/popbr/data-integration/blob/main/Project/Database-IO/src/main/java/com/mycompany/app/App.java#L79

It's ok to have default values, but the program should let the user the possibility of changing this value without having to re-compile.

MNSleeper commented 2 years ago

In an email, I have attached a sample method that implements the ability to define what we wish to search for and what attributes are tied to it as a mock method that can be put into the larger program.

aubertc commented 2 years ago

That's really good. Please incorporate this in the project, but leave the ability to run the program with some default values as well.

MNSleeper commented 2 years ago

I would like to leave the original hardcoded value in, comment out the search method call below it, and add the method to the program. That way, Every time I compile and run it for testing, I won't have to type in what I want to search for and what attribute it's under. When we have a release/we're out of heavy testing, I'll uncomment it and delete the hard coded line.

aubertc commented 2 years ago

Ok, a cleaner method would be to let the user give arguments using the command-line, and if they don't, to prompt them (and let them use default values if they want).

You can use (cf. this post)

mvn exec:java -Dexec.mainClass="com.mycompany.app.App"A -Dexec.args="'argument separated with space' 'another one'"

to pass the arguments 'argument separated with space' and another one to your main method, and then normally you should be able to access them through args[0] and args[1] in your main method.

MNSleeper commented 2 years ago

If I understand this correctly, make the main method accept parameters, and those parameters will be filled by the above-suggested execution command?

aubertc commented 2 years ago

That is the idea, yes. And if no arguments are given, then default back to asking the user if they want to enter their own set or run the program with pre-defined values.

MNSleeper commented 2 years ago

I have mostly implemented this by checking args.length and using the GetSearchInputs method. It works as intended. Small note, though: the obj.scanner can't be opened and closed every time GetSearchInputs is called. It has to be left open, else it'll error out.

aubertc commented 2 years ago

Please, point out to the commit that implements this feature, in the future, for easier review.