Win a copy of Rust Web Development this week in the Other Languages forum!

Justin Allen

Greenhorn
+ Follow
since Feb 02, 2011
Justin likes ...
Eclipse IDE Chrome Linux
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
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Justin Allen

Hello all, I work on a mid sized java project currently and we are currently using seralization to copy most of our java objects. This process bothers me because for some of our bigger objects serialization takes forever! So I've been reading about using clone() and/or copy constructors. Here is an example object in our system:



now I know this class would have to implement Cloneable interface for us to use clone but my question is since we have other objects(List of values) in this object I would have to explicitly handle them in the clone method for them to be copied correctly?

so something like this:



My second question is about copy Constructors, I have read in Josh Bloch's book Effective Java that a copy constructor something like this:


but my question is would this, how would the implementation be, would it be this:


Thanks for the help everyone.
9 years ago
I will. I think my general approach for now, will be trying to get the synchronization out of the system slowly. We have lots of instance's of Vector's and Hashtable's floating around that I think can slowly be converted to List's and Map's of various kinds. I need to do more investigation into my system to determine what really needs to be in the session and what doesn't and also what really needs to be synchronized, because it is my feeling right now that alot of the stuff that is synchronized has been done so for no good reason.
10 years ago
Excellent, thank you for all the good information. Unfortunately my system uses a lot of ajax and has been deployed in production for a while. I've been tasked with improving the performance, so I will take what you've told me and try to refactor the code I have to use the session less and less where I can. Thank you!
10 years ago
Thanks for the information Bear, that is very helpful. One followup question if we do add things to the user session would be it be best to synchronize mutators on those objects? Or should I just do some more investigation about how sessions are shared in tomcat?

thanks!
10 years ago
So I've just started a new job and we've got a traditional web app setup(Tomcat, Struts1, Sybase DB) and I have a question about design and synchronization. I've worked on a previous web app and all of our beans were never synchronized. We just created a new set of object's for every user and then served that information up. Now on this application the have decided to synchronize some of their operations on information. Is there really a need to do that in a web app? If you give every user a new set of object's there should be no problems with one user modifying another's information? They should all write to the DB and if one user is modifying the same information as another, the DB will just over-write the older information?

If we didn't share any of the objects between requests(meaning we create a distinct set of objects for each request) there should be no need for synchronization correct?

thanks!
10 years ago
I don't think passing the SCJP could hurt you at all. I think cole is right that getting a CS degree can also help. But don't be scared to get an IS or IT degree, my degree is in Management Information Systems, and I've been working in software development since I graduated from college, about 11 years ago. If you are interested in java I would do as much coding as you can. Whether that be for an open source project or just stuff for yourself it doesn't matter. It is always a good start to get open source projects and at least start looking at the code and get an understanding for how enterprise projects work, they are free and some of them have very complex workings. Other than that I would start seeing about internships or entry level jobs.
hello ranchers, I have a performance question about a web application that I've recently started working on. The codebase for this app is on the larger side, for me anyway, 450 java files and has been around for about 2 years. We use struts1 and tomcat. Here is a jconsole screen shot for the past day and a half or so. Now the million dollar question that's gotten me head scratching.

I can see during the day we get spikes in memory and threads, but even in the dead of night our processor seems to be constantly pegged. I'm not sure what type of horsepower we have on the box itself but is that where I should start looking or should I start looking at our processing code? I know this is very vague and there are lots of things that need to be fixed in our code but I was hoping to get a general impression based on the image.

thanks!
10 years ago
YES! It worked, i think it was deleting and re-creating my run configuration. Thanks so much for your help!!!
10 years ago
Jeanne, thank you for your response, I will give your idea's a try. FYI, ListLookup and EventManager are in named packages, I just took them out because I work for a major company and wouldn't want anyone getting upset if they saw my code on this website. I do have them imported correctly, I just dropped them for the sake of this post.


thanks

Justin
10 years ago
I'm trying to setup eclipse to run Junit tests. I have created this simple test-class :



I setup junit to run this test but I get this exception when running:

java.lang.Exception: No runnable methods
at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:158)
at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.ParentRunner.validate(ParentRunner.java:349)
at org.junit.runners.ParentRunner.<init>(ParentRunner.java:73)
at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:57)
at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:13)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestMethodReference.<init>(JUnit4TestMethodReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:54)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

I'm obviously doing something wrong, but I haven't been able to pinpoint what. Any help would be greatly appreciated.
10 years ago
I found this link online and it is super in-depth, maybe a bit to much but here you go:

Generics FAQ
I have used enthuware and K&B so far and I would say you should get the Java OCP Java SE 6 Programmer Practice Exams book from Berts and Sierra. When you can complete those tests successfully, I would say you are ready. The book tests are the hardest ones that I've come across. Here is the amazon book url

Yadrif, I was having some problems with this and then I wrote this little test program to help:


So this is how it breaks down:
scores[0] is {5,2,4,7}, scores[1] is {9,2}, and scores[2] is {3,4}.
Then scores[0][0] is 5, scores [0][1] is 2, scores[2][0] is 3 and so on.

The key is that the first dimension of a multi-dimensional array is an array of objects, and the second dimension is the object's themselves in this case, ints.
I think I have it now, here is what I see as happening:

when the a = b evaluation happens we get the third element(4th) of the b array which is 0, then evaulate that as the 1st element of the 'a' array, which is 1.

Thanks everyone for the help
So I was taking an mock test on enthuware and came across this question:


The code compiles and prints 1.

I am confused by what's happening in the println statement.