Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #24417 > unrolled thread

About java program.

Started byrajbhaumik@gmail.com
First post2013-06-15 13:38 -0700
Last post2013-06-18 04:06 -0400
Articles 3 on this page of 103 — 16 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  About java program. rajbhaumik@gmail.com - 2013-06-15 13:38 -0700
    Re: About java program. Arne Vajhøj <arne@vajhoej.dk> - 2013-06-15 16:50 -0400
    Re: About java program. Robert Klemme <shortcutter@googlemail.com> - 2013-06-16 01:12 +0200
      Re: About java program. lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-06-16 14:21 +0100
        Re: About java program. Robert Klemme <shortcutter@googlemail.com> - 2013-06-16 17:28 +0200
          Re: About java program. lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-06-16 19:52 +0100
            Re: About java program. Arne Vajhøj <arne@vajhoej.dk> - 2013-06-16 15:50 -0400
          Re: About java program. lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-06-17 09:36 +0100
          Re: About java program. Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-06-17 09:49 -0300
            Re: About java program. lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-06-17 14:46 +0100
              Re: About java program. Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-06-17 13:32 -0300
              Re: About java program. Joerg Meier <joergmmeier@arcor.de> - 2013-06-17 20:32 +0200
                Re: About java program. Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-06-17 14:49 -0400
                  Re: About java program. Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-06-17 18:38 -0300
                    Re: About java program. Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-06-17 18:30 -0400
                      Re: About java program. Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-06-18 17:33 -0300
                    Re: About java program. Arne Vajhøj <arne@vajhoej.dk> - 2013-07-04 22:56 -0400
                  Re: About java program. Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-06-18 00:13 +0200
                    Re: About java program. Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-06-18 17:50 -0300
                      Re: About java program. lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-06-19 08:50 +0100
                        Re: About java program. Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-06-19 15:16 -0300
                          Re: About java program. Lew <lewbloch@gmail.com> - 2013-06-19 16:20 -0700
                            Re: About java program. Jeff Higgins <jeff@invalid.invalid> - 2013-07-07 13:31 -0400
                              Re: About java program. Jeff Higgins <jeff@invalid.invalid> - 2013-07-07 18:16 -0400
                              Re: About java program. Jeff Higgins <jeff@invalid.invalid> - 2013-07-07 19:21 -0400
                                Re: About java program. Jeff Higgins <jeff@invalid.invalid> - 2013-07-07 20:07 -0400
                                  Re: About java program. Jeff Higgins <jeff@invalid.invalid> - 2013-07-07 20:21 -0400
                                    Re: About java program. Jeff Higgins <jeff@invalid.invalid> - 2013-07-07 20:40 -0400
                                  Re: About java program. Jeff Higgins <jeff@invalid.invalid> - 2013-07-07 22:20 -0400
                                    Re: About java program. Lew <lewbloch@gmail.com> - 2013-07-07 21:47 -0700
                                      Re: About java program. Jeff Higgins <jeff@invalid.invalid> - 2013-07-08 06:58 -0400
                                        Re: About java program. Jeff Higgins <jeff@invalid.invalid> - 2013-07-08 08:07 -0400
                                          Re: About java program. Jeff Higgins <jeff@invalid.invalid> - 2013-07-08 08:58 -0400
                                            Re: About java program. Jeff Higgins <jeff@invalid.invalid> - 2013-07-08 09:18 -0400
                                              Re: About java program. Jeff Higgins <jeff@invalid.invalid> - 2013-07-08 09:47 -0400
                                                Re: About java program. Jeff Higgins <jeff@invalid.invalid> - 2013-07-08 10:07 -0400
                      Re: About java program. Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-06-19 16:42 +0200
                        Re: About java program. Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-06-20 23:33 -0300
                          Re: About java program. Martin Gregorie <martin@address-in-sig.invalid> - 2013-06-21 04:16 +0000
                            Re: About java program. Joerg Meier <joergmmeier@arcor.de> - 2013-06-21 12:27 +0200
                              Re: About java program. Martin Gregorie <martin@address-in-sig.invalid> - 2013-06-21 21:14 +0000
                                Re: About java program. Joerg Meier <joergmmeier@arcor.de> - 2013-06-21 23:37 +0200
                                  Re: About java program. Martin Gregorie <martin@address-in-sig.invalid> - 2013-06-21 23:42 +0000
                                Re: About java program. Gene Wirchenko <genew@telus.net> - 2013-06-24 13:00 -0700
                                  Re: About java program. Martin Gregorie <martin@address-in-sig.invalid> - 2013-06-24 21:29 +0000
                                    Re: About java program. Martin Gregorie <martin@address-in-sig.invalid> - 2013-06-24 21:42 +0000
                            Re: About java program. Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-06-21 23:59 -0300
                              Re: About java program. Martin Gregorie <martin@address-in-sig.invalid> - 2013-06-22 13:30 +0000
                          Re: About java program. Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-06-21 16:24 +0200
                            Re: About java program. Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-06-21 22:39 -0300
                              Re: About java program. Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-06-22 19:25 +0200
                                Re: About java program. lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-06-22 19:41 +0100
                                  Re: About java program. Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-06-23 03:53 +0200
                                    Re: About java program. lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-06-23 09:21 +0100
                                      Re: About java program. Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-06-24 18:57 +0200
                                        Re: About java program. lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-06-24 18:14 +0100
                            Re: About java program. lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-06-22 09:03 +0100
                              Re: About java program. Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-06-22 19:26 +0200
                                Re: About java program. lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-06-22 18:51 +0100
                      Re: About java program. Arne Vajhøj <arne@vajhoej.dk> - 2013-07-04 22:58 -0400
                  Re: About java program. Joerg Meier <joergmmeier@arcor.de> - 2013-06-19 00:38 +0200
                    Re: About java program. Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-06-18 18:56 -0400
                      Re: About java program. Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-06-18 21:26 -0300
                        Re: About java program. Robert Klemme <shortcutter@googlemail.com> - 2013-06-19 21:20 +0200
                          Re: About java program. Sven Köhler <remove-sven.koehler@gmail.com> - 2013-06-20 11:23 +0300
                            Re: About java program. Robert Klemme <shortcutter@googlemail.com> - 2013-06-20 19:18 +0200
                              Re: About java program. blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2013-07-15 20:20 +0000
                      Re: About java program. lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-06-19 09:14 +0100
                    Re: About java program. lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-06-19 09:11 +0100
                      Re: About java program. Arne Vajhøj <arne@vajhoej.dk> - 2013-07-04 23:11 -0400
                        Re: About java program. lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-07-05 09:13 +0100
                          Re: About java program. Robert Klemme <shortcutter@googlemail.com> - 2013-07-05 23:15 +0200
                            Re: About java program. Arne Vajhøj <arne@vajhoej.dk> - 2013-07-05 22:03 -0400
                              Re: About java program. Robert Klemme <shortcutter@googlemail.com> - 2013-07-06 13:01 +0200
                                Re: About java program. lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-07-06 13:43 +0100
                                Re: About java program. Martin Gregorie <martin@address-in-sig.invalid> - 2013-07-06 14:17 +0000
                                Re: About java program. Arne Vajhøj <arne@vajhoej.dk> - 2013-07-06 16:18 -0400
                                  Re: About java program. lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-07-06 21:42 +0100
                            Re: About java program. lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-07-06 09:16 +0100
                              Re: About java program. Robert Klemme <shortcutter@googlemail.com> - 2013-07-06 13:14 +0200
                                Re: About java program. Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-07-06 08:22 -0400
                                  Re: About java program. Robert Klemme <shortcutter@googlemail.com> - 2013-07-07 20:43 +0200
                                    Re: About java program. Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-07-07 18:07 -0400
                                      Re: About java program. Arne Vajhøj <arne@vajhoej.dk> - 2013-07-07 19:35 -0400
                                        Re: About java program. Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-07-07 20:42 -0400
                                      Re: About java program. Robert Klemme <shortcutter@googlemail.com> - 2013-07-08 20:50 +0200
                                        Re: About java program. Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-07-08 15:01 -0400
                                          Re: About java program. Robert Klemme <shortcutter@googlemail.com> - 2013-07-08 23:29 +0200
                                Re: About java program. Arne Vajhøj <arne@vajhoej.dk> - 2013-07-06 16:27 -0400
                                  Re: About java program. Lew <lewbloch@gmail.com> - 2013-07-06 13:41 -0700
                          Re: About java program. Arne Vajhøj <arne@vajhoej.dk> - 2013-07-05 21:59 -0400
                Re: About java program. lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-06-17 21:06 +0100
              Re: About java program. Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2013-06-17 17:36 -0500
                Re: About java program. Robert Klemme <shortcutter@googlemail.com> - 2013-06-18 08:24 +0200
                Re: About java program. lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-06-18 09:03 +0100
                  Re: About java program. Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2013-06-18 13:07 -0500
                  Re: About java program. Lew <lewbloch@gmail.com> - 2013-06-18 14:48 -0700
                    Re: About java program. lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-06-19 08:36 +0100
                Re: About java program. Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-06-18 23:33 -0300
                  Re: About java program. lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-06-19 08:34 +0100
              Re: About java program. Arne Vajhøj <arne@vajhoej.dk> - 2013-07-04 22:53 -0400
    Re: About java program. Roedy Green <see_website@mindprod.com.invalid> - 2013-06-16 07:04 -0700
    Re: About java program. Jeff Higgins <jeff@invalid.invalid> - 2013-06-18 04:06 -0400

Page 6 of 6 — ← Prev page 1 2 3 4 5 [6]


#24639

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-07-04 22:53 -0400
Message-ID<51d6353e$0$299$14726298@news.sunsite.dk>
In reply to#24436
On 6/17/2013 9:46 AM, lipska the kat wrote:
> On 17/06/13 13:49, Arved Sandstrom wrote:
>> On 06/16/2013 12:28 PM, Robert Klemme wrote:
>>> On 16.06.2013 15:21, lipska the kat wrote:
>>>> On 16/06/13 00:12, Robert Klemme wrote:
>>>>> On 15.06.2013 22:38, rajbhaumik@gmail.com wrote:
>>>>>> import acm.program.*;
>>>>>> public class askYesNoQuestion extends ConsoleProgram {
>>>>>>     public void run(){
>>>>>>         String str=readLine("Would you like instructions");
>>>>>>         println(askYesNoquestion(str));
>>>>>>     }
>>>>>> 7.        private boolean askYesNoquestion (String str){
>>>>>>             if(str.equals("yes"))return true;
>>>>>>             if(str.equals("no")) return false;
>>>>>>     }
>>>>>>
>>>>>> }
>>>>>> the false is that , the program cannot be executed, because no 7
>>>>>> said, this method must return a type of boolean.
>>>>>
>>>>
>>>> One possible solution (not compiled or tested)
>>>>
>>>> private boolean askYesNoquestion (String str){
>>>>     boolean response = false;
>>>>     if(str.equals("yes")){
>>>>         response = true;
>>>>     }
>>>>     return response;
>>>> }
>
> [snip]
>
>> To the original point, I agree to an extent. But the actual idiom that
>> lipska used is not bad in general, if you're used to single return. It's
>> sort of like *always* providing braces for conditionals, even for one
>> liners, defensive coding in part, but also adhering to personal coding
>> style.
>
> ... and what is your opinion of defensive coding?
>
> Anyone who has ever written software to interact with a user via a
> device interface knows (or should know) that defensive coding is de-riguer.
>
> If you don't want the device to crash every time someone does something
> unexpected you need to anticipate no only the unexpected but the
> unanticipated. There is *no* room for error.
>
> This discipline is hard to learn and once learned even harder to
> un-learn. This is why I don't like things like
>
> return str.equals("yes");

Why?

Your code and this code has the exact same potential for problems!?!?

> It's lazy coding and harder to understand than my example

Not is is not. It has less elements to understand.

> If I was doing a proper job and not just providing a simple example I
> would have had a pre-condition on the method *and* exception handling

Exception handling is rarely a good thing to try ay such low level -
and especially not a NPE.

> *and* braces around every conditional, even one liners,

You already had.

Arne

[toc] | [prev] | [next] | [standalone]


#24424

FromRoedy Green <see_website@mindprod.com.invalid>
Date2013-06-16 07:04 -0700
Message-ID<gfhrr8hgecroer5e02h04n904qrmiqofee@4ax.com>
In reply to#24417
On Sat, 15 Jun 2013 13:38:48 -0700 (PDT), rajbhaumik@gmail.com wrote,
quoted or indirectly quoted someone who said :

>  private boolean askYesNoquestion (String str){
>	    	if(str.equals("yes"))return true;
>	    	if(str.equals("no")) return false;    	

what should it return if I typed "maybe"?
-- 
Roedy Green Canadian Mind Products http://mindprod.com
Getting information off the Internet is 
like taking a drink from a fire hydrant.
~ Mitch Kapor 1950-11-01

[toc] | [prev] | [next] | [standalone]


#24450

FromJeff Higgins <jeff@invalid.invalid>
Date2013-06-18 04:06 -0400
Message-ID<kpp41o$nto$1@dont-email.me>
In reply to#24417
On 06/15/2013 04:38 PM, rajbhaumik@gmail.com wrote:
> import acm.program.*;
> public class askYesNoQuestion extends ConsoleProgram {
> 	public void run(){
> 		String str=readLine("Would you like instructions");
> 		println(askYesNoquestion(str));
> 	}
> 7.	    private boolean askYesNoquestion (String str){
> 	    	if(str.equals("yes"))return true;
> 	    	if(str.equals("no")) return false;    	
> 	}
>
> }
>   the false is that , the program cannot be executed, because no 7 said , this method must return a type of boolean.
>
import acm.program.ConsoleProgram;

@SuppressWarnings("serial")
public class AskYesNoQuestion extends ConsoleProgram {

   public void run() {
     boolean answer =
         readBoolean(
             "Have you read the manual?", "Yes", "No");
     if(answer)
       println("Yes, I will read the manual.");
     else println("Yes, I will read the manual.\n"
 
+"<http://jtf.acm.org/javadoc/student/acm/program/ConsoleProgram.html>");
  }
}

[toc] | [prev] | [standalone]


Page 6 of 6 — ← Prev page 1 2 3 4 5 [6]

Back to top | Article view | comp.lang.java.programmer


csiph-web