ProgrammingMethodology-Lecture25.pdf
(
56 KB
)
Pobierz
Programming Methodology-Lecture25
Instructor (Mehran Sahami):
So welcome back to another fun filled, exciting day of
cs106a. A couple quick announcements before we start. First announcement, there is two
handouts. One of those handouts, which we'll spend some time talking about today, is
your last assignment for the class, which is assignment No. 7. It's worth noting, we sort of
talked about it the very first day of class when we talked about late days. The very first
handout says no late days can be used on assignment No. 7. So that’s important to
remember. No late days can be used for assignment No. 7 because it's due the last day of
the class.
If you're looking at the syllabus, you might say, I didn't think we had class on Friday, the
last day of class. That would still be correct. We don't actually have class, so you only
need to do electronic submission for turning in your program, but it's still due at 3:15 on
that Friday. We just don't actually have lecture on that Friday. We'll talk about the details
of that assignment as we go along.
The other handout that you got is the example of the code that you say last time for the
Fly Tunes music store. So you should have all that code, which shows and example of a
big data structure. In fact, the data structure for that program is perhaps more complicated
than the data structure you're going to need to use for the face pamphlet assignment, No.
7.
So as you know, assignment No. 6 review today. I have a feeling a lot of people may
have been taking late days on it because it was, for example, the last assignment to
actually be able to use late days on. So we'll just do a quick, painful as to how much time
it actually took you. Hopefully it wasn't too painful, but we'll see.
Just wondering, how many people are taking a late day? Wow. So for the six of you who
actually are turning in the assignment on time, anyone in the zero to two hour category? I
would be frightened if you were. I don't think it's actually possible to do in two hours.
Maybe, if you just sat there and wrote all the code. Two to four? Oh, I actually have a
couple for two to four. Wow.
Four to six? Good to see. I think all the [inaudible] is just going to be smaller. Six to
eight? That's a pretty healthy contingent. Eight to ten? Also good-sized contingent. Ten to
12? Couple of folks. 12 to 14? 14 to 16? 16 to 18? 18 plus? Anyone in 18 plus and still
hasn't turned it in, like you're just going for late days. All right. That's good.
So that's good to see. It's a good time. World is still normal, though the normal curve just
happens to be a little smaller because there's more people taking late days, but it's a good
time. If you haven't done it yet, two things. One is that this should give you an idea about
how much time it'll take, perhaps. Two is you don't want to push it. Even if you have late
days, don't push it off too late because you really want to give yourself time to do
assignment No. 7.
So any questions about anything we've done so far before we kind of delve into today's
great topic? All right. So I want to spend the beginning of class actually talking a bit
about your next assignment. So if you're still kind of in the mindset of thinking about
name surfer, and you're like, oh, I'm just so in the mindset of assignment No. 6, take that
little part of your head that's got assignment No. 6. Pop it off the stack. That's my whole
head. Yeah, that might be painful. Pop it off the stack for a second, and we're going to
think about our friend, the face pamphlet.
So just a quick show of hands, how many people are part of a social network or do some
social networking online. That's good to see. So I won't need to spend too much time
telling you about what a social network is, but I'll spend a little bit of time in case you're
not familiar with social networks.
Basically, a social network is just a way of keeping track of some set of people, or
profiles of people, and relationships among people. At the simplest level, that's all it is.
So what you can think about is you have some profile for a person. In some sense, you
can think of the notion of a profile and a person interchangeably most of the time. But as
most of you know, if you've ever read the New Yorker and seen that cartoon that no one
on the internet knows you’re a dog.
So you don't necessarily have to be a person to have a profile. So when we think about a
social network in the abstract sense, we always just talk in terms of profile. But if want to
think about it concretely, you can just think of a profile as being synonymous with a
person, but it need not be, so we generally refer to a profile.
So what a profile has associated with it, it has some attributes or some things that we
keep track of for that profile. For example, it has a name. In the case of your assignment,
it's also going to have some status that we care about, keeping track of the person. It
might have some other things, like the reason why it might be called face pamphlet is
because say you want to keep track of people's faces. You want to actually see what they
look like.
So you might actually have some image in there. Then I mentioned you want to keep
track of some list of friends. So there's some notion of a list of friends that is also
associated with a profile. Real social networks also have other things associated with
them, and the assignment talks about extensions you can do, but we're not going to get
into extensions right now. But these are things we want to think about.
For a person's profile, there's a name. One of the things based on some of the ideas we
talked about in the last lecture, is you can think of name as a unique identifier. What that
means is that you will never have two profiles in your social network that have the same
name. So once you have a name in your profile, in your social network, that name is
yours. That profile will be associated with that name until, at some point we decide,
maybe we want to delete the profile to get rid of it. But the whole time the profile's
actually live, it will have that unique identifier, which is the name of that profile.
So if you ever try to create another profile with the same name, the application will tell
you that you can't. I'll show you some examples of that in a bit. But the name is a unique
identifier, and this thing's just some string that we keep track of the name. So it can be
like your real name or whatever name you want to have, like Code Dog. That can be your
profile name. That's cool, too.
Status is just what you're doing right now. You can think of this as some string which is
what you happen to be up to at the time. Like Maron is teaching. I don't know. Ben is
contemplating life. It's just some particular string of the thing you happen to be doing.
You might want to change this a fair bit.
This image thing is just an image. In our world, that means it's a G image. That means it's
some picture. Originally, when you create a profile, you may not have a status, and you
may not have an image. You may want to add one. You may want to change one as life
goes on. We should be able to allow for that. Then you have a list of friends. When you're
born into the world, your list of friends is empty. Over time, you can gradually build up
friends.
That's the other part of the social network to consider, besides the fact that we have
profiles is that we also have some notion of friendship. The way you can think of
friendship is basically some profile or some person just has a list of friends. So an easy
way to think of a list of friends is a list of names of friends because names are unique
identifiers. So if we keep track of a list of names, we have a list of the unique identifiers
that are our friends.
That's an easy way to be able to look them up, for example. The idea behind friendship
that's key to us – this is not necessarily true in the real world, sadly enough, but for our
intents and purposes, as far as the assignment's concerned, friendship is reciprocal. That
means the if your friendship is reciprocal. Not all the time. That's the way it is.
What the really means is if I have two people, like I have Bob over here and I have Alice
over here, you can think of those as profiles. If they are friends, we draw a line between
their names in our little social network. This is not actually how we keep track of them in
the application that you'll see, but this is often how social networks are drawn.
We put in sort of a circle for each profile in the social network. Here's Don over here, and
here's Chelsea. Notice there's the ABCD phenomenon. Always a good time. So when we
put what we refer to as a link between two people, that means they're friends. Friends are
reciprocal. So if Bob is a friend of Alice, that means that Alice is a friend of Bob. That's
just the way life is all the time in face pamphlet.
It's just a happier place. Everyone's like, oh, I'll be your friend. Okay. Then you're my
friend, too. So that's the way you want to think about it. So if Bob ever adds Alice as a
friend, that automatically means Alice becomes Bob's friend. There's never a
directionality of friendship. Bob clicks, oh, Alice, be my friend. She's like, no. Talk to the
hand. That happens in real life all the time, but not here because it's just a happier place
to be in.
So think of friendships as reciprocal. Again, we don't necessarily have to have anything
explicit to model this link. All we need to do is think about just having a list of names. So
Bob might have Alice in his list of names of friends that he's keeping track of. That's how
I would keep track of the link.
What that also means is that reciprocally, Alice should have Bob in her list of friends
because the links are always reciprocal. When we actually draw this out, if we want to
draw the stylized picture, we could say Alice is friends with Chelsea and Don, and Don
and Chelsea are also friends over here. This is where the name network comes from.
When we draw this thing out, eventually you have millions and millions on these things
in there, all over the place. Everyone's holding hands and singing Kum Ba Ya. You have
a social effect because you have friendship, and what you actually end up drawing is
something referred to as a network.
If you're really the mathematical type, this is really a graph. In this case, it's an undirected
graph. If that kind of talk makes you hot and bothered, like, oh, a graph, yeah. Take
CS103B, which I'll be teaching next quarter. Graphs are just the coolest, most wonderful
thing. But that's a thought that's not important right now.
What is important right now is that this is where the name social network actually comes
from. We create this network that keeps track of social relations. So if we have that base
idea of social networks, how do we actually think about writing an application to keep
track of them. So [inaudible] the computer, I'll show you what, at the end of a week and a
half's effort, you will have your own social network application.
So we're going to call it Face Pamphlet because it's not really big enough to be a book.
It's a tiny book, so it's a pamphlet. So when it starts up, you can see there's interactors
galore all over the place. Over on the north side, we got a name. We got some buttons
over on the west side. We got some status, some pictures, some adding friends. What
does this all mean?
We'll actually go through an example and sort of create a little social network. So what
I'm going to do is create a profile for myself. You're like, oh, that's kind of narcissistic.
That's okay. I didn't want to – oh, we're going to create a profile for you right now.
So we add the profile on here. Here's what we get in the display. There's a bunch of
display elements. We have a name up there with some big font, and it's blue. We don't
have an image right now, so we just have a place holder. That's basically just a rectangle
with some text. It says no image. We don't have a current status, but what we've done is
created an initial profile with the name, Maron Sohami, which is a unique identifier in the
system. So right now, our social network has what we refer to as one [inaudible]. There's
one profile in there, and I don't have a list of friends.
You might say, okay, that's not so exciting. Let's actually add some stuff. So once I
actually have this active profile, I can say, let me change the status. Right now, at this
very moment, I happen to be teaching. So when I click change status, it says Maron
Sohami's teaching. Sometimes I could just be, no, I just really want to be doing this.
So I can keep changing the status. That's fine. It just updates here whenever I type it into
this field and click the button or hit the enter key. I can also add pictures. So I can say, for
example, MaronS.jpeg is a picture of Maron. There's a picture that gets loaded. It gets,
unfortunately, scaled to always take up the space for the image, which is a 200 by 200
region space.
It's constants that are given to you in the handout, but for these purposes, it's 200 by 200.
So this is kind of the bouncer version of Maron in the days of yore, when I was clean
shaven. There was actually a time when I shaved. That doesn't happen very often
anymore. If you were ever wondering what I look like without the beard, not that I care.
But that's what it was like.
So we've created a profile. Not a big deal. You could say, hey, next quarter, I'm planning
on taking 106B, and isn't that taught by Julie Zolanski? Yes, in fact, it is. So let's add a
profile for her. So we type in Julie Zolanski in the name field up here and click add. We
now get a new profile for Julie Zolanski. Julie is just a fiend. She codes like a fiend, so
she's coding like a fiend. That's what she's doing.
So you can see down here, not only is all this stuff getting updated as we typed it in, but
down here, there's something we refer to as the application message. The application
message always tells you what was the last thing you did or tried to do. So your status
was updated to coding like a fiend was the last thing you did. Let's give Julie a little
picture over here. JulieZ.jpeg, and there's Julie, also scaled to 200 by 200. So she's no
longer coding like a fiend. She's kind of feeling stretched.
So now we have her picture. We have her profile. That's all good and well. Let's add a
couple more profiles real quickly. So I'll add some of our section leaders. I'll add Sarah
K. I'm just going to abbreviate. Notice these fields over here don't necessarily get reset
when I create – they just have their old values in them. That's not a big deal. You could
add it as an extension if you wanted to, but they just leave their old values.
Sarah K. Sarah, is it okay if I use your picture? All right. Here we go. There she is, and
she's actually scaled reasonably well. So we'll also add Ben. There's Ben. We'll add a
picture for him. If you're wondering where all these pictures are coming from, in the
starter project that you'll get, you'll get a folder of images that contains the images of all
the section leaders from the class as well as Julie and myself.
I'm scaling until the cows come home. If you have your own pictures, you can add them
into the folder called images, and you, too, can display your image at a 200 by 200
resolution. Ben, where are you? Here's Ben.
Plik z chomika:
m_r_k
Inne pliki z tego folderu:
ProgrammingMethodology-Lecture01.html
(61 KB)
ProgrammingMethodology-Lecture01.pdf
(63 KB)
ProgrammingMethodology-Lecture11.html
(61 KB)
ProgrammingMethodology-Lecture04.pdf
(61 KB)
ProgrammingMethodology-Lecture03.pdf
(66 KB)
Inne foldery tego chomika:
Zgłoś jeśli
naruszono regulamin