Final Exam

--Originally published at oscarlopez95blog

What is an object?

Something that has state and behavior, state can be things to describe the object. (Color, shape, weight, etc.) And behavior is what the object does (Running, talking, walking, etc.)

What is an attribute?
Attributes are the state of the objects, are things who will describe and make your object. If you had a cat object, your attributes would be its size, weight, color, name, etc.

What is a method?
Methods are the behavior of the object, they tell the objects what to do and how to do it. For example if you had a cat object, then the methods would be Walking, meowing, eating, etc.

What is abstraction?
Abstraction in object oriented programming is basically giving information on what the object does, but not how it does it.
Abstract classes don’t need to have abstract methods, but if a class has 1 or more abstract methods, then it needs to be declared as an abstract class.
To use an abstract class you don’t instantiate it, you inherit it from another class, and you need to provide implementation to all the abstract methods it has.

What is encapsulation?
Is wrapping the data and the code that uses said data (methods) together. When you encapsulate a class, its variables will be hidden from other classes and can only be accessed through methods of their current class. To achieve encapsulation you must declare the variables as private and provide public setter and getter methods to modify and view the variables.

What are “has-a” and “is-a” relationships?
“Has-a” relationship is basically when you describe an object, for example a Cat has 4 legs, a name, color, size and weight.

Meanwhile, a “is-a” relationship is when you categorize something, for example a cat is a mammal. You have to realize this only goes one way, for example, every cat is a mammal, but not every mammal is a cat.

What are the mechanics for class description (coding) in the JavaProgramming Language?
For class description in Java we use comments, we use them to make our code understandable and easy to debug, to write a comment you just do this:
/** This is a comment */

What are visibility modifiers, their purpose and use in practice?
There are basically 4 visibility and access modifiers in Java:
Default
Private
Public
Protected

The first one, the default one doesn’t use any keyword. And what it does is a variable or method declared without any modifier is only available to classes in the same package.

Private is the most restrictive, it makes variables and methods only available to the class they are declared on, classes and interfaces can’t be private.

Public is the most open one, a variable or method can be accessed by any other class. But if the class we are trying to access is in a different package, it needs to be imported.

Protected basically allows any subclasses to access the variables and methods in a superclass.

What are inheritance and polymorphism? (Specification and implementation)
Inheritance is the process where one class acquires the properties (methods and fields) of another. The information is managed in hierarchical order.
The class which inherits the properties of other is known as subclass, and the class whose properties are inherited is known as superclass. It uses the “extends” keyword.

class Mammal{

}

class Cat extends Mammal{

}

Polymorphism is the ability of an object to take many forms, the most common use is when a parent class reference is used to refer to a child class object.
Any object that can pass more then one “is-a” relationship is considered polymorphic.

public interface Vegetarian{}
public class Animal{}
public class Deer extends Animal implements Vegetarian{}

By this logic, Deer is-a animal, vegetarian, deer and object.

What is delegation?
Inheritence uses the java compiler’s type system to implicitly include code from elsewhere, with delegation you explicitly implement the callout.

Inheritance is limited to a single parent class (and ancestors) but it can sometimes be non-obvious where your code is going; delegation is less elegant, but you can bring in functionality from multiple other classes and the flow is clearly visible.

What are CRC cards and how do we use them?
CRC cards are usually created from index cards. Members of a brainstorming session will write up one CRC card for each relevant class/object of their design. The card is partitioned into three areas:

On top of the card, the class name
On the left, the responsibilities of the class
On the right, collaborators (other classes) with which this class interacts to fulfill its responsibilities

Using a small card keeps the complexity of the design at a minimum. It focuses designers on the essentials of the class and prevents them from getting into its details and implementation at a time when such detail is probably counter-productive. It also discourages giving the class too many responsibilities. Because the cards are portable, they can easily be laid out on a table and re-arranged while discussing a design.

What are overloading and overwriting? How do we implement those in Java?
Method Overloading is a feature that allows a class to have two or more methods having same name, if their argument lists are different. To overload, you have two or more methods with the same name, but different arguments.

The benefit of overwriting is: ability to define a behaviour that’s specific to the subclass type which means a subclass can implement a parent class method, but with different arguments. To overwrite, you re-write a method from the super class, with different arguments.

What is the metaobject protocol?

The essence of a Metaobject Protocol is simple: every aspect of a program’s mapping down onto the lower level substrate (i.e. its compilation and runtime support) is controlled by some object or set of objects following a well-defined protocol. These objects are called metaobjects, because they are about the mapping of the program, rather than objects in the program’s primary subject domain. Client programmers can replace one or more of these objects with specialized ones to affect specific aspects of the implementation of specific parts of their program.

What do you feel are the benefits to object-oriented programming?
Code Reuse and Recycling: Objects created for Object Oriented Programs can easily be reused in other programs.

Encapsulation (part 1): Once an Object is created, knowledge of its implementation is not necessary for its use. In older programs, coders needed understand the details of a piece of code before using it (in this or another program).

Encapsulation (part 2): Objects have the ability to hide certain parts of themselves from programmers. This prevents programmers from tampering with values they shouldn’t. Additionally, the object controls how one interacts with it, preventing other kinds of errors. For example, a programmer (or another program) cannot set the width of a window to -400.

Design Benefits: Large programs are very difficult to write. Object Oriented Programs force designers to go through an extensive planning phase, which makes for better designs with less flaws. In addition, once a program reaches a certain size, Object Oriented Programs are actually easier to program than non-Object Oriented ones.

Why do you think your change to object-oriented programming is difficult or what makes it difficult for the standard student?
I think it’s difficult to start because it requires more planning than other ways to program. To create an object-oriented program you need to design it very well, and even though it gets easier as the program gets more complex, the beginning of the program is hard, and by consequence, the learning curve for object-oriented programming tends to be harder at the start.

 


Final Exam

Course Review

--Originally published at oscarlopez95blog

This is my Course Review for my Object oriented programming class with Ken. First of all, my overall opinion on the course is that it is something really new, and the fact that Ken focuses a lot on us learning the concepts helps a lot with the learning curve of the topics. Also, I believe it’s better to learn Object oriented programming in general and then focus on a language that we need, instead of just learning Java por example.

 

What I think about the topics

The class is about Object oriented programming, and we’ve seen many topics, from objects to polymorphism and delegation. But honestly I think there should be a more interactive way to learn about those topics rather than just reading about them and trying to implement them from nothing.

Sometimes students who are completely new to object oriented programming can get lost because there are so many new things and they’re really different from what you’ve seen before that it just takes time and practice to fully understand them.

What I think about #AbolishGrading

I think this idea is pretty neat, it gives more freedom to the students and prepare us for real life situations. As an engineer you’ll never go to work and your boss will tell you “I need you to write a code that does X thing, but you can’t look anywhere to help yourself”, and after you’re done something like “Oh that’s good, but not great, 83” That’s just not real.

We as engineer students need to realize that a work or a project is about us working as hard as we can and fulfilling both our own and our teacher’s expectations about it.

The grading system doesn’t reward knowledge or how much have you learned, that’s why students cheat, because all they care about is a grade which practically means nothing if they haven’t learned anything.

What I think about Ken

This is the second class that I’ve had with Ken in my degree and I can honestly say he’s one of the best teachers I’ve had in my life. His ideas are new and fresh and he’s not afraid to do and say what he thinks is right for us. He’s not the typical teacher who just grades book summaries and stands up in front of the class room reading a powerpoint presentation, and we need more teachers like him.

Ken, keep up the work like always, don’t let some students too used to the old school system or other teachers thinking you’re crazy change your mind about what’s the best way to facilitate knowledge. Because we both know it’s not about “teaching” is about being a facilitator for students who actually want to learn and become better.


Course Review

Project advancements – Hangman done!

--Originally published at oscarlopez95blog

So our project as you already know will be an arcade machine simulator, with different games, a credit system and 2 players.

We’ve already finished the hangman game and we’re almost done with the other two.

We just need to implement the game logic into a graphic environment.

Here’s the code for the game.

If you have any questions about how we did it feel free to comment on this post.


Project advancements – Hangman done!

Partial 2 masteries

--Originally published at oscarlopez95blog

What are inheritance and polymorphism? (Specification and implementation)
Inheritance is the process where one class acquires the properties (methods and fields) of another. The information is managed in hierarchical order.
The class which inherits the properties of other is known as subclass, and the class whose properties are inherited is known as superclass. It uses the “extends” keyword.

class Mammal{

}

class Cat extends Mammal{

}

Polymorphism is the ability of an object to take many forms, the most common use is when a parent class reference is used to refer to a child class object.
Any object that can pass more then one “is-a” relationship is considered polymorphic.

public interface Vegetarian{}
public class Animal{}
public class Deer extends Animal implements Vegetarian{}

By this logic, Deer is-a animal, vegetarian, deer and object.

What is delegation?
Inheritence uses the java compiler’s type system to implicitly include code from elsewhere, with delegation you explicitly implement the callout.

Inheritance is limited to a single parent class (and ancestors) but it can sometimes be non-obvious where your code is going; delegation is less elegant, but you can bring in functionality from multiple other classes and the flow is clearly visible.

What are CRC cards and how do we use them?
CRC cards are usually created from index cards. Members of a brainstorming session will write up one CRC card for each relevant class/object of their design. The card is partitioned into three areas:

On top of the card, the class name
On the left, the responsibilities of the class
On the right, collaborators (other classes) with which this class interacts to fulfill its responsibilities

Using a small card keeps the complexity of the design at a minimum. It focuses designers on the essentials of the class and prevents them from getting into its details and implementation at a time when such detail is probably counter-productive. It also discourages giving the class too many responsibilities. Because the cards are portable, they can easily be laid out on a table and re-arranged while discussing a design.

What are overloading and overwriting? How do we implement those in Java?
Method Overloading is a feature that allows a class to have two or more methods having same name, if their argument lists are different. To overload, you have two or more methods with the same name, but different arguments.

The benefit of overwriting is: ability to define a behaviour that’s specific to the subclass type which means a subclass can implement a parent class method, but with different arguments. To overwrite, you re-write a method from the super class, with different arguments.

What do you feel are the benefits to object-oriented programming?
Code Reuse and Recycling: Objects created for Object Oriented Programs can easily be reused in other programs.

Encapsulation (part 1): Once an Object is created, knowledge of its implementation is not necessary for its use. In older programs, coders needed understand the details of a piece of code before using it (in this or another program).

Encapsulation (part 2): Objects have the ability to hide certain parts of themselves from programmers. This prevents programmers from tampering with values they shouldn’t. Additionally, the object controls how one interacts with it, preventing other kinds of errors. For example, a programmer (or another program) cannot set the width of a window to -400.

Design Benefits: Large programs are very difficult to write. Object Oriented Programs force designers to go through an extensive planning phase, which makes for better designs with less flaws. In addition, once a program reaches a certain size, Object Oriented Programs are actually easier to program than non-Object Oriented ones.

Why do you think your change to object-oriented programming is difficult or what makes it difficult for the standard student?
I think it’s difficult to start because it requires more planning than other ways to program. To create an object-oriented program you need to design it very well, and even though it gets easier as the program gets more complex, the beginning of the program is hard, and by consequence, the learning curve for object-oriented programming tends to be harder at the start.


Partial 2 masteries

Partial 1 masteries

--Originally published at oscarlopez95blog

What is an object?

Something that has state and behavior, state can be things to describe the object. (Color, shape, weight, etc.) And behavior is what the object does (Running, talking, walking, etc.)

What is an attribute?

Attributes are the state of the objects, are things who will describe and make your object. If you had a cat object, your attributes would be its size, weight, color, name, etc.

What is a method?

Methods are the behavior of the object, they tell the objects what to do and how to do it. For example if you had a cat object, then the methods would be Walking, meowing, eating, etc.

What is abstraction?

Abstraction in object oriented programming is basically giving information on what the object does, but not how it does it.
Abstract classes don’t need to have abstract methods, but if a class has 1 or more abstract methods, then it needs to be declared as an abstract class.
To use an abstract class you don’t instantiate it, you inherit it from another class, and you need to provide implementation to all the abstract methods it has.

What is encapsulation?

Is wrapping the data and the code that uses said data (methods) together. When you encapsulate a class, its variables will be hidden from other classes and can only be accessed through methods of their current class. To achieve encapsulation you must declare the variables as private and provide public setter and getter methods to modify and view the variables.

What are “has-a” and “is-a” relationships?

“Has-a” relationship is basically when you describe an object, for example a Cat has 4 legs, a name, color, size and weight.

Meanwhile, a “is-a” relationship is when you categorize something, for example a cat is a mammal. You have to realize this only goes one way, for example, every cat is a mammal, but not every mammal is a cat.

What are the mechanics for class description (coding) in the JavaProgramming Language?

You have to remember that classes cannot be private, so when creating a class, it should look like this:

public class ClassName(){

}

note that the class name has no spaces and usually uses capital letter to indicate the start of a new word.

What are visibility modifiers, their purpose and use in practice?

There are basically 4 visibility and access modifiers in Java:
Default
Private
Public
Protected

The first one, the default one doesn’t use any keyword. And what it does is a variable or method declared without any modifier is only available to classes in the same package.

Private is the most restrictive, it makes variables and methods only available to the class they are declared on, classes and interfaces can’t be private.

Public is the most open one, a variable or method can be accessed by any other class. But if the class we are trying to access is in a different package, it needs to be imported.

Protected basically allows any subclasses to access the variables and methods in a superclass.

What are inheritance and polymorphism? (Specification and implementation)

Inheritance is the process where one class acquires the properties (methods and fields) of another. The information is managed in hierarchical order.
The class which inherits the properties of other is known as subclass, and the class whose properties are inherited is known as superclass. It uses the “extends” keyword.

class Mammal{

}

class Cat extends Mammal{

}

Polymorphism is the ability of an object to take many forms, the most common use is when a parent class reference is used to refer to a child class object.
Any object that can pass more then one “is-a” relationship is considered polymorphic.

public interface Vegetarian{}
public class Animal{}
public class Deer extends Animal implements Vegetarian{}

By this logic, Deer is-a animal, vegetarian, deer and object.


Partial 1 masteries

WSQ08 – Yo Soy 196

--Originally published at oscarlopez95blog

I finally finished this WSQ, and now that I’ve done it I don’t think is that difficult. Is a challenge, but by no means impossible.

Here’s my code.

One thing that I had wrong at first was the fact that numbers that COULD become a palindrome before 30 iterations but where too long for “int” to represent them correctly were appearing as lychrel numbers. (89 for example)

I fixed that problem by using “long” instead of “int”.

If you have any questions, feel free to ask me anytime:)


WSQ08 – Yo Soy 196

WSQ05 – Project

--Originally published at oscarlopez95blog

-This is a Work In Progress-

1st entry:

So, right now our team (Luis, Gio, Itzel and myself) are planning to make an arcade, it’ll have a main menu and at least 2 games to play. That’s the main idea and we have been talking about adding credits and how the user will earn them, but there’s nothing definitive yet.

If you’re interesed, the main menu is basically done, we just have to create each game and link them with the menu.

Here’s the menu in GitHub

I’ll update this post as we move forward with this project.


WSQ05 – Project

WSQ04 Flipped Learning / Abolish Grading

--Originally published at oscarlopez95blog

I just finished reading this post about abolishing grading.

It’s written by a guy who did really well in high school, but then he realized all his dreams about his education were based on getting good grades and not learning. It’s really interesting when you start thinking about it. Students actually care more about getting a good grade than learning something useful, we don’t see a new subject as “Will I ever need this in my career?” we see it as “This will be in the exam”.

It is said that students cheat because in our educational system grading is more important than learning, and it’s actually true. My dad is really strict when it comes to school,  so he always wants me to get the best grades possible, obviously as any person sometimes I fail to do so, and he gets mad. But he has never asked me “What did you learn in this class?”, instead, he asks me “What grade did you get?” and that’s it.

I think is BS that we focus so much in made up numbers that are supposed to be measures of our intelligence and dedication. We should appreciate the time each student dedicates to a subject. We shouldn’t tell students “You need to learn this, and in this way. If you don’t you’ll fail”. Everyone needs to realize you can’t test every person equally, we’re all different with different strengths and weaknesses. And our educational system doesn’t make use of it. They just ignore it.

If you support this idea, please tweet your thoughts and put #AbolishGrading.


WSQ04 Flipped Learning / Abolish Grading