New answers tagged

1

I think this bit is worth refactoring: public void printOptions(){ System.out.println("Options:"); System.out.println("0. Quit"); System.out.println("1. Add a new dog"); System.out.println("2. Add a new cat"); System.out.println("3. Print all animals"); System.out.println("4. Delete an animal"); ...


0

Animal.java I do not know which version of Java you are using, but consider version 8 as it is pretty much the industry standard now and use LocalDate instead of Date species seems like it should be an Enum, not a String InputValidator.java Keep your scopes to smallest possible, why is Scanner an instance field? Do not forget to close your Scanner public ...


1

OOP considerations: Dog and Cat are both animals; You should have Dog and Cat classes which extend Animal. You have basically three concerns (business logic) in your application: (1) Get input from command line, (2) Validate inputs and translate inputs to entity, (3) Apply CRUD operations to perform on entities. You can create one interface for each ...


3

Unfortunately I don't have time to finish my answer right now, but here's what I think so far: Main.java If your whole program is built around reading and manipulating a single file, it's customary and useful to take the name of that file in as a parameter (i.e. read it from args) instead of hardcoding it. (In future versions you might replace the filename ...


5

First, I'm afraid all the path handling and validation is a common anti-pattern of trying to check every conceivable error condition before trying to do something, in order to avoid lots of error-handling code. The problem is it doesn't work - it is literally impossible to guard against all possible errors, because an error may be introduced after you verify ...


1

require style I (and most of the Node developers I've worked with) prefer the style where require is put on top. As stated in the guide you linked, it gives a clearer overview of what are dependencies of the module/file you're writing. No one likes to see that if some condition is successful, then a new module will be loaded. It's just unnatural. On the ...


1

The code feedback is already done wonderfully. I'd like to write about some pointers that might be important, apart from the leet speak: The word Phoque , is French for seal. There are numerous examples of words which are perfectly meaningful in some language but if pronounced in English, might be considered offensive. You might need to do a phonetic ...


2

explicit_words = [ #explicit words not shown ] Instead of embedding the word list within the program, you might want to treat it as configuration, and load it from a data file. The advantage of this is that it can allow the use of alternative configurations by command-line option (e.g. use a list of French obscenities for French-language lyrics). On ...


3

To simplify your input you could change word == explicit_word to explicit_word in word. This can lead to the Scunthorpe problem, and so from here you can check if the word only contains prefixes and suffixes. Given the amount of common prefixes alone, it's unlikely you'd catch all variations using a blacklist alone. It would also catch gibberish/...


Top 50 recent answers are included