aspose file tools*
The moose likes Ranch Office and the fly likes problem with finding index of a string? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Ranch Office
Bookmark "problem with finding index of a string?" Watch "problem with finding index of a string?" New topic
Author

problem with finding index of a string?

J radolf
Ranch Hand

Joined: Jan 08, 2009
Posts: 121


[HENRY: This is a spin-off topic... from this one....

http://www.coderanch.com/t/449028/Java-General-beginner/java/with-finding-index-string

]
santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Posts: 296
[MG]Edited content. Please do not provide ready made answers. Ref David's post below


Creativity is nothing but Breaking Rules
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

NotACodeMill

Don't just blindly supply answers: the point is to help people learn, and learn how to learn, not do their work for them. If the OP was in a class, for example, you just did their homework for them.

(Btw, I knew someone named January once. And Carrot. One never knows...)
santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Posts: 296
Please do not provide ready made answers.



Sorry for binding the answer.But i had not given any ready made answers please don't think that people will give ready made answers .
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Whoops, I was looking at Collection--never mind.

Still shouldn't blindly provide answers, though: provide resources, assist the poster's thought process, etc. Handing them solutions on a plate serves no one.
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
You know, this thread addresses some very important issues about the way people learn. I respect the intent of the experienced people here who say that to just give someone the answer serves no-one. Certainly that is true if the OP is only interested in the solution. The idea is to help someone learn, and I fully support that ideal.

However, consider the following, which is based on my learning experience, and also many others because I don't think I'm all that unique in the way I learn things. Anyways, in many situations, I think the best way to learn something is to start with something that works and then figure out how, why it works, or how the solution fits into the java "philosophy. Certainly there are many times when I have gotten much mileage out of a "solution" that was handed to me. I was then able to go back and much more easily understand the material that was presented in something like the Java Tutorial or the API docs.

Anyways, I am just trying to say that very often an effective starting point to learning is to be given the answer. It all depends on what "the learner" does with that answer.

Just my two cents, hope it isn't out of place in this thread. Perhaps a separate thread where this issue can be discussed would be appropriate.



Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18997
    
  40

However, consider the following, which is based on my learning experience, and also many others because I don't think I'm all that unique in the way I learn things. Anyways, in many situations, I think the best way to learn something is to start with something that works and then figure out how, why it works, or how the solution fits into the java "philosophy. Certainly there are many times when I have gotten much mileage out of a "solution" that was handed to me. I was then able to go back and much more easily understand the material that was presented in something like the Java Tutorial or the API docs.


Well.... Do you regard the process of arriving at the solution, instead of having a solution handed to you, as useful learning? Do you regard having an incorrect solution, and learning why its an incorrect solution, as useful learning? Do you regard "accidentally" learning something that is related, but not really what you needed, because you didn't know better, as useful learning? Do you regard all the "debugging" and "testing" that you had to do, because you didn't have a working solution, as useful learning?

Yes, if you only regard learning the exact subject that you need, as learning, then reviewing a working solution is the best way to learn.... But then again, how would you know that the working solution that was handed to you, isn't some crappy code that barely holds together?

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Henry Wong wrote:
However, consider the following, which is based on my learning experience, and also many others because I don't think I'm all that unique in the way I learn things. Anyways, in many situations, I think the best way to learn something is to start with something that works and then figure out how, why it works, or how the solution fits into the java "philosophy. Certainly there are many times when I have gotten much mileage out of a "solution" that was handed to me. I was then able to go back and much more easily understand the material that was presented in something like the Java Tutorial or the API docs.


Well.... Do you regard the process of arriving at the solution, instead of having a solution handed to you, as useful learning? Do you regard having an incorrect solution, and learning why its an incorrect solution, as useful learning? Do you regard "accidentally" learning something that is related, but not really what you needed, because you didn't know better, as useful learning? Do you regard all the "debugging" and "testing" that you had to do, because you didn't have a working solution, as useful learning?

Yes, if you only regard learning the exact subject that you need, as learning, then reviewing a working solution is the best way to learn.... But then again, how would you know that the working solution that was handed to you, isn't some crappy code that barely holds together?

Henry



First Question. It's useful if it's reasonably efficient, but it's not the only way to skin a cat, and besides, we all operate under time constraints. Second third and fourth questions I would yes, are all useful, but not the only way to learn, nor should one have to go through that process every time. As for how do we know that that the solution isn't crappy, well jeez, anything is possible, one would hope that a solution that is handed to you is good, but I might just as well ask how does the OP know your suggestions aren't crap, if he hasn't the experience to tell good from bad? Of course having been here a while, I know that any answer you have given me has been very helpful, but an absolute newbie wouldn't, would he?

Anyways, it all depends on our short term and long term goals. I'm not trying to say that my suggestion was best, and especially not the only way to go, just that a statement such as "There is no value in handing someone a solution" is in and of itself not true, and it also involves making assumptions about what is "the right thing" for the OP, which seems somewhat presumptuous. Like I said, it all depends what the OP does with the information he/she is provided.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Handing someone a solution may also come down to literally doing their homework for them. What's the point of having someone do your homework for you?

And I have *zero* issues being called "presumptuous", particularly when this *purpose* of this site is to encourage people to learn how to learn and to figure things out for themselves. These issues are addressed in FAQ entries:

ShowSomeEffort
NotACodeMill
DoYourOwnHomework
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
David Newton wrote:Handing someone a solution may also come down to literally doing their homework for them. What's the point of having someone do your homework for you?


David, I agree with you. There is no value if that's all it is. But I respectfully submit that maybe by taking such a stance you are making an assumption that the OP doesn't know what his best for himelf. Like I said, it all depends on what the OP does with the info.

And besides just because handing someone a solution is sometime a bad idea, it doesn't mean we should never do it.

I know from where I speak. There have been many times when a solution was handed to me, or I've found it via Google, and that solution has been a gateway to improved learning. Because I used the solution appropriately. I want to learn, I am not interested in just plugging some code I find into my project and if it works forget about it, and I don't think "we" should start making assumptions that that is what people are going to do.


OK David, I saw your update, duly noted. All I am saying is that there is (sometimes, often, maybe not most of the time) value in being handed a solution., and I explained circumestances. If you are saying there is never value, we'll have to agree to disagree. If you are saying that "this particular site" does things such and such a way, then I guess I have to play by the rules, seeing as how it's not my site.

This is more than people doing what they want, people are being told what to do.

regards.


David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Re-read the ShowSomeEffort FAQ entry. No effort was shown.
I don't think "we" should start making assumptions that that is what people are going to do.

So we should hand people answers since they *may* use it appropriately? Or should we ask "Excuse me, will you use this knowledge appropriately?" Or should we just follow the policies already in place and encourage them to think it out? I vote for the last one.

We'll have to agree to disagree: you answer questions how you want, I'll answer them how I want.
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
David Newton wrote:Re-read the ShowSomeEffort FAQ entry. No effort was shown.
I don't think "we" should start making assumptions that that is what people are going to do.

So we should hand people answers since they *may* use it appropriately? Or should we ask "Excuse me, will you use this knowledge appropriately?" Or should we just follow the policies already in place and encourage them to think it out? I vote for the last one.

We'll have to agree to disagree: you answer questions how you want, I'll answer them how I want.


I honestly think you have drawn conclusions that don't necessarily follow from my original points. But if you are saying that there is never value in being given a solution, then yeah, I am happy to agree to disagree on that point.

regards.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Look: in a forum for beginners the whole point is to encourage them to figure things out for themselves. I don't see this as a difficult concept. There are answers-on-plates all over this site in contexts where it makes sense--but when it doesn't, it's more likely that people will receive hints, things to think about, links to documentation, and so on.

If you're going to continue this conversation it should be moved to the ranch office or somwhere else; it doesn't belong here.
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
David Newton wrote:Look: in a forum for beginners the whole point is to encourage them to figure things out for themselves. I don't see this as a difficult concept. There are answers-on-plates all over this site in contexts where it makes sense--but when it doesn't, it's more likely that people will receive hints, things to think about, links to documentation, and so on.

If you're going to continue this conversation it should be moved to the ranch office or somwhere else; it doesn't belong here.


Look: I don't see that being given a solution always precludes useful learning. Like I said, it depends on what you do with the information. Sure have this moved.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18997
    
  40

Fred Hamilton wrote:
I honestly think you have drawn conclusions that don't necessarily follow from my original points. But if you are saying that there is never value in being given a solution, then yeah, I am happy to agree to disagree on that point.


Fred,

Then we are all in agreement ...

Seriously though, feel free to disagree with the policy, but please don't just hand out answers to homework questions.

Henry
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18997
    
  40

Sure have this moved.


Okay, I will move this to the Ranch office forum -- and separate the topics. Please refrain from posting in the next few minutes, as it will likely not make the move.

Henry
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18997
    
  40

Okay, topic moved... and deleted a bunch of stuff... whew!!

You may continue the discussion now...

Henry
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
I don't have much else to say, I agree about homework, and will take extra precautions to make sure I don't violate the spirit of what homework is all about.

Also, I'll do my best not to give out solutions or rewrite someone's code. At most , if it looks like circumstances warrant it, I may provide a working prototype to isolate and illustrate a particular concept.

And if I step over the line on these points, I'll be happy to comply with the requests of a moderator.
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20693
    ∞

Hooooo Doggy! What a debate!

Well .... here's another opinion tossed on the pile:

I think that somebody can earnestly struggle with a problem for a long time and come up with nothing. And then they see "the solution" and get a big bucket of learning.

I also think that they usually figure it out for themselves long before getting to that point. So this is a sort of "once in a long while" sort of thing.

And "the solution" can come in a lot of flavors. Rather than the fully developed app, it can be something like "unroll the loop and it will all work."

Of course, to figure out when to spill the solution and how much to spill is a big mix of speculation, mind reading and getting that damn crystal ball to work. And when you are riddled with people trying to cheat, it's kinda hard to step out of the mode of trying to impede the cheaters and help the honest folks when you have a situation of an honest person asking for the same thing that a cheater is always asking for.

The easiest thing for the helpers is to just not spill the beans all the way.





permaculture Wood Burning Stoves 2.0 - 4-DVD set
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Well said, Paul.

I've been into java for a couple of years, and I have a fairly good idea of how the Class Heirarchy works, and the basic philosohy of java, and all that.

In the last week or so, I have gotten started with JDBC. The first thing I did was look for a couple of working prototypes, one of connecting to a database, the other of executing some SQL queries. These were asy enough to Google. By spending a couple of hours looking over these examples, and relating then back to the API docs, I gained more understanding of the overall JDBC system that I would have spending 8 hours working through the SUN Tutorial. Now when I go back through the tutorial, it all makes much more sense than if I had started there without the prototypes.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11509
    
  95

Speaking as an author of a book designed to help readers with a certification, I find this a very interesting topic. One of the biggest issues we faced when writing our book was ensuring that we did not give away a solution to the assignment.

Effectively what we did with our book was as per Fred's suggestion:
Fred Hamilton wrote:
At most , if it looks like circumstances warrant it, I may provide a working prototype to isolate and illustrate a particular concept.

Our entire book is based on that premise: if you read the book and/or just download the sample code, you will find examples of concepts. When you understand the concepts then they can be easily applied to the assignment. Almost every line of code is explained in the book itself, so we hope we did a good job explaining the concepts. However if you don't try to learn from the code / don't try to understand the concepts behind the code, then the code itself will not work for the certification assignment.

Working out how to explain a concept without providing the solution to the problem can be very difficult. But it can help the reader immensely.


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Andrew Monkhouse wrote:Speaking as an author of a book designed to help readers with a certification, I find this a very interesting topic. One of the biggest issues we faced when writing our book was ensuring that we did not give away a solution to the assignment.

Effectively what we did with our book was as per Fred's suggestion:
Fred Hamilton wrote:
At most , if it looks like circumstances warrant it, I may provide a working prototype to isolate and illustrate a particular concept.

Our entire book is based on that premise: if you read the book and/or just download the sample code, you will find examples of concepts. When you understand the concepts then they can be easily applied to the assignment. Almost every line of code is explained in the book itself, so we hope we did a good job explaining the concepts. However if you don't try to learn from the code / don't try to understand the concepts behind the code, then the code itself will not work for the certification assignment.

Working out how to explain a concept without providing the solution to the problem can be very difficult. But it can help the reader immensely.


Cool. In the case of your book, it's a good approach. So maybe we need to ask ourselves what is the difference between a prototype and a solution? IMO for someone who is here on coderanch to help others learn, it's not so clear. For example, I could ask someone in a forum here how to put together a complete example (prototype) of connecting to a database, performing a query, and disconnecting. Then someone here might balk at actually providing such an example. on the grounds that it is just giving an answer. Which is fair enough. so I look elsewhere, find my prototype, change a few values to match my environment. and it works. And I learn a 'bucketful" in the process. And I am in no way worse off than someone who couldn't find a prototype and struggles twice as long to put one together, never mind understand it.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10523
    
    9

So maybe we need to ask ourselves what is the difference between a prototype and a solution?


I would prefer to give out pseudo code instead of the real code. Pseudo code is a guideline, which points in the right direction. Even if you know which direction to take, you are forced to think on how to step through that direction. Thinking for your own, helps you learn.

I have observed, two types of people. One of them are "how do I do this"? They are the ones who tend to ask for ready made solutions. Their interest is to get things done, not understand how things are done. I ususally direct them to links which they could have found out on their own in the first place. They just do not understand the philosophy of "Show some effort".
The second are the ones who will explain to us, what they are trying to do and what have they got so far. For them I would really get involved, because there is a fair chance, I get to learn something new too!

[MG]Corrected typos. Never ever visit the forums in the morning until appropriate levels of coffee have been achieved


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18997
    
  40

And when you are riddled with people trying to cheat, it's kinda hard to step out of the mode of trying to impede the cheaters and help the honest folks when you have a situation of an honest person asking for the same thing that a cheater is always asking for.


And some of us has gotten more jaded over the years -- we are starting to see everything as a homework problem.

On the other hand, for easy questions, what is wrong with treating it as a homework problem? Doing the easy problems is the best way to learn... and student or not, the poster is definitely a beginner (ie. learner), if he/she is posting an easy question right?

Henry
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18997
    
  40

As a side note, I used to just give out answers to regex questions -- particularly if it is to hard to explain. After all, regex can't be homework right?

Unfortunately, now I see more people, with very complex regexes, that they are trying to fix -- and they don't know much about regexes. Since it is not homework, this means that these people are using code snippets that they don't understand -- and probably in production. And I don't think that is ever a good idea.

Henry

paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20693
    ∞

I think samples of some very simple tasks is a good thing.

I think it would be cool if JavaRanch had 100 different tiny how-to programs: setting a one line servlet running on tomcat; a hello world for mysql; etc.

Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3220
    
  49

I totally agree with Paul. We can include those how-to programs in the FAQ section.


paul wheaton wrote:setting a one line servlet running on tomcat; a hello world for mysql; etc.

Did you mean "setting a one line for mysql; a hello world servlet running on tomcat"?


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20693
    ∞

s/b "getting a one line ...."
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I agree--this is a pretty good idea (except that the FAQs seem to go relatively unnoticed by the very people they're trying to address).

Heck, having a source repo (like at Google or whatever) containing working examples might even be cool.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with finding index of a string?