#WSQ10-College Advice

--Originally published at diegotc2016

I think this WSQ has been the most enriching task. Just a few days before Ken posted the assignment I was thinking about asking some of my teachers about college advice because I’ve noticed that I’m not a very good programmer as I could be. So these tips have helped me to know the way on how to become a better programmer but it all depends on how I implement those tips.

The tips Joel Spolsky gave are:

  1. Learn how to write before graduating.
  2. Learn C before graduating.
  3. Learn microeconomics before graduating.
  4. Don’t blow off non-CS classes just because they’re boring.
  5. Take programming-intensive courses.
  6. Stop worrying about all the jobs going to India.
  7. No matter what you do, get a good summer internship

I think the most important tips first of all is learning C, as he said C is like the god of all programming languages so if after graduating I wanna have a good job I must lear C.

Another great tip is to don’t blow off non-CS classes just because they’re boring. This CS classes I think are the AEV, EVAP, Ethics and those kind of subjects, so I better make my best in this courses because they are the ones that make your final carrer grade better and most of the recruiters check on how your grade is in order to get a job.

Finally another tip that I find important is to take programming-intensive courses. A friend of mine that is studying these degree too told me that also. My friend told me that taking these kind of courses gives you the better job when you’re graduating.

#WSQ10-College Advice

I got this out of:

http://www.joelonsoftware.com/articles/CollegeAdvice.html

 


#WSQ10-College Advice

#WSQ09- The Movies (Still not finished)

--Originally published at diegotc2016

This WSQ was really hard I have to search for a lot of documentation, I look to this assignment in python and I searched for other classmates assignment.

Here is a picture of my entire code so that you can understand it better: ****file is WSQ 09***

#WSQ09- The Movies (Still not finished)#WSQ09- The Movies (Still not finished)#WSQ09- The Movies (Still not finished)#WSQ09- The Movies (Still not finished)#WSQ09- The Movies (Still not finished)

Here’s the picture from the other file: ****this file is named movies****

#WSQ09- The Movies (Still not finished)#WSQ09- The Movies (Still not finished)

Anyway here are the both files in github:

https://github.com/diegoalatorre/TC2016meromero/blob/master/WSQ09%2Cjava

https://github.com/diegoalatorre/TC2016meromero/blob/master/Movies.java

Note: This WSQ was “based” in one of my classmates WSQ

I got this out of:

https://docs.oracle.com/javase/tutorial/essential/io/

I wont go to the movies again – WSQ09

 


#WSQ09- The Movies (Still not finished)

CRC Cards

--Originally published at Orientierteprogrammierungobjekteundetwasmehr

 

What are CRC cards? Are they really useful or just a waste of time? Why should I care? Where where were you on the night of December 25th? We all have asked these questions to ourselves at least once in our lives. And I’ll just answer the first one.

CRC (stands for Class, Responsibility and Collaboration) cards (stands for Community Assistance for Reconstruction, Development, and Stabilisation) is an Object Oriented design pattern, useful.

These cards are supposed to help the software developer to think which objects he will need to have, what methods they will have and how will they interact among them, even before start writing code. It is supposed to be a good tool to learn the OOP paradigm because, regardless the syntax or implementation of an specific language, you can focus in what really matters, the whole concept of objects.

To write CRC cards you need to think about three things:

  1. Class (name):The class has to have a short and descriptive name of what it represents and what it does.
  2. Responsibility:
    The problems that the class is supposed to solve and its procedures, these should be short verb phrases containing an active verb. This is typically what this class does when it interacts with other classes.
  3. Collaboration:
    Objects should not be isolated from each other, they all must collaborate to accomplish a common goal, just like we learned from The Wonder Pets! Here you write with which other classes this one interacts with.

CRC cards have the following format and are written in 4×6 index cards:

CRC Cards

With CRC cards you can clearly see the relationship between classes, and the index cards have the advantage that you can move them around, organize and overlap them so you can put them in certain position that helps you to think about the relationship between these classes.

CRC Cards

And with this I answer to the fist question, you should be able to answer the second and third questions by yourself, maybe the fourth too.

Information and images extracted from http://c2.com/doc/oopsla89/paper.html

Permission to copy without fee all or pan of this material is granted provided that the copies are not made or distributed for direct commercial advantage, the ACM copyright notice and the title of the publication and its date appear and notice is given that copying is by permission of the Association for Computing Machinery. To copy otherwise, or to publish, requires a fee and/or specific permission.

CRC Cards

Overloading vs. Overriding

--Originally published at Orientierteprogrammierungobjekteundetwasmehr

Overloading vs. Overriding

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 polymosrphism) 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 when 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

Overloading vs. Overriding

Overloading with different data types and number of parameters.

Overloading vs. Overriding

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

Overloading vs. Overriding

Overloading allow different return types.

Overloading vs. Overriding

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

Overriding

Overloading vs. Overriding

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 right and Actual type on the left), 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 class (like explained in the previous stack overflow link).

Overloading vs. Overriding


Overloading vs. Overriding

Why do you think your change to object-oriented programming is difficult or what makes it difficult for the standard student?

--Originally published at diegotc2016

First of all I think changing to OOP was difficult because  I’ve learned this way of programming in a new language which is Java and this programming language has more difficult syntax than python has, most of beginners of programming use a simple language like python.

Why do you think your change to object-oriented programming is difficult or what makes it difficult for the standard student?

The next thing I think has made OOP difficult is the proccess in order to code. I was used to code and just code without any paper proccess before coding. For programming in an object oriented way first you have to design the clases and these goes without any coding process, you are even told that you have to do the design process in paper and not just in an electronic tool.

Why do you think your change to object-oriented programming is difficult or what makes it difficult for the standard student?

And the last thing that makes OOP a little bit difficult is the new concepts. This new concepts include class, method, encapsulation, inheritance, polymorphism. The new concepts may be difficult to understand if you have only worked with variables, lists, conditionals and just in a beginner way of programming.

Why do you think your change to object-oriented programming is difficult or what makes it difficult for the standard student?


Why do you think your change to object-oriented programming is difficult or what makes it difficult for the standard student?

What do you feel are the benefits to object-oriented programming?

--Originally published at diegotc2016

According to c4learn.com these are the advantages of OOP:

  • OOP provides a clear modular structure for programs.
  • It is good for defining abstract data types.
  • Implementation details are hidden from other modules and other modules has a clearly defined interface.
  • It is easy to maintain and modify existing code as new objects can be created with small differences to existing ones.
  • objects, methods, instance, message passing, inheritance are some important properties provided by these particular languages
  • encapsulation, polymorphism, abstraction are also counts in these fundamentals of programming language.
  • It implements real life scenario.
  • In OOP, programmer not only defines data types but also deals with operations applied for data structures.
  • 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

What do you feel are the benefits to object-oriented programming?

I got this out of:

Advantages And Features Of Object Oriented Programming

https://www.cs.drexel.edu/~introcs/Fa15/notes/06.1_OOP/Advantages.html?CurrentSlide=3


What do you feel are the benefits to object-oriented programming?

What do you feel are the benefits to object-oriented programming?

--Originally published at diegotc2016

According to c4learn.com these are the advantages of OOP:

  • OOP provides a clear modular structure for programs.
  • It is good for defining abstract data types.
  • Implementation details are hidden from other modules and other modules has a clearly defined interface.
  • It is easy to maintain and modify existing code as new objects can be created with small differences to existing ones.
  • objects, methods, instance, message passing, inheritance are some important properties provided by these particular languages
  • encapsulation, polymorphism, abstraction are also counts in these fundamentals of programming language.
  • It implements real life scenario.
  • In OOP, programmer not only defines data types but also deals with operations applied for data structures.
  • 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

What do you feel are the benefits to object-oriented programming?

I got this out of:

Advantages And Features Of Object Oriented Programming

https://www.cs.drexel.edu/~introcs/Fa15/notes/06.1_OOP/Advantages.html?CurrentSlide=3


What do you feel are the benefits to object-oriented programming?

What are overloading and overriding? How do we implement those in Java?

--Originally published at diegotc2016

 

Overloading: two methods are overloaded if  both methods have the same name but different argument types.

For example:

class DisplayOverloading
{
    public void disp(char c)
    {
         System.out.println(c);
    }
    public void disp(char c, int num)  
    {
         System.out.println(c + " "+num);
    }
}
class Sample
{
   public static void main(String args[])
   {
       DisplayOverloading obj = new DisplayOverloading();
       obj.disp('a');
       obj.disp('a',10);
   }
}

The output would be:

a
a 10

Overriding: is when someone declares a method in subclass which is already present in parent class.

For example:

class Human{
   public void eat()
   {
      System.out.println("Human is eating");
   }
}
class Boy extends Human{
   public void eat(){
      System.out.println("Boy is eating");
   }
   public static void main( String args[]) {
      Boy obj = new Boy();
      obj.eat();
   }
}

The output would be:

Boy is eating

What are overloading and overriding? How do we implement those in Java?

I got this information out of:

Method Overloading in Java with examples

Method overriding in java with example

http://javarevisited.blogspot.mx/2011/12/method-overloading-vs-method-overriding.html

What are overloading and overriding? How do we implement those in Java?


What are overloading and overriding? How do we implement those in Java?

What are overloading and overriding? How do we implement those in Java?

--Originally published at diegotc2016

 

Overloading: two methods are overloaded if  both methods have the same name but different argument types.

For example:

class DisplayOverloading
{
    public void disp(char c)
    {
         System.out.println(c);
    }
    public void disp(char c, int num)  
    {
         System.out.println(c + " "+num);
    }
}
class Sample
{
   public static void main(String args[])
   {
       DisplayOverloading obj = new DisplayOverloading();
       obj.disp('a');
       obj.disp('a',10);
   }
}

The output would be:

a
a 10

Overriding: is when someone declares a method in subclass which is already present in parent class.

For example:

class Human{
   public void eat()
   {
      System.out.println("Human is eating");
   }
}
class Boy extends Human{
   public void eat(){
      System.out.println("Boy is eating");
   }
   public static void main( String args[]) {
      Boy obj = new Boy();
      obj.eat();
   }
}

The output would be:

Boy is eating

What are overloading and overriding? How do we implement those in Java?

I got this information out of:

Method Overloading in Java with examples

Method overriding in java with example

http://javarevisited.blogspot.mx/2011/12/method-overloading-vs-method-overriding.html

What are overloading and overriding? How do we implement those in Java?


What are overloading and overriding? How do we implement those in Java?

Delegation

--Originally published at diegotc2016

Delegation is when a class “delegates” another class to do something.

Delegate is to give the power you have to do something to another person in order to do something.

In OOP delegation is when a class gives one or more functionalities to another class in order to do something.

Here’s an example:

Some parents want to go out. They hire a babysitter and tell her to look after the baby.
But what if the baby gets sick?
There’s a note on the fridge door. “In case of emergency phone Helen 555-3141”

This is a pretty good analogy for delegation. Helen is the
delegate.

//within the parent class
babysitter.delegate = helen
[babysitter lookAfter:baby]

//within the babysitter class
if (baby.isSick)
{
[delegate callAbout:baby]
}

When assigning actions to an object, you can provide that object with a delegate. The delegate will be called when the object needs to inform something or do something beyond the scope of the object.

Delegation

Where I got this information from?

http://es.thefreedictionary.com/delegar

https://www.quora.com/What-is-delegation-in-object-oriented-programming

https://es.wikipedia.org/wiki/Delegaci%C3%B3n_(inform%C3%A1tica)

 


Delegation