Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!

Jake Monhan

Ranch Hand
+ Follow
since May 21, 2018
Cows and Likes
Cows
Total received
2
In last 30 days
0
Total given
0
Likes
Total received
5
Received in last 30 days
0
Total given
19
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jake Monhan

Junit can't destroy things it doesn't know about.



Of course I definitely agree with your point about taking care of such things as closing IO's and delinking resources which had been setup in the @Before and @BeforeClass sections, just being a responsible design. But then again as you mentioned in your earlier post, those steps should be taken in any application, not just in test applications.
5 months ago
Thanks everyone for your input. It loos like although I'm using JUnit4, some resource management in tear down method is good housekeeping practice.
5 months ago
I was wondering while testing with Junit; considering that the test runner holds strong references to all test instances, is setting different objects to null in the tearDown() method best practice to save resources, or should garbage collection be left to java?

Thanks
5 months ago
Thanks for the suggestion. I'll restructure a test using Maven and see how it turns out.
5 months ago
Let me start by saying that I'm by no means proficient with using JUnit, so if my question makes no sense, I appreciate all comments I can get!

When I use Junit I set up the test class in its own package different than the package that has the actual code being tested. Then I setup the class that has the runner to run the test class in a different package. Recently I was told that I was creating unnecessary packages and if need be I can have all the classes (source and test) in the same package, and even have the runner in the test class' main method and run the test that way.

I tried variations of the above suggestion, but all I get is "no test executed for project"!

So is there some best practices for using and running JUnit or what?

Thanks
5 months ago
Considering the number of different responses, it looks like it does come down to personal choice, unless effected by outside forces.

As for the UML part: besides one showing the class relationship, also creating one that shows the relationship of the methods within each class.  As to that end, sometimes it has helped, sometimes it is nothing more than too much information!

Thanks every one.
6 months ago
So looks like is a choice of does one want the UML diagram to show what each method does, and then how they all interact - VS - showing what functional call each method needs to make to another method and then defining that method.

That being said, I would hazard a comment that it all comes down to a combination of personal choice and case by case design need.

Thanks for the input.
6 months ago
Besides personal preference, is there a (for lack of better phrase) standard design way of sequencing methods in a given class?

By that I mean: given a simple example,



My personal preference has always been to define methods bA() and cA() in the class before calling them in method aA().  However I've seen that some others define aA() first, and the methods being called (i.e. bA() and cA()) are defined after the aA() method.

Thanks

p.s. I've left out Static and Instance considerations, because my question goes to design based on functionality grouping, rather than java execution sequence.
6 months ago

If you find a copy of Core Java II by Cay Horstmann or by Cay Horstmann and Gary Cornell, the IO chapter



Found it. I'll definitely be picking through chapter 2.

Thanks again.
7 months ago

I think it is called the decorator patter‍n, but I might be mistaken



As usual you are not mistaken. I looked into decorator design pattern and some examples online, and changing the design from abstract's IS-A to decorator pattern's HAS-A, hence modifying each I/O component behavior, saved me a lot of back and forth and much closer to the so-called streamlining the overall code that I was looking to do.

Thanks a bunch.
7 months ago
Yes I have. You just like to get on my case, don't you?


But Ron had it pegged. I was hoping that maybe there was a way that I could design an application that didn't have to have so many different types of Streams, since it has to both handle raw bytes and persist objects with local storage involved and on top of that transferring them (both raw bytes and objects) to remote storages.

Anyways, back to the tranches.
7 months ago
Hi,

I was wondering since FileInputStream and FileOutputStream have constructors that take file object, to simplify/streamline ones design,

1. can File I/O Streams handle the job when Object I/O Streams are typically used?
2. if not, is there some sort of rule of thumb as to when one must use the Object I/O Streams, and not File I/O Streams?

Thanks
7 months ago
Yes I added  Runtime.getRuntime().totalMemory() -  Runtime.getRuntime().freeMemory(); for both tail recursion and iteration versions, and the results were identical. I guess is possible for very certain applications the numbers may differ. But you're right, given the time savings of about 5% and even memory usage, it would not be worth taking much time to strike a balance between time and memory in this case.

But in general, is incorporating memoization as matter of norm to achieve any improvement - a good design?

8 months ago
oops that's what I get for running spell checker!

Tail recursion is what I used. When I timed the runs using System.nanoTime(); with 2 billion as the number limit in Fibonacci series, the time difference was about 5% in favor of memoization. So I posted the question to see for a gain a 5% speed improvement, is there memory usage consideration that should be taken into account?
8 months ago
Hello,

I was wondering when dealing with very large number calculations (i.e. Fibonacci series),  which of the two options below is a better design taking into consideration a balance between memory usage and speed-

1. Memorization method calling the method doing the actual calculations with recursion, or
2. Memorization method calling the method doing the actual calculation with iteration?

Thanks

p.s. I forgot to mention that in my memorization method, I'm just doing HashMap with cache.get() and cache.put().
8 months ago