dave hopkins

Greenhorn
+ Follow
since Oct 27, 2006
Merit badge: grant badges
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by dave hopkins

Here's the model answer list for those who wanted to check. Middle column being the number of potential matches.

http://pastie.org/8056214
11 years ago

Ryan McGuire wrote:I think I'd use a recursive method to solve this:



Wow! I just ran yours and it's an order of magnitude faster than my solution. Can you explain why?
11 years ago
I was looking at a Puzzle from a website called BrainBashers this morning. Here's the Q

During the recent BrainBashers cipher convention, a binary code contest took place. The contest consisted of a binary code transmission where the spaces between the letters were missing and there was no punctuation. Each letter of the alphabet was translated into its binary equivalent based on its position in the alphabet, a=1, b=10, c=11, d=100, e=101, f=110, g=111, h=1000, i=1001, j=1010, k=1011, l=1100, m=1101, n=1110, o=1111, p=10000, q=10001, r=10010, s=10011, t=10100, u=10101, v=10110, w=10111, x=11000, y=11001, z=11010. Can you find 10 countries?

101011000011110
101111110010110011
100001111110011110100
110100101111011101
11100010011100101
1101111110010111111111111
11010111011010011
10100110011011111110
1000011110111011
1101111111101111111110010011



I thought it would be interesting to write a program to give me a list of all the possible answers but I found it to be extremely challenging.

Here's my solution, it does work but I fear it's inefficient as for example the last country takes about 5seconds to finish. Any feedback appreciated!



The code for Letters is here to keep this post tidy.

http://pastie.org/8036886
11 years ago
So I've sat and watched my application in JMX, specifically the Memory tab. I was quite surprised to see the heap creep up to about 300MB. It does shrink down but in another 5 minutes or so, it's right back up there. I was curious to see what was actually inside, so I initiated a dumpHeap to disk (also from JMX). The annoying thing is that file created is only about 11MB small! I've tried it a few times, just to make sure I wasn't catching it at the wrong moment, but it hasn't seem to make a difference.

Can anybody explain this quite significant difference?

cheers!
14 years ago
I found it quite hard to follow your question to be honest. At a very high level, you seem to want to know if your plan is the best way to solve the problem. Unfortunately, both your plan and the problem are not well defined enough, that someone might be able to give some assistance. Some more clarification is needed I feel.
14 years ago
There's more to REST than just matching params dude. Forget code just for the minute and read up on the principles first.

Here's a really good article

http://www.peej.co.uk/articles/restfully-delicious.html
14 years ago

Prasad Kharkar wrote:I did the certification last month
and I find it really helpful for the basic knowledge about the java language


Yes, but he was asking was it going to help his CV.
Not a black and white answer I'm afraid. Some people claim that it really does assist your CV but I work with a guy who claims in his last place of work, they practically ignored it altogether.
Personally, I think it can't possibly do any harm having it on your CV but whether it's worth the £150~ exam fee is open for debate.
14 years ago
Awesome responses guys!
16 years ago
Thanks for that guys. But if the constructor is run before every test

Originally posted by Lasse Koskela:
I can verify what Jeanne's saying:

1) JUnit creates a new instance of the test class for each test method.



why is there a setUp() method?

thanks!
16 years ago

Also, you have no way of being sure the add test runs before the delete test.



I agree we should not be making assumptions about the order in which test cases are run but I can see for myself they are being run in the order they are written, so let us just assume this to be true for now.

This assumption is not correct. JUnit creates separate objects for each test case - at least in the version I tried.



Look at the code. I create r1 in the Test Object's contructor. What I believe you are referring to is the setUp() and tearDown() methods which is not what is being done here.

Thanks!
16 years ago

Originally posted by Stevi Deter:
Dave,

I think if you debug through the actual code in deleteRecipe, you'll discover
why the call to deleteRecipe is returning false and your test is failing.



Hmmm, nope still think it should suceed. We have:


So r1 is first passed to add recipe then the same r1 reference is passed to deleteRecipe. Therefore at some point this will be true

and so the method will eventually return true. I honestly don't see any other way for this to work???

cheers!
16 years ago
Hey guys! Have been doing some experimenting junit today but have hit a wee wall! I have the following code which I downloaded from a University website. I don't think you need to read any of the CoffeeMaker code to answer my question, but if you'd like to:
http://open.ncsu.edu/se/tutorials/junit/



My first test "testAddRecipe" works as expected, so I would then assume the second test "testDeleteRecipe" to work but it fails. I have traced the code through and it seems as though the CoffeeMaker object is reset after the end of the first test. There is no tearDown() method defined so I cannot see why this would happen?
17 years ago
Ok guys, thanks for the info!
17 years ago
So are you saying the two implementations of class B will use the same amount of memory?
17 years ago