Concept Summary – Study Guide

--Originally published at chozaoop

Hey there, this post will be about reviewing the concepts which will be featuing in the second partial exam of #TC201, check it out.

Inheritance and Polymorphism were already posted here.

I’ll be taking information from various internet websites and then link the source below.

Delegation

“Delegation is like inheritance done manually through object composition.”

It is a technique where an object expresses certain behavior to the outside but in reality delegates responsibility for implementing that behaviour to an associated object.

Delegation is an abstraction mechanism which centralizes object (method) behaviour.

You can use the delegation pattern when you need to reduce the coupling of methods to their class, you have components that behave identically, but realize that this situation can change in the future.

Or in general: use delegation as alternative to inheritance. Inheritance is a good strategy, when a close relationship exist in between parent and child object, however, inheritance couples objects very closely. Often, delegation is the more flexible way to express a relationship between classes.

Now check this image and this code evolution.

Concept Summary – Study Guide

Concept Summary – Study Guide

All the information, concepts, images and snips were taken from this SOURCE.

—————————————————————————-

CRC CARDS

I think we should have already watch a video about CRC Cards in this lynda.com course (the bald guy course). Really useful by the way, nevertheless, here’s some other stuff.

CRC stands for CLASS, RESPONSIBILITY and COLABORATION.

A class represents a collection of similar objects. An object is a person, place, thing, event, or concept that is relevant to the system at hand.
A responsibility is anything that a class knows or does.
You should ask yourself what a class does as well as what information you wish to maintain about it. You will often identify a responsibility for a class to fulfill a collaboration with another class.
A class often does not have sufficient information to fulfill its responsibilities. Therefore, it must collaborate (work) with other classes to get the job done. Collaboration will be in one of two forms: a request for information or a request to perform a task. To identify the collaborators of a class for each responsibility ask yourself “does the class have the ability to fulfill this responsibility?”. If not then look for a class that either has the ability to fulfill the missing functionality or the class which should fulfill it. In doing so you’ll often discover the need for new responsibilities in other classes and maybe even the need for a new class or two.

Another explanation would be:

 The front of a CRC card for a class looks like this,

      ---------------------------------------------------
     |  Class Name                     | Collaborators   |
     |  -----------------------------  |                 |
     |  Responsibilities               |                 |
     |                                 |                 |
     |                                 |                 |
     |                                 |                 |
      ---------------------------------------------------

   The "Class Name" section just contains the name of the class.

   The "Responsibilities" section describes the tasks an object of the class is 
supposed to carry out.  It should simply describes what is to be done, and it 
should avoid mentioning any of the detaile details of how the tasks are to be 
carried out.

   The "Collaborators" section should definitely contain any classes the object 
needs to carry out its tasks.  In some designs, but certainly not all, it may 
also include classes that use the object.

   The back of a CRC card for a class looks like this,

      ---------------------------------------------------
     |  Class Name                                       |
     |  -----------------------------                    |
     |  Variables                                        |
     |                                                   |
     |                                                   |
     |  Methods                                          |
     |                                                   |
     |                                                   |
     |                                                   |
      ---------------------------------------------------

    The "Variables" section lists the global variables (object state variables) 
an object of the class needs to maintain.

    The Methods section lists the methods of the class.  It should simply list 
the method signatures (method return types, names and parameter lists) and brief
descriptions of what the methods do.  It should avoid mentioning any details 
about how the methods carry out their tasks.  Typically, each method carries out
one of the tasks listed in the Responsibilities section.

All of the above was extracted from this SOURCE.
—————————————————————————-

Overloading vs. Overriding

Ken explained this concept on theeeeee Tuesday class i think…

Ok so, we already saw this example from the Intel Forum Website:

1)
Method overloading is used to increase the readability of the program.
Method overriding is used to provide the specific implementation of the method that is already provided by its super class.

2)
Method overloading is performed within class.
Method overriding occurs in two classes that have IS-A (inheritance) relationship.

3)
In case of method overloading, parameter must be different.
In case of method overriding, parameter must be same.

4)
Method overloading is the example of compile time polymorphism.
Method overriding is the example of run time polymorphism.

5)
In java, method overloading can’t be performed by changing return type of the method only. Return type can be same or different in method overloading. But you must have to change the parameter.
Return type must be same or covariant in method overriding.

Java Method Overloading example

  1. class OverloadingExample{
  2. static int add(int a,int b){return a+b;}
  3. static int add(int a,int b,int c){return a+b+c;}
  4. }

Java Method Overriding example

  1. class Animal{
  2. void eat(){System.out.println(“eating…”);}
  3. }
  4. class Dog extends Animal{
  5. void eat(){System.out.println(“eating bread…”);}
  6. }

 

Here’s an explanation by Hisham on Stackoverflow:

Method overloading deals with the notion of having two or more methods in the same class with the same name but different arguments.

Method overriding means having two methods with the same arguments, but different implementations. One of them would exist in the parent class, while another will be in the derived, or child class.

Yet another summary by programmerinterview.com:

When overloading, one must change either the type or the number of parameters for a method that belongs to the same class. Overriding means that a method inherited from a parent class will be changed. But, when overriding a method everything remains exactly the same except the method definition – basically what the method does is changed slightly to fit in with the needs of the child class. But, the method name, the number and types of parameters, and the return type will all remain the same.

—————————————————————————-

Wow, kind of a long post, didn’t research THAT much but hey, we got the concepts!

Leave a comment if you’d like to, SHARE and please don’t settle with this post if you still have doubts or any uncomformity.

Sorry if you hate the fact that this was mostly a giant copy-paste, i personally think it’s the most efficient way of gathering information.

See ya!

 


Concept Summary – Study Guide

College Advice by Joel Spolsky

--Originally published at chozaoop

Whoops, haven’t post in a really long time, sorry about that, kinda busy with other subjects.

However, here’s WSQ10 on Ken’s Courses

It was about reading this article by Joel Spolsky.

Wow, i just finished reading this, i agree on many of these arguments and convinced myself that it IS important to take advice from the elder, it really got me thinking. Even if this was a post from 2005, it still makes a lot of sense, many things remain the same.

Joel recommends students to learn stuff such as C, microeconomics and how to write. Let’s focus on these 3 for the moment. He mentions that the C language, even if it seems old and “a waste of time”, it isn’t, he wants us to know that even before knowing some high level language, we need to start from the basics.

Microeconomics, this convinced me personally since it is our responsibility to manage and take care of our own economy, our numbers,  it is also REALLY important to a company (either yours or a one you are working on), that their employees know this, and actually it is kind of common to see that many majors on Computer Science, Electronics or any other Ingineering takes some course on economics or enterprise management.

Onto the how to write subject, Spolsky talks about the value of knowing how to formally and correctly express ourselves and convincing others as well. A thing that i’ve been told is the importance of knowing how to write manuals and instruccions for software or electronics you might do later on your career, in order to do this you MUST know how to read and write properly.

 


College Advice by Joel Spolsky

Some other concepts

--Originally published at chozaoop

Happy Valentine’s Day!

So in this post i’m gonna share the remaining OOP theoric concepts that will be featuring in partial #1 exam. Mentioning them and then referencing the source, if you like the explanations and would like to copy them you are free to do so, if you have a comment, leave a comment please, ya know, Ken likes discussion.

Abstraction

What is abstraction?

Abstraction is process of hiding the implementation details and showing only the functionality. Is used to hide certain details and only show the essential features of the object.

You implement it like this:

“abstract class <class-name>”as creating an abstract class

and as for a method “abstract public void <method-name>;”

This concept kinda relates to encapsulation, since encapsulation means hiding information inside the object, while abstraction deals with the outside or the interface.

Encapsulation = Object Internally —–Abstraction = Object Externally

An Abstact Class cannot be instanciated, and an Abstract method is a method which is declared without implementation.

An Abstract class and a Final Class have the opposite meaning.

When do i use it? When i know that i need to implement something, but not exactly what it is or how it should look like.

S O U R C E

Java Visibility Modifiers

            | Class | Package | Subclass | World
————————————+———————+—————————+——————————+———————
public      |  y    |    y    |    y     |   y
————————————+———————+—————————+——————————+———————
protected   |  y    |    y    |    y     |   n
————————————+———————+—————————+——————————+———————
no modifier |  y    |    y    |    n     |   n
————————————+———————+—————————+——————————+———————
private     |  y    |    n    |    n     |   n

y: accessible
n: not accessible

Really nice table.

Default: This one might be a mistake, it means adding no access modifier. As you can see on the table, only available this class or a class in the same package, it is not available for subclasses or the rest of the world.

Public: Available anywhere, any other class, subclass or even any class in the world, this one provides the most access while private provides the least.

Protected: I see this one as using the class inside your own works, i mean if you create a package and a class and then a subclass, protected modifier keeps any foreign intruder away, but still making it available for you.

Private: PRIVATE EYES! This modifier only allows access from the same class, no other package, subclass and obviously the rest of the world.

So remember:

Public > Protected > No Modifier > Private.

From most access to least.

Ok so the purpose of using these modifiers is, well, controlling the access to your member variables and functions, whether it is in your own program or most importantly, the outside world.

We do give it a use sometimes in this course but it’s really really important to know how to use these when making a big project since you never know who wants to mess up your stuff and if you know how to use modifiers it should keep you safe.

SO UR CE


Some other concepts

WSQ02

--Originally published at chozaoop

Ok fellas i’m a little late here, sorry, i got sick and have occupied my time on the other classes.

Anyway, here’s Hello World in Java, running from Eclipse and also having connection with Github.

There’s something weird going on here but atleast i managed to connect to Github, gotta ask Ken about this.

Here’s a Screencap:

WSQ02

I watched some Lynda vids in order to know the basics about setting this thing up and creating a Java Project.

Here.

 


WSQ02

WSQ05

--Originally published at chozaoop

This is entry number 01, i’m just gonna explain what is my team and i are thinking about this project.

We have these two ideas, either exploring the options in Unity Engine, such as making a entire new game, or just a collection of some classics like Pinball, Poker, some Cars, stuff like that.

Or making a text-based game but orienting it to objects to we give it the spice it’s needed, i was planning to go to Global Game Jam here on Campus but some Social Life stuff came up and i couldn’t go.

Hey, you guys should play Persona 3 or 4, it’s just a great game. I spent 100 hours into a single playthrough, just a great freaking game, IF YOU PLAY IT LEAVE A COMMENT, I JUST KNOW ABOUT 3 PEOPLE WHO PLAYS THIS.


WSQ05

WSQ04

--Originally published at chozaoop

Hey there, long time no see (that’s not good), here’s WSQ04; in this WSQ we were requested to read some articles and discuss, make our own comments about them and express how we feel by them.

I’m going to go one by one, just after i read it, i’m typing my opinions here.

“A Lecture From the Lectured”.

I think there’s a different situation here in Tec de Monterrey in comparison to some Universities in US, mostly because the classrooms here are kind of “reduced”, and by that i mean less students, comparing to classes in most Universities which make up to more than 100 students in a whole auditorium, here in Mexico, that’s a lot of people.

But in contrast, it is alike too, we still get lectured and people also get bored from time to time, may not come to class some days, and feel pretty distant to their professor. In this article, students (the lectured) give their own feedback about how they feel, what they feel, things they like and things they don’t, how they wish the professor to be.

These students express that there’s no connection between them and the teacher, feeling that he’s not someone they can speak to, they want to interact with the teacher so the class is not always a lecture, something you can even do on your own, but some dynamic learning in which they break that routine.

“An A+ student regrets his grades”.

Wow, this hitted me up, so Afraj Gill talks about how grading is some stuff from the past, how we need to change the way school is, how they measure your sucess based on some numbers, the way that most students apreciate an A+ on some subject more than what they learned or how they grew.

He discusses the fact that failure is, in most cases, punished by the system rather than teaching the students that, in fact, failure is part of learning and this has to do with one of Ken’s phrases that says “It’s okay to fail”.

Afraj says that actually the culture is a problem and we need to fix this from the ground up, which is a pretty difficult and complex process, but with great rewards.

Showing the Differences between a Traditional and a Flipped Classroom”

Really fun video, showing the contrast between those two type of learning, in my opinion, flipped class seemed more relaxed and flexible, in the way that you interact a lot with your teacher; not everything is just a bunch of theory throwed at your face. Also you have more time to fix some problems you had while reading at home or in this case (physics class) some exercise that gave you problems and such.

Regular class seemed more square, kind of the same you know, taking notes, asking the teacher, trying to comprehend just the theoric part and not even getting a grasp of what it works in the real life.

Obviously we saw that one is teacher-centered and the other is more of student-centered, it makes a lot of sense that classes should be indeed student-centered since there’s always a lot more of students than teachers and guess what? Students are the ones who must learn.

WSQ04

LET’S FLIP

 

 

 


WSQ04

WSQ03

--Originally published at chozaoop

Ok so the author here reviews some basic concepts of Object-Oriented Programming, some of these were already reviewed on one of Ken’s classes, but personally i gained some new knowledge here.

All the “snips” and annotations i’ll be taking are from this video. Since i liked the images he used for explaining the concepts, they seems clear and simple.

Encapsulation:

WSQ03

“The idea of encapsulation is simply that the fields of an object, an instance should only be read or written by methods of that instances class…”

“If we want to read or write one of these fields, we should not do so directly from outside the object, only the methods of the class should be directly reading and writing these fields from outside the class, externaly we only interact with the fields indirectly by invoking the methods, the thinking here is that we create a class, the methods you give that class ENCAPSULATE the encompass all the knockledge of what is meant to be done with the data that makes up that data type…”

Inheritance:

WSQ03

“The idea of inheritance is simply that some data types, some classes may overlap, such as that one data type has all the same stuff found in another…”

So in this example above the Cat class inheritances from Mammal and them both inherits from Animal, which means that the Mammal class automatically inherits all of the members from the animal class, and so, the Cat class inherits the members from both of above, even if when you wrote the Cat class you only specified “F” and “G”.

We could say that Mammal and Cat are subtypes of Animal, and Cat is a subtype of Mammal, and so, Animal would be a supertype of Mammal and Cat, kinda easier to say Parent and Child.

Also, let’s say it like this, the Animal class has some methods or states which could be Eating, Sleeping and Breathing, Mammals also have these properties BUT, Mammals also have some “unique” properties such as, hot-blooded or furry idk, but also Cat has some properties which Animal and Mammal don’t such as Purring or Meowing.

Is-a vs. Has-a:

WSQ03

Here we ought to ask ourselves, is a relationship between these two classes an “is-a” relationship or a “has-a” relationship, like the past example, Mammal class was a more specific type of class than Animal, that’s a “Is-a” relationship, which is a proper use of inheritance.

Another example is about a car, a car is composed of many parts, let’s say that we have a Stereo class, and we have a Car class, then it would make sense that the Car class has a “Stereo” field, which is a “Has-a” relationship, since it calls for composition.

It would not make sense to have the Stereo class inherit from the Car class, because the Stereo is not a kind of Car, nor the other way around either, because the Car is not a kind of Stereo, if we were going to extend the car class we would do so as something like: Ford or Sedan or Jeep, something which is a Car, just a more specific type of Car.

Polymorphism:

WSQ03

Ok so here i’ll explain it myself, let’s say we create a method called foo(), in the class “Jack”, Ted inherits is but then we create another one called also foo() in Lisa, then Kate and Mike inherits this, if we call a Kate, Mike or Lisa object, this will invoke the foo() method created in Lisa, but if we do so from Ted or Jack, it will call the method created in Jack.

Kind of vague explanation of Polymorphism, i understand that the word itself means “changing forms”, i might ask Ken for help throught the week or even via Twitter.


WSQ03

Week 2

--Originally published at chozaoop

This class is about researching what an Object, Attribute and Method are.

An Object has 2 main characteristics: State and Behavior; states can be explained as what status the object has, as an example, a car might be “On” and “Off”, these are obvious conditions for that object; and the Behavior might be “Running” or “Standby”, an Object can exist with or without a name, a name just references objects, it isn’t the object itself.

Behavior = Method    —-&—-  State =  Fields

An object might have objects inside, the value of the attribiutes may vary.

A class describes the object, which is an instance

The answer of a method might return a different result depending of which object does it.

“A method always begins with lower case.” -Ken, 2016.

—————————————————————————-

“Methods operate on an object’s internal state and serve as the primary mechanism for object-to-object communication. Hiding internal state and requiring all interaction to be performed through an object’s methods is known as data encapsulation — a fundamental principle of object-oriented programming.”

Taken from: http://docs.oracle.com/javase/tutorial/java/concepts/object.html

A method could be explained as a collection of statements that are grouped together to perform an operation.

—————————————————————————-

In general, an “attribute” is a property or characteristic.

In OOP,  an attribute is a public variable inside the class/object.

 


Week 2

WSQ01

--Originally published at chozaoop

Posting about installing Eclipse the IDE we’ll be using this course, hopefully.

First you must download the JDK which stands for Java Development Kit.

Here’s the link, i chose the “jdk-8u65-windows-x64.exe”, since i have a 64 bit Windows, you have to agree with the License first though.

Then you download Eclipse.

Here.

Again, i chose Eclipse IDE for Java Developers

Since that’s the one we’ll use, i guess…

Everything ran fine i suppose, classmate David seems to be having some trouble, KEN IS THE ANSWER.


WSQ01