Clarice Doe

+ Follow
since Dec 24, 2004
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Clarice Doe

Can you suggest some cool, funny & creative usage of annotations in Java? I need it for a traning (on custom annotations) and all the examples I could find (like unit testing, cross cutting etc) are boring.

12 years ago
I need to stay in UK for 2 months. My office is at a place called Apsley (in Hertfordshire). I don't have a car and so I need to depend on the train services. Could someone suggest a good place to stay near to this area? (it is okay even if I have to travel for 30-40 minutes, provided the railway station in close by and there are frequent train service)

Also, will it be possible to get some furnished apartment for rent (for 2 months)? I ask this question, because I had a tough time finding an apartment for such a short duration in US.
12 years ago
We are building a small testing tool to test an external interface. The external interface exposes some methods. The user has an option to select which method he wants to test (say through a drop down in a web page) and provide the input for the method (say XML) in a text field. When he submits the form, we need to call the selected method with the input value.

Now, I'm not able to get the abstraction right. I don't want to put a big conditional (if-else / switch) block to decide which method has to be called based on the option selected by the user.

Is there any elegant solution for such problems?
Thanks for the link. But that doesn't actually answer the question.
The examples given in that link, doesn't use any constant values. The where clause keeps changing all the time.

Let me give another example on the same line as mentioned in the link

Does code A perform better than code B or not.

Code A:

Code B:

I will try it and will let you know. But meanwhile, any guesses?
[ October 04, 2005: Message edited by: Clarice Doe ]
Say, I want to insert a row with two values into the database using a PreparedStatement. If I'm sure that one of the value is always going to be the same, I have 2 options

Is there a performance difference between these two approaches? My friend says that PreparedStatement works better, if and only if all the values are bind at the runtime. Even if we fail to specify a single value as a bind variable, it will work as if it is a normal Statement.

I find it difficult to buy this argument. Will it really make a difference? If yes, why should it be?

I thought I will get some comments from the experts here before I try to measure the performance and find it out myself.

Any comments?
I have 3 columns in a table say, A_DATE, A_TIME and A_DATETIME. The data type for all the columns is DATE.

Now I want to take the date part from A_DATE, time part from A_TIME, and insert those date & time values into A_DATETIME.

I could get the date & time part from the 2 columns using to_char funtion, but I don't know how to merge them and put it in to the third column. Any suggestions.

I think I figured it out. Will this solve the problem? Please confirm.

var StrRE = /^[\w.\-]{1,}[@][\w\-]{1,}[.][\w.\-]{1,}$/;

Originally posted by Eric Pascarello:
The reg exp I usuaully use is

var StrRE = /^[\w.]{1,}[@]\w{1,}[.][\w.]{2,}$/;

Hi Eric,
As per this expression, the character "-" is invalid in a email field. What change should I make to the above regular expression to make "-" (or any other character for that matter) as a valid character?

Thanks for all the replies. Let me take a different example.

The service charge for shipping a product is 5% of the cost of the product.
The service charge is exemted (0%) for some products (say goods shipped to Red Cross).
An additional 2% of service charge is applicable to all products which has to be sent via express service.

So, we have the following possibilities

Normal product & ordinary service: 5%
Red cross product & ordinary service: 0%
Normal product & express service: 7%
Red cross product & express service: 2%

The idea is to calculate how much each product costs (cost + service charge) and what is the total service charge applicable to a cargo pack (which can have multiple products).

Based on your suggestions, I have come up with the following design. Let me know your inputs.

I will go ahead and assign a suitable instance of ServiceCharge type to each product depending upon the business rules (Does Factory Method pattern fits here?). Now I have some questions

i) Whether the getServiceCharge() method should return just the percentage or should it calculate the service charge and return the actual amount (for this I need to pass the cost of the product to this method).

ii) How do I handle the ExpressServiceCharge? As said earlier, ExpressServiceCharge is an additional Service charge applicable to all products sent in a express service. I'm not able to find a way to represent this relationship properly.
The employees of a company are divided into various types based on the allowances they get.

i) Employees who just get their salary.
ii) Employees who get salary plus a 20% of their salary as bonus
iii) Employees who get salary plus a 20% of their salary as bonus plus 10% of their salary as a super bonus.

The payroll application should calculate the pay for these employees based on the above mentioned rules. (it is essential that the payroll application should be able to get the salary and bonus parts separately)

How do I go about designing this?
Should I have

Employee class:
PreferredEmployee extends Employee
SuperPreferredEmployee extends PreferredEmployee

or should I have a single abstract class at the top, and all these 3 types of employees are derived from that abstarct class?

Also, in any case, the Employee object needs to implement a getBonus() method, which always returns a zero. Is it a good way of implementation?

I have number of Employee objects and a number of company objects. Now I want to assign some employees to one company, some other employees to some other company and so on.

In OO terms, a company has zero or more employees and an employee is associated with one and only one office. In Java code it translates to

But is this sort of circular reference (company holds employee and employe has a referece to company)acceptable? Is there a better way of putting it in code?

[ September 06, 2005: Message edited by: Clarice Doe ]
For traversing a graph, which is the better way - Breadth First / Depth First? Or is it something related to the problem we are trying to solve?
Can someone give few example scenarios where these different strategies are suitable?

Apart from some general scenario, I have a specific example.

Assume there is a graph representing an airline network (where vertices represents the airports and the edges represents the flight paths). If I'm interested to do the following tasks on that graph, which is better - Depth First or Breadth First?

a) To find different possible routes between a pair of cities
b) To find the distance of route between some cities.
c) To find the shortest path between a pair of cities.

13 years ago

Originally posted by Vijayendra V Rao:
Show me a program without a single class in it first and then I will answer your question!

I can't. It's a syntactic requirement of Java (you can define interfaces & enums, but they don't count as a program, for they can't function independently).

Can you now answer to the question "Why Java is not fully object oriented language?"

Originally posted by Vijayendra V Rao:What does a class encapsulate?! Think!!!

It encapsulates state and behaviour. But, what effect does that has on whether Java is OO or not.
13 years ago
Thanks for all the replies.
I got the problem. The issue is that the tar compresses empty folders. But when I transfer it to Windows system, and extract it using WinZip, the empty folders are missing (WinZip is not showing the empty folders, even when I view the contents of the tar file).
Now, how can I extract the tar file in Windows, with out any problem?
14 years ago