February ?, 2014 – February 21st, 2014 Discussion

Hello again! I’ve been super busy so I hadn’t had the time to make a post about my notes like I usually do, but now I’m making the time for it. But before we go on with that I have some great things to say and they are the following:

1. When I started this blog for my comp class I was not expecting anything but then suddenly I got three likes on two different posts!! I couldn’t believe it so I just wanna thank you all for taking a look! ūüôā

2. I’ve been wondering about the grade I’ll get on this blog. I remember the professor said he was going to grade it according to the number of posts and the depth of the post but I wonder… Are mine deep enough? Will I be able to make enough posts by December??? Will the professor have enough time to read all the crazy things I write here? Is he already reading them and grading me per post?! Gasps! THE ANXIETY!!!!!!!!!!!! :0

3. I have two great news!!! I’m finally going to my professor’s office hours!! It took me a bit to work up the courage but the need forced me!!!! And I realized I had nothing to be afraid of!! He is so nice and the class becomes a lot more clear when I go to his office hours and the only reason why I was able to finish Lab 2 was because I went to his office hours! Oh Goodness I have to get around doing lab 3 already!!! Not only that but I’ve been trying to make a COJ problem but ugh it wasn’t coming out but now I have an idea of what it might be I should get around writing the algorithm asap.

4. EEEEEEEEEEEE!!! Happiness!! Guess what? There’s a programming competition on April 26th at Bayamon and we get to go!!! The prof will get a Shuttle ready and everything so we can go if we want!!! And I want to!!! The prof said we could compete but I’m AFRAID!!! So I don’t want to compete I just wanna go and look. He said there was nothing to be afraid of but I’m just so terrible at programming~~~ I don’t feel ready………….. But I still wanna go. My friend, Emmanuelle always participates (because he’s boss like that) and he always talks to me about it so I’ve been wondering how those things go! I hope nothing gets in the way and I am able to go.

5. First midterm will be based on the first 3 chapters and will be on March 5th, 2014. I’m A.F.R.A.I.D. I’ve been told EVERYONE fails the first test, URR. I hate Failing… It’s so ugly…….

BEGIN!

January ?, 2014

Wow so I didn’t write the date~~~~~

So during that day of January we were talking about the program design process and how it has two phases. The problem solving phase and the implementation phase. I have in my notes that the implementation phase is not that challenging intellectually speaking. Eh. I kinda agree I guess for someone who knows all the commands the implementation won’t be as hard as the problem solving phase, which is very challenging. But to me they are both challenging because I still have a lot to learn.

Next I have the words:¬†Programming Paradigm and I remember this day as clear as day, lol. That day the professor went on about this and I just sat there and wondered. But now I’m like why did I just not tell him that I wasn’t getting it? Gosh! Luckily my class participation has been increasing lately and being more honest when I don’t understand something! ;). But since I lost my chance with this one I just looked it up. First of all I’ll go to the dictionary and tell you what that strange magic word means. My dictionary says this: 1. a set of forms all of which contain a particular element, especially the set of all inflected forms based on a single stem or theme.

2. an example serving as a model; pattern.

Then I went to a website and it says that a Programming language Paradigm is the various systems of ideas that have been used to guide the design of programming languages. So yeah it’s pretty much the definition of paradigm but applied to programming. I guess I just wasn’t following that day but I think that IS what the prof was saying.

Then I have the prof kept talking about programming languages but now he moved on to object programming languages. These are not very popular anymore because they’re not modern. But what are these¬†object programming languages? Well like I said, me = very bad at that BEAUTIFUL thing they call concentration, so much better than gold!!! I wish I had concentration powers!!!!! If I could just concentrate I would break my limits!!! Not the point, the point is that I just found some info online about it. First of all according to this website, “objects are the things you think about first in designing a program and they are also the units of code that are eventually derived from the process. In between, each object is made into a generic¬†class¬†of object and even more generic classes are defined so that objects can share models and reuse the class definitions in their code. Each object is an instance of a particular class or subclass with the class’s own methods or procedures and data variables. An object is what actually runs in the computer.”

http://searchsoa.techtarget.com/definition/object

O.k now that we know what objects are let’s see what the book and slides have to say about OOP. The book says OOP is viwed as a collection of interacting objects. It says that programming in OOP consists of designing the objects and algorithms they use. OOP has 3 characteristics:¬†Encapsulation, inheritance and polymophism.

Going back to my notes I have that polymorphism can be divided in poly = many and morphism = shape.

Encapsulation is simplification of the description of objects so it’s like you’re hiding that description, I think.

Inheritance is writing reusable code, so it’s like recycling!!

Polymorphism is where a single statement can have multiple meanings within the context of inheritance.

January ?1, 2014

On that day,¬†no date again, I started taking notes when the professor was defining what a directive is. Uuuuugh!!!!!! But I just wrote directive = when the compiler compiles your program and left 2 blank lines and kept writing about what an instruction is… Shame on me… Luckily we have the book and slides! The slides say that include directives, example:

#include <iostream>

tell the compiler¬†where to find information about items¬†used in the program. In the example we used iostream, the most common directive I’m guessing because this one is the library that contains the definitions of cin and cout. And what would we do without cin and cout??? lol

O.k so an instruction (I actually got the full def on that one) is how you want your computer program to run and what you want it to do.

Then I have this question written down: Why would I want to use a directive? It takes less space. Behind the iostream directive there’s a lot of code.

I’m guessing what the prof is saying is that if we don’t use directives such as iostream then we’d have to define everything on our sourcecode and that would not only take a lot of space but also a lot of time.

Next thing is something that I also got lost at. It was like the prof was saying the names of the parts of the proggram but once again I got lost… And once again I did not ask. This time because I felt everyone around me knew this already so I ask the next guy and guess what? He doesn’t know… Should’ve asked the prof, Shirley. Now you’re regretting it. But I could always go back to his office, lol. You know what strikes me? That he has office hours at 7:00 am! W0W! But I go anyway! It’s fun because it forces me to be really early in campus which is a good thing because I feel more compelled to work!

O.k so I have that int main is the function header. Then the whole thing enclosed in {….} is the function definition. I guess it makes sense but I’m not sure how truthful it is because I was lost the day I wrote this. Guuuh~ And even so I feel like I already ask a lot in class…

Next we move on to talk about variables.You know how we declare variables, well guess what? We also define them and there is a difference between these two things! When you define a variable you give it a value. When you declare a variable you just describe it but it has different values.

Variables can vary. This is why it makes no sense to talk about the value of a variable. The concept of value of a variable depends on where in the executable program.

I find the sentence above a tad abstract considering that we just said that when we define a variable we give it a value but if you think about it makes sense because just because you gave it a specific value now doesn’t mean you can’t change it later.

Now I’m going to say something, don’t forget it because it looks small but it’s always the small things that we forget during a test, only to remember them right after we hand-in our unfinished full of mistakes test…

<< insertion symbol

>> extraction symbol

cin>> user has a chance to give a value

Hoho! And now I realize even more why speaking of the value of a variable makes no sense. It is because when you assign a value you do it like this for example:

total_peas = number_of_pods * peas_per_pod

You do it putting varibles together to give yet another variable that will vary but will have a current value at current times.

Oooooooooooooooooh! Here the prof gives us a menacing sounding WARNING!!!! It reads as follows:

“Think about¬†SEQUENCE¬†and have it deeply¬†ROOTED in your mind” – W0w! That makes a lot of sense if you want your program to run the way it has to w/ out any of the logic, runtime or syntax errors.

Another important thing to keep in mind is the the = symbol in programming DOES NOT mean equal to. It means “becomes”. Isn’t that amazing? Yet it’s kinda hard to shake the equals to off, lol. So why does it stop being an equality in programming? Because in order for an equality to be an equality it has to equal the same thing on both sides of the equality but that is no the case in programming. Because in programming the variable that has a name only becomes something for a little while but it never equals it. That is also why we don’t speak of the value of a variable.

Programming is managing perplexity! Yeah, got that sentence straight from my notes…

February 5th, 2014

Finally got a date written down.

O.k so this day we began learning about while and do while loops and boolean expressions which means we are finally in chapter two. But actually the whole variables thing was from chapter two as well.

 Boolean expressions are expressions that can be true or false. We use comparison operators such as <, >, >=, !=, ==. Boolean expressions can be combined using: && (and), || (or)

You know what is interesting? This: !. Back in the day when I learned about factorials I found it striking that the exclamation point was used as a math symbol also but now I’m learning here that in boolean expressions this: ! has yet another meaning,¬†negation.¬†

As for a loop, this is for when things need to be repeated. I understand there are many ways of doing this in C++ but I only know two so far. The while and the do-while. 

The process of the loop is the following (I got this straight from the slides the prof provides):

First, the boolean expression is evaluated
If false, the program skips to the line following the while loop
If true, the body of the loop is executed
During execution, some item from the boolean expression is changed
After executing the loop body, the boolean expression is checked again repeating the process until the expression becomes false
A while loop might not execute at all if the boolean expression is false on the first check.

So w/ that last sentence we see that there might be a problem w/ the looping, you know if it doesn’t execute at all. And that’s where the do-while comes in. The do-while makes sure that your loops execute at least once. And now a sample of a very useful little sourcode that you can apply to all your repetitive programs:

#include <iostream>

using namespace std;

intmain()

{

char answer;

do {

¬† ¬† ¬† ¬† ¬† ¬† cout << “Do you want to repeat (y/n)?”

            cin >> answer

} while (answer == ‘y’ || answer == ‘Y’);

   return 0;

}

 

There! If the user writes n or anything that isn’t y or Y the input will be false and the program will stop repeating itself.

So what is char, you ask? It’s a variable type. A nonnumeric one. Character. Variables for single symbols such as a letter, digit, or punctuation mark.

Another variable type is double, a variable type that can store fractional values.

Now we start talking about debugging again. Hooray! 

Image

The professor always says interesting things about why things are not right and when we talked about debugging this time he said debugging was an unfortunate name and then he asked why we thought he said that and tried guessing but try as I might I never guessed the right answer. So he told us and this is what I wrote down as I followed what he said: “A bug is an animal that has its own agenda if you find a bug it’s because it got there on its own. But if there’s an error in your program you put it there.”

Do you get what the prof was saying? I did and I agree but I still think debugging is a super cute name and love it and want it to stay forever! Bugs can be very pretty like the moth in the picture. Anyway what I understand the prof is saying is that you’re not guilty of a bug dying or resting on your computer but you are guilty of a mistake on your program.

Debugging = getting rid of bugs. Correcting mistakes.

Logic errors are¬†THE WORST because the compiler doesn’t tell you and the computer won’t tell you either.

O.k so this post turned out to be REALLY long but I wanna finish it and yet I wanna go to bed…

So anyway the prof asks us this: Can you eliminate an error with repeated tests? He gaves us the following answer, disclaimer: maybe he didn’t use the exact same words but something along the lines of: “Programs are discreet. No, we can’t eliminate them like that. If you run a test in one second but you want to test it 10^22 it would take years. So you can’t completely test a program.”

Then he said a wise man named ¬†Dijkstra said: “Testing can never show the absence of errors, only their presence”

Then things happened, slides were read blah. But at one pt the prof is like reading from the slide, he reads this: “variables are like small blackboards”

Image

Then he’s like no, no they are not. He disagrees w/ the slide and again he has an interesting reason. I like this about him because he is the first prof I’ve ever had who constantly does this and exposes good reasons for disagreeing. This time the reason even works as something you can use to never forget the following truth. He says variables are NOT like BB because you can erase a BB but you can¬†NEVER erase the value of a variable because they¬†ALWAYS¬†have a value. Even if they are just garbage values.

O.k so variable naming. Imp thing to remember about this is to always choose good names for your var. Names that describe what it will be used for. After explaining things we did the following exercise: How would we name a variable for How much distance since the car was last gassed? We had give him names. THese were the ones given by different students:

gas (me)

milage (Rick)

lasttimegasmiles (me)

miles_used (someone)

gas_used_in_miles (someone)

distance_traveled (me)

X (someone)

Image

So guess who won? ME!!!!!!! The prof said the best name was lasttimegasmiles but that it should be rearranged like this: Miles_since_last_gassup. Hoorah! The loser was X because it says nothing about what the variable will be used for. The rest were so-so. Choosing good names for your variables is an extremely important thing for understanding your program.

Now we talk about keywords. who are also called reserved words. They have a predefined meaning in C++ so their names can’t be used as variables or anything else. Some of these reserved words are int and double.So anyway in my notes I have more things that show how math symbols are not the same in programming. Like Q apparently in math Q represents rationals. I did not know that. And check this out! Becomes this = only means becomes in programming you can do cool things like this:

number_of_bars = number_of_bars + 3

More imp things:

*initializing means your assigning international value to the variable. It can be explicit or as input.

*You don’t want excessively long lines in your program. It makes it hard to read.

Check this out! The importance of using the write variable type!!

We know that (mathematically speaking) 2/5 = 0.4

But if we do this: int V1 = 5; >>>>>> 2/5 = 0. Because it only gives youintegers.

Now if we do this instead:

double V2 = 5.0; >>>>>>>>>> 2/5 = 0.4

Don’t forget:

1. single quotes = enclose characters, single letters, symbols, digits

2. double quotes = enclose strings of text

include directive = head out files, we talked about this earlier…

\n = newline 

ooooh! This one is SUPER imp! I remember I wasn’t getting it but I asked and the prof helped me get it! It’s actually simple I was just w/ my head in the super clouds as always…

O.k when you right something for output you use double quotes but when you run the program these don’t show. So if you want something to be quotated you need a special command for it.¬†

Quote character = \”

Example:

cout << “\”Quoted textn.\””

This is the end of my post for today I’ll continue it tomorrow!!! I’m TOO sleepy for this!! ūüôā

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s