Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!

Junilu Lacar

+ Follow
since Feb 26, 2001
Junilu likes ...
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
Columbus OH
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt Green check
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Junilu Lacar

bryant rob wrote:So, since Case is a variable type, is Case in this situation a custom data type?

Your phrasing is again jumbled here.

Case is a class. In that line, it's the declared type of the variable theCase.

If you really want to use the term "variable type" then it would be more correct to say "the variable type, i.e., the type of the variable theCase, is Case."
9 hours ago
A custom data type is just something that you have defined, as opposed to any "built-in" or "standard" types which are classes defined in the Standard Library, such as Integer, List, System, Stream, etc.

Since the Case class is something that you defined then, yes, it is a custom type.
9 hours ago

bryant rob wrote:1.  I would think that theCase is an instance variable of type Case


but my reading tells me that it is a custom data type variable of type instance. Is this correct?


2.  By declaring the instance variables in the class PC, are these instance variables referencing the objects theCase, theMonitor, and theMotherBoard that I created in the main method from the Main class?

No, the objects created in the main() method are local to main()

You have many terms all jumbled up.

Instance - same thing as an object. The term "instance" is usually used in the context of a Class. That is, if Point is a class, then the object created by new Point() is an instance of it.

12 hours ago
You call moreY() two times: first on line 15 then a second time on line 16 so naturally, you'll get two "y"s
1 day ago
Re "hiding the implementation" -- it simply means that the client would have no idea exactly how something is done. Take for example a method of an interface like List. The client code doesn't know or care about how the add() method would be implemented. All the client cares is that an element will in fact be added to the list when this method is invoked. How that happens exactly will be up to whatever the author of a particular implementation decides to do.

In short, using interfaces is all about the intent of the client, not the implementation.
4 days ago
On your first service test, its name says "it should return highest frequency words"

However, the test code is doing more than that:
1. Uses a count of 2
2. Uses a data set with only one word that is repeated ("four") and multiple words that appear only once
3. Yet, the expected result contains "the", which appears only once. It's not clear why "the" is expected in the result rather than any of the other words that appear only once in the data being searched.

The test name should be a concise yet complete summary of what the test code is doing. This is not the case here. This creates cognitive dissonance and makes your test difficult to comprehend.
5 days ago
See this tutorial for how you want to test a Controller class:

Consider: are your current controller tests redundant with the service tests? (Hint: they should test different things)
5 days ago
What "default handler" are you referring to? Java doesn't have a "default handler" as far as I know.

EDIT: Just noticed that this is in the C#/.Net forum -- I don't know if what I said is true for C#, honestly, but I'd imagine it is. (I could be wrong, of course)
6 days ago
It looks to me like OP is using "max" to mean "most number" of pizzas sold/ordered. None of the code I've seen shows any indication that price/cost is what is being checked. That is, if there are 3 orders for "pepperoni", 6 orders for "cheese" then "cheese" is the "max" with 6 orders.

OP, please let us know if this is what you mean by "max" pizza.

By the way, if I'm correct then a better way to say it is "what type of pizza has the most number of orders"
1 week ago
You can start by showing us the code in this service class that you want to test.
1 week ago

Raja Avrv wrote:
The service class actually does all the computation, so I thought I could just test that the controller calls the service (using verify) here and that I can see the result of that service call come out of the controller (through expect). Is that expect maybe not necessary?

1. Your test method name does not give that impression
2. The test code does not clearly communicate its intent
1 week ago
Line 10 of the test looks very wrong to me. Especially when you look at line 22.
1 week ago
You might also look up alternatives to marker interfaces in Java before you decide on using them.
1 week ago
You might want to read up on how to properly design a RESTful API for this kind of task. Here's one article that you can start with:
1 week ago

Mark Richardson wrote:

Line 5 is the part that you got particularly wrong. Whenever you see string concatenation like this to build up a SQL query, think "SQL Injection Attack!"
1 week ago