Tagged Questions
3
votes
2answers
120 views
How can I optimize this code for unit testing
How can i optimize this code with less number of loops and return values for unit testing
public class Diamond {
public void DiamondShape(int num) {
for(int ucount=num;ucount>0;ucount--) {
...
2
votes
1answer
191 views
Ranking and sorting on Array/List
My apology, I am quite new to posting a question in this forum.
I had a task where I was supposed to write a solution to sort entries(Name, score - in an array/list) in order of score and generate ...
3
votes
1answer
112 views
Designing a listener method and making it Testable
I have a java based server application that needs to support multiple clients. In the main class I have a method that runs in an infinite loop and waits for client connection. Following is this ...
2
votes
2answers
440 views
Tesing a simple calculator class with JUnit/JMock
I'm playing around with JMock and trying to understand whether I understand the idea correctly.
There's an interface Printer aimed to print integers somewhere. There's an interface Calculator aimed ...
1
vote
1answer
149 views
Spotify Best Before puzzle
I thought to spent my free time by solving a puzzle: Best Before Spotify Puzzle.
I coded in Java, and yeah I did not clean up my code (just a rough work) and I have yet to optimize... so I did check ...
2
votes
2answers
161 views
How to use inversion of control within a strategy when using the strategy pattern
I am creating a skeleton application to demonstrate use of the Strategy design pattern and inversion of control inside a Strategy.
The application is the backend of a simple board game, which also ...
1
vote
1answer
124 views
How should I test this class?
I've been trying to figure out how to (reasonably) test a builder-type class I've created, or whether (and how) I should refactor some portion of the design.
Specifically, I created a builder ...
2
votes
2answers
572 views
Ways to improve my coding test FizzBuzz solution for a TDD role?
I had an interview recently where I was asked to produce the traditional FizzBuzz solution:
Output a list of numbers from 1 to 100.
For all multiples of 3 and 5, the number is replaced ...
1
vote
2answers
154 views
Question on where to put code logic
I am developing a small compiler like tool. In the process, I wrote a Class<?> wrapper, JavaClass:
public class JavaClass {
...
public List<GenericEntry> getAllGenericEntries() ...
2
votes
2answers
364 views
Please Review my Generic Linked List Implementation in Java
I am looking for feedback on my Doubly Linked List implementation that I have written in Java. I am looking for specific feedback on the efficiency of my code, as well as my usage of generics. I am ...
1
vote
2answers
96 views
FooTest or FooTests? [closed]
Can't make up my mind. For a class Foo, should its test class be called FooTest or FooTests?
5
votes
5answers
405 views
Simple function in Java
This is a JUnit asserts for this function:
assertEquals(0, obj.generateListSize(0));
assertEquals(1, obj.generateListSize(1));
assertEquals(1, obj.generateListSize(2));
...
5
votes
2answers
364 views
Multithreaded log test
I'm writng a logger extension that allows multiple threads to log a process and then dump that log to the main log in one atomic operation. The point of it is to make the logs easier to read when many ...