Mr I Never Use an Umbrella

TC201 #CourseReview – Mr. I Never Use an Umbrella

This course has been something really new to me.

I learned the more fundamental concepts of Object Oriented Programming, as well as putting most of these into practice. Classes, objects, attributes and methods. APIE: Abstraction, polymorphism, inheritance, encapsulation and delegation. Has-a, is-a relationships. Visibility modifiers. Overloading and Overriding. Also I learned about software development tools and practices like UML and CRC cards. I still have to learn about the metaobject protocol. I also learned a lot about the Unity game engine and about video game networks and protocols, the Authoritative Server approach, latency compensation, client prediction, server reconciliation and other interesting concepts. this and this  are some really nice articles about the subject.

First off, I thought I wasn’t doing a lot of things, the course was really relaxed, doing the assignments whenever I wanted and learning whatever I wanted. A lot of people coursing OOP with Salinas told me that I was learning nothing, because the way the class works. But at the end of the first partial I realized I had learned more than my fellows from the class of Salinas, and they are still saying “you didn’t learn about Java user interfaces”,  but honestly, I don’t give a duck about user interfaces. I was learning all the theory and doing the programming wsq’s by, which is quicker than having the teacher trying to put the concepts in everyone’s head in one class, because I think everyone has it’s own learning rhythm.

I personally think this teaching method is really good and could work really well, but first, ken has to polish some aspects of the course:

First, there must be more emphasis on doing the assignments, because people (at least most I know) is not very interested in self-education, they don’t do the things they should until they realize they have one or two days left for finishing everything. They don’t manage their time correctly, they prefer to procrastinate all the time instead of focusing in what is really important.

Second, I think there should be more programming assignments, sometimes I learned the concepts, did the posts about what I learned and everything but never put these concepts into practice, making me feel like I did not master the topic completely, and I don’t mean learning Java, I mean reinforcing the concepts learned with something practical, because I definitively think that this class (and every programming class) should be language agnostic, focusing on learning the theory and putting these concepts in practice in whichever language the student wants.

I think that if ken really efforts improving his course in these aspects he will have a really, really good course, keep the good work!

Anuncios

James Gosling interview

Just finished watching Triangulation 245, featuring James Gosling, the creator of Java, one of the most popular programming languages in the world, and the Java Virtual Machine.

Glossing staring right into your soul

Gosling staring right into your soul

He was interested in programming at an early age. The idea of creating Java came from observing how everything was switching from hardware to software, writing code instead of inventing new machines. I also want to point out that he is Canadian.

Canadian-Flag.jpg

Overloading vs. Overriding

Overload

Serendigity. “Overload” Online Image. Flickr. Octover 3, 2007. https://www.flickr.com/photos/maleny_steve/1473552769/

Overloading and overriding are two similar concepts -they both are about creating several methods with the same name- but very different when it comes to practical functionality and implementation.

Overloading (formally, static polymorphism) is resolved at compile time, and it is when the methods with the same name are declared in the same class, distinguished only by their signatures (the parameters of the method), so that the compiler knows which method overload you are calling based on the data type of the arguments you are passing.

Overriding (or overwriting, according to ken), is resolved at runtime and it is when you define a method that is already defined in a parent class. It can be resolved because of the data type of the “implicit first parameter” (aka, the object itself).

Java implementation

Overloading

overloading1

Overloading with different data types and number of parameters.

overloading2

Overloading with same data types and number of parameters, but different order.

overloading4

Overloading allow different return types.

overloadingerror1

The return type of the method is not considered when overloading.

Overriding

overriding4.png

In this example of overriding I have the Person abstract class, this class cannot be instantiated, but it provides like a “template” for its children classes. For example, the Person class has a String field “name”, because every person has a name, and a public method “talk” because all persons can talk (ok, almost all), this method prints “I’m a ” to the console, because, like I said, this is like a template, and different persons have different (very interesting) things to say. The method “getName” returns the name of the person. The constructor just takes the String name, although you can’t call this constructor directly, it can be called from its children classes.

It’s children classes are not abstract and extend (are children of) the Person class. They implicitly have “name”, a method “talk” and a method “getName”. Read the code of the Student and the Teacher classes and note how the constructors have a line “super(name)”, this is a call to the parent class constructor, and it will throw an error if it’s not there. Both the Student and the Teacher class Override the talk method, the notation @Override over the talk method just tells the compiler that you are overriding a method (no shit, Sherlock), it’s not required but you should use it to enforce proper overriding of a method. The talk() methods of Student and Teacher call the “super.talk” method (unlike the constructor, you can miss this statement here and there will be no errors), it prints “I’m a “, and then it prints something else. I also included an Overload of an Overriding method (mind blown) in the Student class to show the difference, it just prints “I love” + the argument (there is no call to super.talk()).

In the main method of the Person class I declare 2 persons, one teacher and other student, also, I declare a Student as a Student, this sound stupid but actually affects in the code. The preferred way is to declare the variable with the data type of the abstract class and instantiate it as the type that you actually want to use (Declared type on the left  and Actual type on the right so your code is not dependent from a specific implementation of an interface/abstract class. You can read more about this here. You can see that when the talk method is called from both the teacher and the student they print different things. Finally, to call the Overload method “talk(String food)” of “s” (with Declared type Person and Actual type Student) you have to implicitly cast it to Student and then call the method, like ((Student)s).talk(“tacos”), this is because this implementation is not declared in the Declared type of “s”. However, with “c” this does not happen, you can call that overload method because the Declared type of “c” is Student. Anyway, this is not considered a good OO practice, you should avoid writing methods that are not in the parent class, because there is a method specific to the Children class, and therefore making the code dependent from that class, and what you want is to make the code independent from specific implementations of the children classes (like explained in the previous stack overflow link).

11w1f1

tutu sparkles

#WSQ11-Library

And this is the most boring wsq that I have ever done!
Because all it asked of me was filling the blank methods with just some return statements in most cases.
The most interesting I did in this assignment was doing a for loop and throwing some exceptions.

So i entered the WSQ11 blog post in kenscourses and clicked the first link because I’m too lazy to read.
And the first thing I notice is that I don’t know what to do here, obviously, instead of go back and read the instructions I started doing the first assignment.
wut

After some dedication and hard work doing that thing about gravity I realized it was too stupid, so I deleted all the files, including System32.

So now I had the tough task of reading the instructions.
According to the English dictionary of Cambridge, the word “to” is pronounced as “tu”.
The instructions said that I should try to “tutu” the Library assignment.
tutu

All I did in the book class was add some fields, getters and setters.
part1

And in the Library class I just used the Book class to create the simulation of a library.
It also asked me to create a static method, I was so excited.
final

After that I kept reading and clicked on a link, and the first thing a saw was a big message saying “Buy my book!”, it was so gross that I had to leave the site.
buyMyBook

github