Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

Henrique Boreg

Greenhorn
+ Follow
since Aug 11, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
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 Henrique Boreg

Thanks for the reply.

I've implement the solution by running the "email sender" on a separate thread with MIN_PRIORITY like so:


When I run this code it works fine, but even with min_priority set I am getting a 50% CPU usage.

Is there a way to improve this loop inside the "run" method so it can just sleep until a new email address has been added to the queue?
Thanks.
13 years ago
I am developing a feature where I will eventually have to send out lots of emails to different addresses. Since this is done through a mouse button click event, I want to have a different process separate from the web application which will be in charge of actually sending out the emails.

I am having trouble figuring out the best way to design this. I've thought about starting a new java Thread to send out emails but I'm not sure I want to do multi-threaded stuff inside a button's click event inside a web page. I've also thought about developing a separate application which would work as a kind of a standalone server whose only function would be to send out emails.

Any better ideas?
Thanks.
13 years ago
My DB schemas are as follows (I am only showing the tables and columns relevant to this problem):

Table: User
- userId

Table: Message
- userId (the mesage was written by this userId)
- message_contents (the actual contents of the message)

Table: FriendsWith
- userId (this userId has as a friend 'friendsWith')
- friendWith (this is also a userId from an existing user)


So, if I wanted to know what the latest status updates of a User's friends were, I would have to first fetch all of the User's friends, then for each one of those friends, fetch their latest message contents.

This to me seems like too many sql commands for a simple feature. I was wondering if there was a better strategy for similar issues, maybe modifying my DB schemas, or adding data redundancy, etc.

Thanks.
13 years ago
Hello, I am developing a twitter-like service and am having a hard time to find the best solution for the following issue:

When a user logs in, he sees a list of all of the latest status updates from their friends.
The way the system is built now, there is a simple relation between the user and the status updates they post. This relationship is: a user has many messages (the same architecture is maintained in 2 different tables in the database: User and Messages).

If a user logs in, and this user has for example 50 friends, I want to avoid executing an SQL SELECT for each one of his 50 friends so that he can see a list of all of the latest status updates from his friends.

Does anyone know a better solution for this or have any idea how this feature is usually implemented, without jeopardizing performance?

Thanks.
13 years ago
thanks for the reply Ernest, it was really helpful.
16 years ago
Hello, I was looking over the Rectangle2D class in java.awt.geom, and I came across a method that given an (x,y) point, returns its relative position to the rectangle (eg. left, right, bottom or top). Pretty much, the whole method is:


my question is, what exactly is going on in the assignments such as out |= OUT_TOP | OUT_BOTTOM ??

ps. OUT_LEFT = 1, OUT_TOP = 2, OUT_RIGHT = 4, OUT_BOTTOM = 8

Thanks.
16 years ago
I tried it using the command line as you said and was able to see the runtime error it was throwing...turned out to be that some of my configuration files looked for *.png to load while some of the actual files were *.PNG...renaming them all to lowercase solved the problem. Thanks.
16 years ago
This problem has probably been posted before but I couldn't find it in the beginner forums..sorry if it has already been answered.

My file structure is simple, I have all of my resource files (images, sounds and configuration files) inside my working directory. To load these files, I use their relative path using URL, for example, to load the images:
URL url = this.getClass().getClassLoader().getResource(fileName);

When I jar all of these files, I end up with something like this (inside the jar):
Model // java package
GUI // java package, where my main class is located
META-INF
a.jpg
b.jpg
...
...

and my manifest file looks like:
Manifest-Version: 1.0
Main-Class: GUI.Game

The main class gets executed fine, but the images don't show up, so I guess they are not located by my code. Any ideas how the jar file should be so as to fix this problem?

Thanks.
16 years ago
worked perfectly, thanks.
16 years ago
Hello, I have a class Photo which contains 3 String member variables(name, title and date), and I am using another class which extends AbstractListModel to handle a JList. Inside my AbstractListModel class, I have a List object which will hold Photo objects, like this:



The thing is that my JList displays the current Photo object's reference, like Photo@f6a746 for example. Any ideas how I can still have my JList hold Photo objects but display its title attribute instead of the Photo object itself?...So the JList would actually be displaying:
Photo.getName() instead of Photo.

Thanks.
16 years ago
Its fixed now, the problem was an EOFException not being handled. Thanks anyways.
16 years ago
Hello, I am using object serialization to write objects to a file. Since I have lots of objects of the same type, I use a for loop:


This works fine, but how can I load all of these objects back again using the same loop approach, i tried the following:



This appears to work when I print out the results and they match the same values that were initially serialized, but I various Exceptions. What is the correct way to loop through all of the serialized objects until an EOF is reached?

Thanks.
16 years ago
Oh, I couldn't find my way around that, now I see how it can be done, thanks Ernest Friedman-Hill
16 years ago
What I would actually be trying to accomplish is rewrite the default equals() method of a class with a certain comparator which is sent to a method as an argument, not specifically having this class implement Comparator. Is there any way to do this?

Thanks.
16 years ago
Hello..
I have a class implementing Comparator and I don't want the compare(Object o1, Object o2) method to be defined, so I could send a Comparator as an argument so it would compare objects of that class using diferrent comparators.

For example, say I hava a ContactLit class which has a list of contacts (int id and String name), and I want one comparator to compare using the id and the other one using the name, so that later on I could maybe have a customized getContact(Comparator criteria), which would receive the comparator criteria to be used to fetch the results instead of having 2 distinct method logics for getContact(String name) and getContact(int id).

Thanks.
16 years ago