# Tag Info

8

It solves the problem, and that's good. Period. But you're presenting your code here to get advice how to improve your programming skills, so here are a few remarks. Take them as a hint where to go from here, as soon as you feel ready for the "next level". Separate user interaction from computation Your main method contains both aspects in one ...

5

Reduce code repetition / redundant checks Your if statements are redundant. If grade = 90, it already satisfies the grade >= 80, so just use that. No need to check if it equals 90 exactly because that's already covered. Instead of having four different lines where you show a message dialog, have a string that you assign the message to and print that at ...

5

If I test this method using an ID number which is less than 13 digits long, I will get en exception. I think that should be explicitly handled.

4

Hello and welcome to code review! My main question is: How often do you write programs that have several threads running throughout the application lifecycle with identical exit condition? It is possible that this might negatively affect the way you design your applications and make you use practises that aren't quite optimal? For example, instead of ...

3

OOAD - Object Orientated Analyze and Design It's always a good idea to start with a pen and a pencil before you do any coding. Here is a demonstration on how such an Design could look like (I strongly recommend UML since this kind of diagramms is understood by everybody among engineers) Honestly I do not fully understand your requirements (your homework ...

2

Naming Naming is really important. There are conventions that help to give helpful hints to the reader about what a name refers to. camelCase names on their own are typically going to be variables, camelCase( with parenthesis are likely to be function calls. Capitals are typically used for classes, constants, enums. So, when I see something like this: ...

2

Question: method and normal variable names in java start with a small letter by convention. As opposed to C#. Is it a special convention of the course? Repetitive code for array entries. X == true is simply X and X == false is !X (not X). Parameters f(X[] array, int index) might just be f(X x). It also might be that then the called method should be a method ...

2

In addition to @Linny's answer, I can comment on the following topics: Use correct method names. getGrades method gets grade input and displays student's status. You should name it accordingly. Actually, your getGrades method does two different things which is a violation of Single Responsibility Principle. Dividing it into two methods such as getGrades and ...

2

For an interview, this is bad code. It is $O(n \log n)$. But it can be done in $O(n)$ time. Your code does not show your skills in that direction. Also, many interviewers (justifiably) will be unhappy for using streams. Streams may look cute but at scale like Gmail, they cause performance problems.

1

As for a real review, see Torben's answer. Apart from that: have a look at the method Thread.setDaemon(). Setting your worker threads to daemon would probably solve your problem without any further code. (See this question in SO https://stackoverflow.com/questions/2213340/what-is-a-daemon-thread-in-java) If you want to perform additional parallel tasks in ...

1

@TorbenPutkonen's answer includes all the important facts about your code, I want just to add some minor thoughts. When you works with java threads and you have some shared variables check if there is a thread safe alternative already implemented in the java library. So instead of long and boolean use the thread safe alternatives AtomicLong and AtomicBoolean,...

1

The code as presented is poorly formatted, which makes it difficult to read. If this is how it is in your editor, then you should consider reformatting it to a standard indentation. Most IDEs / code editors can do this automatically for you. public class List { The list you've implemented is a linked list. This impacts on how it performs. Consider ...

1

Naming I'm sure you already know this, but naming matters. The few keystrokes that you save using w are paid for every time somebody reads the code. Consider always using more meaningful names withdrawalAmount etc. Be cautious about reusing names of classes from the standard library. Rather than Consumer, consider giving it a more specific name to reflect ...

Only top voted, non community-wiki answers of a minimum length are eligible