New answers tagged

4

You should not bake hand literal strings in your logic; instead refer to your constants or better yet an Enum You should try to reduce the amount of class state floating around. index and current_hand for instance are not good class members; instead they should just be local variables. Consider refactoring your Player class to be an iterator over its hands, ...


0

Some ADODB pointers Querying the data Keep in mind that a query may return an empty recordset. OpenScalar accesses the first record without any checks. Verify that RecordCount > 0 (CSV backend, for example, ignores the MaxRecords attribute, so the recordset returned by OpenScalar may have RecordCount > 1 even if MaxRecords = 1) and that ...


0

One additional comment: You text-based menus are not a professional way of creating a user interface (it feels like in the 1980s). On your learning curve, you probably haven't covered graphical user interfaces (e.g. using Swing or a web server) yet, so that's fine. But maybe you want to read on how to improve your professional skills. Text-based programs ...


3

Naming Conventions Methods in Java use lowerCamelCase, as seen in your ReportData class. PascalCase ist only used for classes, so the method names in the Products class should be changed Confusing names Products isn't a class related to products, it handles user input (suggesting Menu instead) exit isn't an exit flag, it stores the user's menu selection (...


2

We can rewrite this to be more declarative. Not to mention StreamReader and StreamWriter are fairly low level types, in most cases there is a different call to make to express your intent better. private string writeUser() { string filePath = "usernames.csv"; var found = false; //we don't modify the existing list, don't store it //if ...


1

There are quite a number of things that can be done to simplify the code. Consistency It is important to be consistent in your code. If you express the same thing in two different ways, a reader will assume that there is an important difference between the two. For example, you can write strings with double quotes or single quotes, and if you use double ...


1

Prefer interfaces to implementations private HashMap<String, ToDoList> toDoLists; private HashMap<String, User> map; You should almost never use an implementation as the type. So these should be private Map<String, ToDoList> toDoLists; private Map<String, User> map; Then if you change the implementation, you only ...


3

Don't use random for passwords, use secrets "has-a-root" is a cleaner pattern here, I think, than "is-a-root"; in other words, don't inherit - instantiate Cut down the repetition in your options by generalizing to a collection of strings, each expected to be an attribute name on the string module. Represent this name consistently between ...


1

To do the job in a single pass you can do it like this: const preferedDomain = 'prefered' const data = [ { keyword: 'hey', domain: 'apple', rank: 1}, { keyword: 'hey', domain: 'apple', rank: 2}, { keyword: 'hey', domain: 'prefered', rank: 46}, { keyword: 'foo', domain: 'amazon', rank: 1}, { keyword: 'foo', domain: 'amazon', rank: 2}, { keyword: ...


2

I don't think Password needs to be a class. __init__ is calling gen_password, so this really could be boiled down to a single function call: def gen_password(length: int, lowercase: bool, uppercase: bool, digits: bool, punctuation: bool) -> str: char_groups = { 'lowercase': string.ascii_lowercase, 'uppercase': string.ascii_uppercase, ...


2

You have provided limited information in regard to what and how to filter the data. Thus this review looks at just an array (table of records) and how to build complex searches using functions built into the filter object. Complex filters As you have the filter you filter while you parse the filter. This adds overhead to processing the table. It also makes ...


2

You improved the program by a lot but then misunderstood some of @TorbenPutkonen's suggestions. As it turns out, the program runs just as fine when you change all StorageInstances to Storage and remove the interfaces you added. The Storage instance Let's get the StorageInstance out of the way first. Consider a line like this Storage store = new Storage(); ...


2

Its seems like you have all the logic to filter the rows centralised, and the use the external filters array to decide which filters to apply. This makes your code kind of complex. Why not let each of the entries in filters be a function that takes a row as an input, and returns true if it should be filtered? Then, you could simply change the way you filter ...


Top 50 recent answers are included