Swerrgy Smith

Ranch Hand
+ Follow
since Mar 26, 2010
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
25
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Swerrgy Smith

Hello,

I would like to know if a generational garbage collector visits all objects during a minor GC or it only visits the objects in the Young Generation?
If the answer is no, how can it do this? Because in my understanding, it has to start from a "root" and visit all reachable objects from this "root". There is no way it can knows in advance which objects are in the Young Generation and which objects are in Old Generation.

If the answer is yes, how it can be better than a traditional garbage collector while it also has to spend time to visit all objects.

Thank you very much.
2 years ago
Thanks Jeanne, it works better than my first version but it seems that I still have to to some kind of type cast in the method if I really want to use the list and add some element. Is there anyway to avoid completely the type cast?



Jeanne Boyarsky wrote:This works. It doesn't use the enum, but keeps it to preserve your method signature:

2 years ago
Hello all,

Suppose that I have a super class Animal.java and sub-classes Dog.java and Cat.java
How can I write a "factory" method that return a list of Dog or Cat based on the parameter without explicit type case.

For example:


And I think of the factoryMethod signature like that:


However, this code doesn't work.

If I use explicit type cast then it work but that's what I want to avoid:

Can anyone help me?

Thanks a lot.
2 years ago
Hello all,

I have to merge regularly from a trunk and a branch using tortoise SVN.
Can you please tell me how to check what revisions I have merged from the trunk and the branch?
(I want to make sure that I do not forget to update anything from the trunk the the branch)

Thank you very much
Hello,

Thanks for your reply.
I have another questions: How can I know which revisions I already merged to the branch? (In case I already forgot my activities in the past)

Thanks very much
Hi all,

Suppose that I have a trunk with revisions from 1-30 (HEAD is 30th revision) and a branch which I create after I committed the 10th revision.
What are the differences among the 3 scenarios below:
1) Merge a range of revisions from 15-HEAD (as can be seen in the text box in the attached picture) to the branch
2) Merge the HEAD to the branch (the text box contains "HEAD")
3) No revision from the trunk is specified (the text box is empty)

Thank you very much.

Jaikiran Pai wrote:I had the IDE open in front of me, so I just tried it in debug mode. Clicked "Evaluate expressions" and then clicked the "Code Fragment mode" button and in the top area editor entered:



and then hit the "Evaluate" button. The output, 7, was shown in the "Result" text area. See screenshot for details.



Yes, I know what you mean. However, it seems that we cannot do something more complex as we can do with Eclipse.
For example, I have a Set<String_FullName> named infoSet that have 100000 elements. In "Display View" of eclipse, at one break point I can enter some code to verify whether this set contains the name "Robert" or not. I can insert my code as:



In the "Evaluate expressions" I don't see I can do this.
Hi all,

In Eclipse, we can open "Display View" to enter some code and execute this code while debugging.
In IntelliJ, how can we do it? I already tried "Evaluating Expressions" but it seems that I can only see values of variables and I cannot enter my customized code (even in "code fragment evaluation" mode).

Thank you very much.

Gregg Bolinger wrote:You should name your test methods based on what you're attempting to assert. For example, suppose your class Biz has a method called calculateTotal(). You might name your test methods as such:



Test methods should be as well defined as your methods being tested. testCalculateTotal_xxx is a bad idea.



Thanks for your excellent advice, Gregg.
4 years ago
Hi all,

Suppose I want to test the method doSomething() of the class Biz; I create a test class BizTest.
If I want to write many test methods to test doSomething(), how should I name these methods? I am thinking of some thing like: testDoSomething_1(), testDoSomething_2() ... but it will look like a automatically generated test (and not a test written by a person); furthermore, it will not tell the nature of each test (e.g. what the test method testDoSomething_1() is supposed to do).

What do you think about that? Or should I write only 1 method testDoSomething() and put a lot of assertxxxx inside?

Thanks for your advice.
4 years ago
Hi all,

Can you tell me why we always need to use a class (or a name of a class) in the getLogger method?


Why don't we simply use a same name (for example "ABCDEFGH") for every .java file ?


Thank you very much.
Thank Henry for your replies.

I also found a very helpful answer to my question here:
http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html

As I understand from the article, the most EXPENSIVE operation is not to mark the objects (i.e. traversing the object tree) but it's the compacting process.
Using Generational GC can help optimize the compacting process. Instead of compacting the WHOLE heap memory each time, the GC just needs to move all the "survived" objects from the Eden region to the Survive regions (first S0, then S1). After this "moving step", the Eden region, which is the busiest region, is clear and ready to use.

In this model, the compacting process is done much less frequently and only with the old generation region.

Please correct me if I'm wrong!

Thank you all.
4 years ago
Hi all,

I would like to know how we can deploy one Web application on multiple server to share the work between them?
My first thought is that we just deploy the same war file on different servers that connect to the same database. However, what will happen when a user enter something like www.webdomain.com ?
How can multiple servers share the same domain name and how the requests from different users are redirected to these different server?

Any help will be very appreciated!

Thank you very much.
4 years ago
Hi all,

I don't understand the real benefit of a generational garbage collector. As I understand, the generational garbage collector divides heap memory in different region and the young generation region (Eden region) is visited more frequently than other region. The purpose is to REDUCE THE TIME NEEDED to collect the unused objects because most of the objects have a short life.

However, the GC still have to traverse ALL THE OBJECT TREE from the root set and visit all the objects, even if these object are in older region (tenured region). How can the time be reduced compared to a garbage collector which does NOT use generational model? Because in a non-generational GC, the GC also has to traverse ALL the object tree from the root set.

Thank you very much.
4 years ago
Hi all,

Suppose I have



Why this doesn't work while A is a super type of B ?

4 years ago