Lecture 14 | Programming Methodology (Stanford)

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

КОМЕНТАРІ •

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

    this explains why everyone cannot be a teacher.. and its an art ... amazing job ... i want to sit with clean slate ;-)

  • @raynoldcsya8317
    @raynoldcsya8317 11 років тому +18

    Very talented lecturer! His students are very lucky. :-)

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

    Stanford, we want more courses taught by Professor Mehran please!

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

    he makes "heap" and "stack" go being happy couple in my head now. Best CS professor ever!!!

  • @sahilgupta9800
    @sahilgupta9800 4 роки тому +3

    I am here in 2020 and this lecture still excites me. Amazing professor.

  • @bjornschuller5178
    @bjornschuller5178 10 років тому +27

    Great video and great explanation:D. Indeed very talented lecturer!! Only the last part of the video is wrong:
    String s1 = "Hello";
    String s2 = "Hello";
    System.out.println(s1==s2);
    This is actually true, because when you don't use the new operator the String value is placed in the String pool. As a result, s1 and s2 are pointing to the same memory address. I think the Professor forgot the new operator and meant the following:
    String a = new String("Hello");
    String b = new String("Hello");
    System.out.println(a==b);

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

      yes, you're right.

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

      Björn Schuller You are right. There is an optimization for String class. (When you get a new instance they are not same even though their computed hashcodes are the same. )
      What about concatenating strings ?
      It is said that when you concat strings as follows it works as if you 'new' Strings and uses memory inefficiently. So using StringBuilder(StringBuffer for threadsafe) is recommended.
      Java, --returns NOT Equals !!! . Unless you won't write s1.Equals(s1,s2+"lo")
      String s1, s2;
      s1 = "Hello";
      s2 = "Hell" ;
      if(s1==(s2+"o"))
      {
      System.out.println("Equals!");
      }else
      {
      System.out.println(s1+" != "+s2+"o"); // OoooPs!
      }
      C# -- They are all equals
      string s1, s2;
      s1 = "Hello";
      s2 = "Hel" ;
      if (s1 == s2 + "lo")
      {
      Debug.WriteLine("they are equal");
      }
      if (s1.Equals(s2 + "lo"))
      {
      Debug.WriteLine("they are equal");
      }
      In C# there are object.Equals and object.ReferenceEquals. Their values are equals which can be verified by object.Equal(o1,o2) and for references object.ReferenceEquals(o1,o2).
      So, == double equal operator works differently among programming languages. To check if values are the same in Java you should use yourObject.Equals(otherOne);.... but == checks references.
      What's more in .Net you can 'new' some structs such as DateTime and structs are value types. Not object types. Thus, it doesn't mean that object types are the only types you can 'new' it. You can overload operators in .Net but not in Java.
      According to my job I use both of the languages and at first glance there are lots of similar things but there are various differences underlying .

    • @trebleclef4889
      @trebleclef4889 6 років тому +3

      Meybe for old jvm versions. Or he forget new String("Hello");

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

    Things are starting to get interesting.

  • @user-os6jm7pc9c
    @user-os6jm7pc9c 3 роки тому +2

    Topics: Memory, Different Sections of Memory for Different Types of Variables, Memory Allocation Mechanics, The Pointer Viewpoint, The Binky Pointer Fun Video
    (see.stanford.edu/Course/CS106A)

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

    That yoda comment was gold.. funny guy.

  • @nandanpandey5628
    @nandanpandey5628 5 років тому +1

    Amezing explanation on JMM.
    s1==s2 will be true because String litral pool does not create same hello more than once so both s1 and s2 will hold same memory location and result will be true.

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

    good times..

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

    world class education. a million times better than my uni lecturers

  • @kamui2020
    @kamui2020 11 років тому +4

    Great Explanation..!!!
    Now I have a better understanding about Heap And Stack

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

    Mehran marathon! Good times!

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

    what an energy this teacher has!!! :D

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

    Very informative! I hadn't known this or even really thought about it before watching this lecture. Thanks Stanford!

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

    hey, there is a mistake. Why word = 4 bytes? in 3:02. In data structure, 1 WORD = 2 BYTES=16BITS, 1 DWORD = 4 BYTES= 32 BITS, 1 QWORD = 8BYTES. Who can explain that?

  • @seenimurugan
    @seenimurugan 9 років тому +5

    Great lecture but last part about string is wrong. String literals are stored in the string pool where identical strings are referred to the same memory location. So (s1 == s2) produce true, unless if new keyword is used to create the string.

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

      +seenimurugan shanmugam you are absolutely right buddy

  • @danada45
    @danada45 9 років тому +14

    I wanted to see the video at the end :(

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

    Day 4
    - Chapter 5
    - Lectures 8 - 14
    Days 5 & 6
    - Read
    - Do some assignments

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

    Now I know how to recognize former CS1006A guy among my Java-oriented students!
    First. they know that a computer has a stack;
    And they try to do calculations in _hexadecimal_ ;-)

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

    This is an essential part to programming.

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

    at last a lecture where we can take back something home. wish i had studied at stanford !

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

    i got more clear after this lecture. It's so great

  • @sakshichadha9410
    @sakshichadha9410 11 місяців тому

    how can we compare int a=5; int b=5; if(a==b)? It checks value, not address

  • @kimmiev2114
    @kimmiev2114 5 років тому +1

    Mehran's eraser marks @13:22 looking like some abstract art

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

    Greatest of all time

  • @wardenofthenorth-w5d
    @wardenofthenorth-w5d 4 роки тому +1

    Damn, I was asked heap, stack in some interviews. Wish I could have stuck at it through.

  • @afj2010
    @afj2010 5 років тому +1

    The lectures are from 2008. Does anybody know if it’s still relevant with today’s java?

    • @dmiserak
      @dmiserak 3 роки тому +2

      They are using Java SE 6 (2006). Most of the code is still relevant. Java updates: Java SE 7 (2011), Java SE 8 (2014), Java SE 11 (2018), Java 17 (2021). If you are using Stanford’s Karel JAR you will need Java SE 6 for its applet support.

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

      @@dmiserak thank you so much for your comprehensive reply 👍

    • @hetaeramancer
      @hetaeramancer 2 роки тому +2

      @@dmiserak can we still use JApplet now? How about the GObject or GRect? And what about the java.acm?

  • @0ElectroMad0
    @0ElectroMad0 13 років тому

    Mehran u r just amazing :) thanks man ...

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

    This is the funky thing!

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

    There are a couple of youtube video download addons in Chrome if you want to try those. Just download them and play them in VLC.

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

    Awesome. Simply awesome.

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

    Does anybody know the video he was going to show to the class, i MUST know.

    • @dg-hughes
      @dg-hughes 7 років тому

      Probably some HR thing all students had to watch nothing to do with the class.

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

    I wish I had a teacher like him in my undergrad : (

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

    why is Point (2,3) in the heap. but move(int dx, int dy) in the stack. I thought a constructor is method?

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

      Point object is in the heap. When we refer to an object (as opposed to assigning a variable to a primitive type), the local variable takes the value of address of the object in the heap.
      But firstly we allocate memory and then call the constructor method to initialise instance variables. So constructor, and move are in the stack.
      Does that clarify things?

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

    @j0natan This may be and old question but...
    Do you mean 'why do you have to declare a Point as a "New Point()" because you said it was of type Point: "Point myPoint"?
    If so, it is because: When you say "Point myPoint" it is making a variable of type point. The object is, at this moment NULL. When you say "= new Point(x, y)", it then assigns the address to this 'new' Point object, and changes the NULL variable.
    Does that make sense? :P

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

    Perfect! Perfect! Perfect!

  • @adamlee9347
    @adamlee9347 6 років тому +4

    lol
    1:05 "I just bought a computer with 2 GB of RAM"
    Oh back in 2008

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

    very clear. when I learned the "==" Vs equals(), I were confused.

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

    very good lecture, one thing I don't understand why do you have to declare the pointers as different Objects
    cant it just be a declaration like Pointer pointer = new Object();
    Pointer is just and example

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

    Objects having own copy of instance variables what cause instance variables are not thread safe

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

    Great teacher.

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

    Monitoring the program syntax and source codes.

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

    does anybody know what happened to the course website. I've spent the last 30 minutes searching my computer and the internet for it. Hopefully the page hasn't been taken down. Please let me know. I'm only half way through the course and plan on finishing.

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

      elcat9091 I think I saw a message somewhere that they had taken it down to revamp it and would put it up again in August.

  • @Thegamer-yp7qq
    @Thegamer-yp7qq 9 років тому

    where is the video ??Stanford

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

    Where is "this" in the stack when calling constructor? I mean "this" is available to be used in constructors, it sure has to be somewhere

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

      'this.' contains the address of where the current object lives on the heap. It is created and destroyed on the stack along with the local variables of the method. 'this.' refers to the current object

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

    I wonder what the video Mehran played at the end is about.

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

    "Professor" has been misspelled in the description.

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

    Are the lecture slides available anywhere?

    • @GGGJJJay
      @GGGJJJay 9 років тому +3

      Tnaca7 Probably 4 months too late, but just in case some one else reading these. You can get them here
      stanford.edu/class/archive/cs/cs106a/cs106a.1142/lectures/

  • @AM-5d
    @AM-5d 4 роки тому

    "i've got 2 gigs of RAM in my computer" @1:05 LOL hhhhh that was a thing back in 2008

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

    Doesn't he mean 256 here? 2:04

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

      No, he doesn't. One byte can represent a number from 0 (inclusive) to 255, in other words it can assume one of 256 values.

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

      Oh right, we include 0.

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

      +beingme2345 Actually, the lowest value you can represent with 8 bits is 00000000 and the highest is 11111111 (255 in decimal) so the range of 1 byte is [0 to 255] which is 256 integers.

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

    ALL the confusion about ram resolved here

  • @Thegamer-yp7qq
    @Thegamer-yp7qq 9 років тому

    p1 puplic how it be local?

  • @einarmani
    @einarmani 16 років тому

    Sure is

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

    no microphone no candy !!!!

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

    Oh we're the little children, we store integers. rofl this guy rocks!

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

    @00:26 Bless you! (lol).

  • @dg-hughes
    @dg-hughes 7 років тому +1

    I need a drink. I don't drink but I think I need a drink. Actually that second example cleared it up for me the first example had my head spinning. The Heap and Stack pictures help a lot it's nice to have a mental picture of what is going on. I've read about pointers before and I thought I understood but those examples never mentioned Heap and Stack so this clears it up quite a bit. Actually no I lied the "this" still confuses me.

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

    nice chalk

  •  4 роки тому +2

    The video at the end: ua-cam.com/video/vm5MNP7pn5g/v-deo.html

  • @georgimmitev
    @georgimmitev 4 місяці тому

    17:44

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

    Professor Sahami, you kinda lost me the first half but the last half more than made up for it.
    @ snaps with a twist ;-)

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

    The video cut off at the end is at /watch?v=6pmWojisM_E

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

    34:47. Boink!

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

    But you need to know it ^^

  • @mrBolex
    @mrBolex 5 років тому +1

    ua-cam.com/video/vm5MNP7pn5g/v-deo.html Video at the end of the lecture

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

    Yottabyte=one septillion bytes or 1trillion terabytes. mhhh maybe in 2075?

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

      was hoping you'd list the topics like you do in most videos..anyway..your comments are very helpful

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

    garbage collection shirt gnomes are awesome

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

    Thanks I didn't want to go either xD

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

    34:47 laawl!!

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

    2 gigs of ram is now 8 gigs of ram haha

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

    you must unlearn what you have learned...

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

    really fake and gay even fake and gayer then i originally thought, also can i get a place in stanford? :*