# Prasma Kankut

Greenhorn
since Oct 15, 2003
Cows and Likes
Cows
0
In last 30 days
0
Total given
0
Likes
0
0
Total given
0
Given in last 30 days
0
Scavenger Hunt
Ranch Hand Scavenger Hunt
Greenhorn Scavenger Hunt

## Recent posts by Prasma Kankut

My laptop has a DVD-R writer. Can I use this drive to burn DVD+R discs? Or can I only use DVD-R discs?
14 years ago
Also is it possible to find the types of relations from a Java code?

Code 1:

Code 2:

Code 3:

I guess the Code 3 is an example for Dependency relationship. Is my understanding correct?
What about Code 1 & Code 2? Aggregation? Association?
14 years ago
How are the following relationships typically implemented in a Java program?

• Generalization
• Realization
• Association
• Aggregation
• Composition
• Dependency

• For example, Generalization is implemented as

and Realization is implemented as

What about the other relations? Can someone throw some examples?
14 years ago
Assume the following case:

The price to transport a shipment depends on 2 things
i) the distance from origin to destination and
ii) the weight of the shipment

For example,
If the transportation distance is less than 100 kms, the cost is 10\$
If the transportation distance is between 100 and 200 kms, the cost is 20\$
If the transportation distance is greater than 200 kms, the cost is 30\$

If the shipment weight is less than 10 kgs, the cost is 10\$
If the shipment weight is between 10 and 20 kgs, the cost is 20\$
If the shipment weight is greater than 20 kgs, the cost is 30\$

So, to transport a 50 kg shipment for 500 kms, the total cost is 60\$.

Now, the shipment will have a getTotalCost() method, which will calculate the total cost, based on the above rules. It can be done with simple if/else checks, but ofcourse that is the worst way of doing.

Is there any pattern, which can help me here?

Strategy looks close, but I'm not sure. Any clues.

Many thanks
14 years ago
Working in India / 6.5 years of Experience / Technical Lead / Current CTC = Rs 800,000.

I haven't made any job shift in my life...and now I don't know how much salary I should ask for.

14 years ago
Ilja Preuss: I am not sure - how do you pronounce Ilya?
In German, Ja is pronounced as Ya, Joern as Yoern and so on. So, I thought your name should be pronounced with the 'J' sounding as 'Y'.
Ilya - Il as in ill and ya as in Yard :roll:
Ilja Preuss: Don't be ashamed - you just grow a little bit again. "The fact that today we know more than yesterday is good news about today, not bad news about yesterday."
Thanks. I got a signature
Ilja Preuss: Right, I think.
You think? :roll:
Does it mean
a) There are many ways to do this. To you it looks ok, but others might think otherwise.
b) You are not sure whether this is the right way to do
c) You can tell for sure, only when you get the overall picture (meaning, there isn't much info to come to a conclusion)?
Ilja Preuss: Not necessarily. In fact, if done right it is a very powerfull technique to decouple your design, and thereby reduce complexity.
Okay. This mis-understaning looks a common problem with many novice. I'm not alone.
Ilja Preuss: I think it would be a good starting point. I had to see the resulting code to have further suggestions.
Ok got it. Actually there is no attribute like that, just guessed what should I do if I come across such situations.
And thanks for the links. My Favorites list keeps growing!
16 years ago

Originally posted by Thomas Paul:
There are a couple of articles about Struts in the JavaRanch newsletter.

Yes, I noticed it after seeing Frank's post. Written by you right? Good work. (but I should admit that your article on Struts was bit overdose for me . But hey, that article on Collections & Logging were excellent ).
Ok, coming back to the point. are you suggesting me to learn Struts? Good point, but the learning curve threatens me
So let me settle for a non-struts architecture for now.

Originally posted by Thomas Paul:

There is an open source Java forum ( http://www.mvnforum.com ) so maybe you can look at that for some ideas.

Thank you so much. That site looks great. They have an entire forum there to discuss the about it. Cool.

Originally posted by Thomas Paul:

One of the big things for forum software that uses a database is an intelligent caching mechanism.

Mmm...sorry I don't get you. Are you suggesting to use a database with is capable of caching data or is it that the application must have a caching mechanism?
16 years ago

Originally posted by Frank Carver:
including my "Simple Web Applications, the Friki Way" series in our very own Java Ranch Newsletter

I just went through the first few paragraphs. It looks interesting. I will come back with more questions after I finish reading all the parts.
And thanks for introducing the Newsletter. I was never aware of its existence before .
I went there and got lost - so much to read (and so much to learn )
16 years ago

Originally posted by Thomas Paul:
Make sure that your question is clear and concise and asked in the correct forum.
Is there a particular question that you would like answered?

I would like to get more responses for this thread
I know, it sounds silly, but thatz the truth.
And...hey I'm getting answers for all my questions now
I should have more patience.
16 years ago

Originally posted by <R K Singh>:

Did you
Try to find ...

Yes and No.
post a very elementary question to a forum where advanced technical questions are expected. See, this is exactly what my Conscience told me
But my initial post was not to criticize anybody. I feel very sorry, if it sounded that way.
I'm quite new to Java (to be frank, I'm quite new pragramming itself). My job is not to develop software and I know I'm too old to learn something new and get a job. I'm learning Java just to satisfy myself. Because of my lack of knowledge, my questions might sound silly among the experts here.
My initial post was nothing but a exposure of my self-pity
But sorry again, if that was hurting.
16 years ago
Thanks Andres.
Another question here: I have heard about Struts and many people are suggesting to use Struts framework. But I don't know Struts
What difference does it make? Is usage of Struts

a. Strongly recommended for these sort of applications
b. Recommended. But not necessary.
c. If you want, use it. Nothing special about it
d. Struts is not recommended for these sort of applications

Also, say if I develop this software with out Struts, how easy or hard it is to add that framework later? I mean, will it be a major re-work or just with some minor changes, I can make it Strut style?
16 years ago
Thanks Kyle and Ilja (how to pronounce it - Ilja or Ilya?)
See, how many times I have read about polymorphism, but couldn't realize that I can use it here. When will I grow-up? Shame on me
Just to make sure that I have understood the things properly, you are suggesting some thing like this.

Is my understaning right or wrong?
Few more questions:
#1. Is it okay to create more and more number of classes? Won't it make things complex? (sorry if this sounds silly, but I'm pretty new to OO)
#2. In the initial example, I talked about a single attribute. What if there are many such attributes in a same class?
For example, say there is another attribute validationPeriod.
If validationPeriod is "UNLIMITED",
don't use the endDate.
Else, use both startDate and endDate
Should I follow same suggestion and create another class ValidationType? (See #1 again)
#3. Kyle suggested something about the Strategy pattern. I tried to understand it by searching in Google, but all the examples given there uses Swings. Since I'm not familiar with Swings, I couldn't understand what they are talking about
Could you please explain how to use that pattern in the above example. Feel free to make your assumptions regarding the complete details of the class, if required.
Thanks again.
16 years ago
Thanks to everybody.
Some more questions regarding this.
i) Many people suggest aganist validating using JavaScripts for Internet applications, for the user can easily cheat the application. Isn't it true?
ii) Say, if I put the validations in Servlets or Struts, if tomorrow, they decide to have additional clients (say using RMI or Sockets), then I might end up duplicating the entire validation logic.
So, we end up with the suggestion given by William (an enhancement on option ii in my initial post). But is it okay to clutter the constructor with so much business logic?
Also from Kyle's post, I understand that Struts uses something similar to option iii mentioned above. So, another possibility is to mimic that behaviour.
Great. From 3 options, we are already down to 2 (eliminating option i)
Now, help me to make it 1
Thanks again.
16 years ago
Thanks Ernest, you got it right! Looks like it was the Oracle client which did the mischief.
But I can't get your point about the SecurityManager. Do you say this error will occur only when using Applets, RMI etc? But mine is a simple Java application.
Also, I noted another thing - this error occurs only when I use the java.util.regex package. Else everything is fine.
Does it mean that, the old JDK don't have this package and hence the error?
16 years ago
Hi,
I'm pretty new to Java and OO programming. I'm bit comfortable with the basics of Java programming, but still couldn't get hold of OO much
I'm trying to learn the language & concepts by doing some small projects, getting help from the experts here on the way. The project I have decided to give a try is to develop something like this site - JavaRanch Saloon!
So, I will post my ideas here. Hope you will correct me and give nice suggestions on the way.
First things first. What architecture should I select to develop such a site?
I'm thinking of using Java Servlets & JSP deployed on a Tomcat server, with MySQL as the database. Is this good enough? Or should I go for something fancier like EJBs? I don't prefer EJB for 2 reasons
i) I don't know EJB
ii) With a little knowledge I have, I think, EJB is not suitable for this sort of applications.
Am I getting it right or I'm wrong?
My selection of Tomcat & MySQL are purely because they are open source. You are welcome to give any better alternatives, so that I can learn something from your suggestions. But as for as this project is concerned, I have to stick to Tomcat & MySQL
Please comment on the above points. I will move on to next steps, once we finalize these questions.
Thanks in advance and hope to get many many replies
16 years ago