Lecture 6 | Programming Methodology (Stanford)

Поділитися
Вставка
  • Опубліковано 27 гру 2024

КОМЕНТАРІ •

  • @XzzHERCULESzzX
    @XzzHERCULESzzX 11 років тому +38

    I mailed Mehran a question. He mailed me candy. True story.

  • @zacbrown112
    @zacbrown112 13 років тому +6

    its like a mixture of learning maths and a language at the same time! ... I NEVER thought id be doing that on my Christmas holidays!

  • @PSSK101
    @PSSK101 13 років тому +2

    You couldn't wish for a better teacher. Genuine, passionate, comprehensive, clear & actually quite funny. Sahami is my hero.

  • @realitify6164
    @realitify6164 2 роки тому

    Mehran is the goat. Havent seen a professor as enthusiastic and involved as him yet.

  • @commonsense1337
    @commonsense1337 15 років тому +5

    Awesome work stanford, making this free is just fantastic.

  • @Smurf0011
    @Smurf0011 11 років тому +21

    "anyone know how george bool die?"
    "he got set to false"
    had to comment it ...

  • @wdmichael
    @wdmichael 12 років тому

    Simply outstanding. Professor Sahami is a gifted lecturer whose genuine interest in the subject and students comes through loudly and clearly.

  • @1958marwan
    @1958marwan 13 років тому

    Professor Mehran is a very dedicated and great teacher I wished I had him as a teacher.Some teacher may be knows the material but do not have the way to presented in a simple way................................Thanks for Stanford and Prof. Mehran

  • @justinli19901027
    @justinli19901027 8 років тому +15

    world class education

  • @sifatrehman1903
    @sifatrehman1903 6 років тому +2

    this man is only hope in this whole wide world

    • @Mersal-uj5nh
      @Mersal-uj5nh 4 роки тому +1

      Not only, There are many like him👍

  • @dhongorom
    @dhongorom 3 роки тому +1

    Is he the best teacher of Stanford? He must be.

  • @rickyjackson1258
    @rickyjackson1258 11 років тому +43

    I wish this guy was my dad...

    • @YungVL
      @YungVL 10 років тому +35

      ... and with all those candies he has, you can call him Sugar Daddy! ;-)

    • @JavierPortillo1
      @JavierPortillo1 9 років тому +2

      YungL I want a candy :c

    • @cathyqu7618
      @cathyqu7618 9 років тому +1

      Javier Portillo
      Did you notice he forgot to give someone a candy in the last episode?

  • @antonehmac
    @antonehmac 12 років тому +1

    He throws candy at those who participate, and it only reaches those closer to the front. Investigate: Conditioning.

  • @brettshipes
    @brettshipes 12 років тому +1

    Get the book. It's called "The Art and Science of Java" by Eric Roberts. It's expensive, but there's always another way to get it if you're clever. Skim the chapters before watching the lecture so you'll have at least some clue as to what is going on, and then go back over the chapter after the lecture. Use a highlighter. Take notes. I'm following a strict MWF schedule to keep myself plowing through this course, it can be done, it just takes dedication.

  • @harshitagarwal5188
    @harshitagarwal5188 8 років тому +2

    where is the error checking that mr. sahami shows at around 11:00 , i could not see that in code

  • @hypyotics
    @hypyotics 12 років тому

    Diversity, competition, brainstorming. We do live in a society... and beside that as an individual you can deepen what you learned in a group and then come back and share. And that's how evolution works. This is my theory.

  • @Vaughnlesterinoz
    @Vaughnlesterinoz 13 років тому +1

    @ferret0rouge I think it was to be able to fit everything into the one comment. 10 months ago the character limit on comments was far lower.

  • @mgwilson271
    @mgwilson271 10 років тому +2

    So far, this course has been great. I wish he hadn't rushed the while loop description at 45:00. The loop would terminate when x==1, x would never be 0.

    • @mgwilson271
      @mgwilson271 10 років тому +3

      1 is not greater than 1, therefore the loop would terminate when X ==1. The case when X == 1, the loop never executes, therefore 1/2 never happens.
      The sequence of X values would be 15 (initial condition), 15/2 -> 7, 7/3 -> 3, 3/2 -> 1 (loop termination).

    • @weyderwarr
      @weyderwarr 10 років тому

      mgwilson271 He never says that the iteration executes while x was equal to one. He asked the students what 1 divided by 2 was and then said it does not run "which is not greater than 1 and we're done". If the reason it prints 1 is what confuses you then well lets break it down a bit further: condition, 15/2==7, prints 7 => condition, 7/2==3, prints 3 => condition, 3/2==1, prints 1 => condition, terminate.

    • @mgwilson271
      @mgwilson271 10 років тому +1

      weyderwarr Yes, I understood why "1" was printed.
      From the section in question:
      "So first time X has 15."
      "15's greater than 1."
      "We divide by 2."
      "We do integer division, so we get 7."
      "We write that out and go back up there."
      "7 is greater than 1.
      "We get 3."
      "We do it again, we get 1."
      "We do 1 divide equal 2 we get...... 0 which is not greater than 1, so we're done."

    • @weyderwarr
      @weyderwarr 10 років тому

      mgwilson271 When did anyone ever say that the loop iterated past 1?

    • @mgwilson271
      @mgwilson271 10 років тому

      The quotations are directly from the lecture.

  • @Artilla2012
    @Artilla2012 11 років тому +3

    i love this guy..
    amazing stuff to learn. still x amount of lectures to go :P

  • @ignaciocorto
    @ignaciocorto 10 років тому +2

    Cascading ifs and switch statements can easily break the 15-lines-per-method rule. Should I forget the rule in those cases? How could I enforce the rule?

  • @PSSK101
    @PSSK101 13 років тому

    I have a huge smile on my face. I had a cool little robot called Karel in my mind over the new year break. Yet another huge inspiration from Stanford University. I feel compelled to start a blog to share all my favourites as a thank you. Just searched the domain. It's available. I will post the link(s) soon.

  • @Phl3xable
    @Phl3xable 13 років тому +1

    @TripodGRANNE You can convert an Integer to a String with the 'toString' method in the 'Integer' class.

  • @X3QT0R
    @X3QT0R 16 років тому +1

    I lost my interest in programming due to crappy teaching in my college and a tuition ...
    prof mehran seems to bring that interest back..
    Thanks for the lectures @ stanford. :D

  • @xiuxiuli2620
    @xiuxiuli2620 4 роки тому +1

    watching it on 2020....with my 7 years old son....

  • @EddieKMusic
    @EddieKMusic 12 років тому +1

    It's not about watching. Its about understanding. Your point of view is really funny. Its like: "If I watch this more than anyone else, I will be cool!!" It's like teenage wannabe programmer kids who use buckys tutorials to "learn" programming.

  • @arjunaravind1351
    @arjunaravind1351 8 років тому +25

    SEVENTY_TWO

  • @xajin24
    @xajin24 13 років тому +1

    working from eclipse, what is the library I need to add so I can use readInt()?

  • @annafilban2859
    @annafilban2859 8 років тому +1

    45:21 - Do you even get to 1/=2? Is 1 greater than 1? In the for loop he said "5 is not strictly less than 5", so is 1 not strictly greater than 1? Why would it be different in a while loop?

    • @william41017
      @william41017 7 років тому

      Anna FIlban he probably made a mistake

    • @cnocbride7256
      @cnocbride7256 6 років тому

      He got it wrong, he most likely should have:
      while(x >= 1) {
      x/= 2; (Or x = x/2)
      println(x);
      }
      That would have worked as 1 is greater than OR equal to 1.
      1 is NOT greater than 1. So yes, you're correct.

  • @LilzAccountttt
    @LilzAccountttt 12 років тому

    It's better practice to cast something even as simple as real division. Later on when you start working with more complex ideas, type-casting can becoming really useful. Which is why you should get comfortable with them early on.

  • @wdmichael
    @wdmichael 12 років тому

    Peaceandwellness - Outstanding. Stay with your studies and good luck!

  • @TheDDgun99
    @TheDDgun99 11 років тому

    I made it check if there was a beeper present when he hit the wall, if there wasn't, it would be even, if there was, it would be uneven. From there I branched the program into two algorithm, one for even rows, on for uneven rows.

  • @Saganist420
    @Saganist420 7 років тому +7

    I like to eat snickers while watching these and pretend i'm an involved real life student

  • @gallegom58
    @gallegom58 10 років тому +1

    39:55 not really a problem but what if I did not choose a variable between 0-6? would it still bring me to default. In that case what could I have done to prevent it?

    • @YoZentrus
      @YoZentrus 10 років тому +2

      Yeah, anything that wasn't 0 or 6 would go to the default case. The default case is there as a catch-all to catch basically "anything else". The only real way to prevent going to the default case would be to have a case set up for whatever that choice is.
      You could enclose it in a _while_ loop that runs until a valid option has been chosen [e.g. while ( day != 0 || 6 ) { _prompt_ _and_ _switch_ }]. Then you could have the default case tell the user that their choice is invalid, and when it exits the _while_ loop would run the choice again.

  • @Jerz4lunch
    @Jerz4lunch 11 років тому +1

    Java is one of the hardest programming language to learn.

  • @bimalgrg
    @bimalgrg 12 років тому

    You are right. He did corrected it on Lecture 7.

  • @wreckass
    @wreckass 15 років тому +2

    thanks stanford, very good lectures!

  • @thought2007
    @thought2007 7 років тому

    21:50 - even SEVENTY_TWO is better than bare 72. Once you realize it means pixel per inch, you can safely rename SEVENTY_TWO to DISPLAY_PPI or something. But globally replacing 72 to, say, 120 for higher DPI would not be safe at all.

  • @Sarstan
    @Sarstan 11 років тому

    I don't quite understand with the program on 42:00 why it ends up starting with 0. The command seems to say "this is 0, I'll add 1, then I'll print". Why does it print the original i value instead of the after the change? Is there a quick way to have it change then print?

  • @todd2133
    @todd2133 7 років тому

    Does anyone know which videos he talks about switch statements and explains constructors?

  • @pker5range
    @pker5range 12 років тому

    what is the difference between the for and while loop? is it just that the for loop as the initial value of the variable while the while loop doesnt?

  • @antonehmac
    @antonehmac 12 років тому

    for (INIT; CONDITION; STEP)
    STATEMENT
    INIT happens once, before anything. The CONDITION is tested. If the CONDITION is true, then the STATEMENT is run. *AFTER* the STATEMENT is run, the STEP is executed. Even though the STEP is written above the STATEMENT, the STEP section of the `for loop` is only done after the whole loop has run. Hope that helps.

  • @TheNohonorpker
    @TheNohonorpker 12 років тому

    i++ means its counting by 1(0,1,2,3,4,5,) and the i=0 means it starts at 0

  • @oristhisjustfantasea
    @oristhisjustfantasea 12 років тому +1

    Hey isn't it a good channel? I'm planning to learn PHP and MySql from there after this.

  • @IWIH90
    @IWIH90 11 років тому

    you may declare a variable of a higher scope, let be (x):
    int x = 0;
    then, add this statement in side the (for) block:
    x += i;
    it would be available after (for) block because it's of a higher scope!

  • @lendelgalyna1042
    @lendelgalyna1042 9 років тому +4

    Thank you so much!

  • @tomthorton5630
    @tomthorton5630 11 років тому +1

    these lectures are great,I wish I could afford to go to college,it would be great.

  • @brianscript9601
    @brianscript9601 11 років тому

    How do you ask the computer to add up all the numbers obtained during the loop instead of printing all the integers of var i

  • @pker5range
    @pker5range 12 років тому

    so what does => and =< mean, since he said the order makes a difference?

  • @emmaodonnell8275
    @emmaodonnell8275 10 років тому

    Having a little trouble. I'm trying to do the assignments associated with this lesson (the pyramid one at the moment). I can do the assignment but to do so I feel like I have to abandon the "top-down" programming lesson taught earlier as I can't make a variable carry from one method to another. Advice?

    • @RamiAbdelal
      @RamiAbdelal 10 років тому

      I realise I'm a bit late here but as I understand it, as long as you declare the variable in the parent class of all the methods or classes you'd like the variable to have access to, they will inherit them and therefore have access to them: giving the variable a wide scope.

  • @karidavid1994
    @karidavid1994 12 років тому

    wow this guy is a really good teacher

  • @kevlam585
    @kevlam585 13 років тому

    @xajin24 you need to download the acm package and import it to Eclipse so you can use it with this Course. Took me a while to figure it out, but if you need assistance, shoot me a message.

  • @Jkfgjfgjfkjg
    @Jkfgjfgjfkjg 6 років тому

    In the while loop example at the very end he says "1 divide equals 2 is 0, so we're done". However, the program would never do that, because as soon as we print 1 in the final step the condition in the while loop is no longer true (i.e., 1 is not greater than 1) so the body never executes.

    • @plaidchuck
      @plaidchuck Рік тому

      Nah it works, just tested it. It will print the one from the 3 / 2 calculation, then go back to the while statement and since the x value is 1 it will end there.

    • @Jkfgjfgjfkjg
      @Jkfgjfgjfkjg Рік тому

      @@plaidchuck Yes, it will end because 1 is not less than 1. It will never do the operation 1/2 to get 0. So "we're done" not because 1/2 is 0, but because 1 is not less than 1.

  • @Rasmusorum
    @Rasmusorum 15 років тому

    is there a big difference between the pdf version of "the art and sience of java" book and the full original version? Will i be able to complete the course and understand all the details with the pdf preliminary draft of the book, or will i miss alot of detail if i don't read the final example of the book?

  • @adrockr2
    @adrockr2 11 років тому

    Does anyone have access to the ORIGINAL course materials? Lecture code & slides, HW prompts, etc. The link directs to the current version of the class, which is different.

  • @meesternadim
    @meesternadim 13 років тому +2

    I thought stanford is for super geniuses, but even i understand this.

  • @archrodney
    @archrodney 14 років тому +2

    I love when he tries to wipe the board, it becomes crappier and crappier.. ;)

  • @phartatmisassa5035
    @phartatmisassa5035 11 років тому +1

    Hey, the for loop looks just like it does in C, cool. Python reminds me more of bash than C or Java. It's interesting to see the similarities and differences in syntax as well as general operation of these programming languages. I live near Mexico and I can't learn Spanish for the life of me, programming seems like a second nature, as if I had been thinking this way but didn't know how similar it was to programming. An old friend of mind who studied C++ in 8th grade said I was very "objective".

  • @tilakrijal3689
    @tilakrijal3689 8 років тому +2

    you are amazing sir

  • @willvoiceit1
    @willvoiceit1 14 років тому

    @MrPolymorphist but why would you want to use % with a double value?

  • @natzolpoa
    @natzolpoa 12 років тому +2

    I wish I could get Snickers every time I asked a question during class

  • @billigerfusel
    @billigerfusel 15 років тому +1

    yea, hes awesome

  • @oristhisjustfantasea
    @oristhisjustfantasea 12 років тому +1

    Ok, Thanks for the heads up, buddy.

  • @KuldipKumarPrajapati777
    @KuldipKumarPrajapati777 12 років тому

    @4:30 algebra: Division comes first then multiplication

  • @TripodGRANNE
    @TripodGRANNE 13 років тому

    Is it Possible to cast an Integer as a String?

  • @hypyotics
    @hypyotics 12 років тому

    This isn't about disabled people or people that TOO LAZY TO TAKE A SELF DEFENSE CLASS, it is always better to learn in a group than as an individual. This is about the people that want to learn but LACK the means.

  • @qoaa
    @qoaa 12 років тому

    I like the lectures and have downloaded the entire series with firefox youtube download plugin So in case I'm not online I've uploaded the mp4s to my ipod touch and onto a Flash drive for rewatching, also in case they ever get taken off youtube.

  • @TheMrjitusolanki
    @TheMrjitusolanki 12 років тому +1

    I am 44 years old and want to know JAVA, I have been to Lynda.com and other webs.. paid for nothing, I think I wested my £, which is hard earn money.... I THANKS Mr. M TO PUT HIS WAY TO EXPLAIN JAVA LIKE TELLING STORY TO THE KID... THANK YOU FOR EVERY THING.. give me your number i am in to big project .... Thank u again

  • @daverodrigues877
    @daverodrigues877 8 років тому

    Is readDouble(); a standard part of java? Or do i need to import something first? In my current classes we would first import java.util.Scanner; then use
    Scanner inp = new Scanner(System.in);
    System.out.print("enter double: ");
    double Variable = inp.nextDouble();
    I have tried to use this before but it wont work, i'm just getting errors?
    I am using the newest version of eclipse. If it is possible to do without using import, can someone show me an example of code that will work in eclipse? Please include the code that will make it print to the console, like System.out.println(); would.
    if not what do I need to import first?
    It would save me writing a small bit of code, but I am more interested in why it is not working for me.
    Thanks in advance, any information will be appreciated.

    • @mohaibra8065
      @mohaibra8065 8 років тому

      +David Rodrigues i have tried and it works, but if you type in a double number like 2.3 it doesnt and it gives you "Exception in thread "main" java.util.InputMismatchException" i dont know why.

  • @3p0cHx
    @3p0cHx 11 років тому

    I don't have it anymore because I uninstalled Karel due to not using it anymore. They start using only simple java programs in assignment 2, but I did blog my solutions to Assignment 2 on my blog. Also you can find several solutions online just do a google search for checkerboard karel solution

  • @Sulaiman-vp1fi
    @Sulaiman-vp1fi 3 роки тому +1

    I'm here after 13 years :)

  • @rtatt1
    @rtatt1 12 років тому

    The scope of a variable is very different from the lifetime of a variable!

  • @pathikmodi6087
    @pathikmodi6087 10 років тому

    can someone tell me y my computer is showing error when i use readInt("Day of the week int: ");

    • @weyderwarr
      @weyderwarr 10 років тому

      ReadInt is reading what the user is inputting. You cannot print to the screen in a request for input.
      println("Day of the week int: ");
      readlnt();
      I have not watched lecture 6 yet so I don't know exactly how the readInt is set up. In C, you have something known as scanf, which would kind of be C's version of readInt. To use scanf on an integer, you would simply scanf("%i", variable); The stuff within quotes cannot contain anything besides % followed by a type specifier (i or d for integer). With that in mind, I would assume you cannot put text that you want printed to the screen inside a readInt statement, as it is asking the user for input, not giving the user output.

    • @weyderwarr
      @weyderwarr 10 років тому +1

      weyderwarr Oh never mind, I realized I was wrong. Did you have the readInt assigned to a variable? If not, then that would most likely be why.

    • @RoushanJ
      @RoushanJ 10 років тому +1

      in short it's like, int x = readInt("enter the number ") ;

  • @benhenicraf
    @benhenicraf 13 років тому

    Can any one clear my doubt...At 24:45 student asks doubt and professor answers it,but i couldn get the sense of what they both are talking about..

  • @AndrewBogus
    @AndrewBogus 13 років тому

    @TripodGRANNE Or you can use String.valueOf() method

  • @Jerz4lunch
    @Jerz4lunch 11 років тому

    I'm just wondering, what algorithm did you use for problem 3 from assignment 1 [CheckerboardKarel]? I only got it to work with the even-numbered rows world. If you know how, can you message me (via UA-cam)? Thanks.

  • @pknyo
    @pknyo 13 років тому +1

    I love Stanford`s theme music, sounds like Knight Rider.

  • @Heikos01
    @Heikos01 12 років тому

    Why is it always better to learn in a group than as an indivual?
    I'm sure there are some advantages too as there are some disadvantages.

  • @cyvretech
    @cyvretech 13 років тому

    You know, it would be nice if all the students used their microphone every time they asked a question...

  • @sportivechild
    @sportivechild 15 років тому +1

    mehran u Rock on always....;-)

  • @TeeUniverse
    @TeeUniverse 12 років тому

    cool how did you do that?

  • @medanibarra
    @medanibarra 5 років тому

    the line the boy can't find is above shift, it is split into two smaller lines

  • @ferret0rouge
    @ferret0rouge 13 років тому

    @Vaughnlesterinoz I see, thanks for clearing that up =].

  • @GSCrepresentative
    @GSCrepresentative 14 років тому

    doesn't the average sign also have a different name? I remember in one of my C++ books it was called something else.

  • @manoouu
    @manoouu 9 років тому +1

    which book do they refer to?

    • @thinkmoreyoulivebetter6879
      @thinkmoreyoulivebetter6879 9 років тому +6

      +The average Guy people.reed.edu/~jerry/121/materials/artsciencejava.pdf

    • @akraticus
      @akraticus 9 років тому +1

      Art and Science of Java by Eric Roberts

    • @jeffm9723
      @jeffm9723 8 років тому

      +thinkmore youlivebetter Thank you!

  • @slr150
    @slr150 11 років тому

    19:15 I would be careful of storing arbitrary double literals. Floating point error means that, what you see is not always what you get.

  • @drewbiggs9007
    @drewbiggs9007 7 років тому

    There is a really high-pitched whine in the background sound for most of this video

  • @coolvideosushouldc
    @coolvideosushouldc 12 років тому

    What he says at 12:20 is not actually true. It actually won't cast the double automatically to an int because of a possible loss of precision. That line of code won't actually compile because it's a type mismatch so you do actually need the cast (int) there. Although going from int to double (the other way) you wouldn't.

  • @Darker_Void_Scientist
    @Darker_Void_Scientist 13 років тому

    @TripodGRANNE yeah You don;t even have to cast.You the + operator.
    int num = 59;
    String number59 = ""+num;
    System.out.println(number59);

  • @Lemon77UG
    @Lemon77UG 13 років тому

    The full textbook (704 pages) should be arriving in a few days, yay! So far I haven't had trouble with using the draft, though.
    I get the logic behind them, but writing complicated Boolean expressions can get somewhat challenging, last night I had to break a few of them down on paper to be clear about what happens, but it's fun.

  • @commonsense1337
    @commonsense1337 15 років тому +1

    if your not uni material, why would you be watching this lecture? Maybe you are better then you think you are...

  • @Jerz4lunch
    @Jerz4lunch 11 років тому

    Welcome.

  • @akraticus
    @akraticus 9 років тому +1

    for loop is fun

  • @cyvretech
    @cyvretech 13 років тому +1

    @mattmanbowz
    True man! Sahami is awesome :D

  • @harutyunyansaten
    @harutyunyansaten 7 років тому

    what is the textbooks of this course?

    • @plaidchuck
      @plaidchuck Рік тому

      "The Art and Science of Java" by Eric Roberts

  • @urbansilhouettemedia
    @urbansilhouettemedia 11 років тому

    The reason it is hard is that most concentrate on syntax and not on OOP. Java is not forgiving if you are a procedural programmer.

  • @Darker_Void_Scientist
    @Darker_Void_Scientist 13 років тому

    @michaeldcurry1 I guess they did the double y = (double)x/2; formula and the answer is wrong :/... All they had to do was add parenthesis around the x/2.

  • @RoushanJ
    @RoushanJ 10 років тому +2

    How a Stanford guy can ask such question like, where should I get OR symbol. I was expecting u to be smarter & better.

    • @SRCmandan
      @SRCmandan 9 років тому +6

      This is an introductory programming course. Students at Stanford are as human as anyone else.

    • @sidisoueina2336
      @sidisoueina2336 9 років тому

      Roushan J. these aren't CS students. The efforts to teach non major students is very substantial.

  • @aerialdude
    @aerialdude 10 років тому +4

    George Boole experienced old school homeopathy.

  • @laxmanbista3195
    @laxmanbista3195 9 років тому

    how to work with karel robot
    how to get it

    • @diablox169
      @diablox169 8 років тому

      +Laxman Bista you need to go to the start of these videos. There is a playlist. In the descriptions of every video (including this one) are links to the Stanford website with all the paperwork, program links, and instructions on how to get set up. These are open to the public. So don't worry, you're not stealing.

  • @3p0cHx
    @3p0cHx 11 років тому

    I'm learning java on my own. These lectures and assignments have helped me learn a lot already. I just finished Assignment 2, problem 5. Would I be able to get feedback on my solutions to the problems even though I'm not enrolled in Stanford?