WSQ10 – College Advice

--Originally published at Alan TC201

I was very impressed of the fact that this blog post has aged very well. It was published in 2005 by Joel Spolsky, and a lot of things he said are still relevant in 2016. The points that interested me the most was about try to learn C, not C++, Java or python. C is the mother language so if you understand C is very probable it will be easier to learn about their sons. Like some people say, if you learn latin in will be a lot easier to learn its derivatives.WSQ10 – College AdviceWSQ10 – College Advice

The second one was the one that said to learn microeconomics. It is very common that you have your work and that everything you do will be about that specific job, that everything else will be fix or ready for you, but no, you need to be prepared to face different situations, one of them seems to be the economic one, maybe you are an awesome programmer but if you do not know how the world works it will be very difficult to get used to it.

WSQ10 – College Advice

The last thing is about de good summer internship, that is easy to say than done, in my country this types of things tend to cost a lot, and in the summer is the time when I save money to bought the books and things I need for the next semester of study. So when the opportunity comes I sure will try it out.

WSQ10 – College Advice


WSQ10 – College Advice

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

WSQ07 – Babylonian Method in JAVA

--Originally published at Alan TC201

This babylonian method was a little difficult, simply because compared to python, Java has a very weird syntax. I had to use a method of this person that I foun on the internet. (http://www.dreamincode.net/forums/topic/43600-babylonian-algorithm/)

Here is a link to understand Babylonian Method  (https://www.deltacollege.edu/dept/basicmath/Babylonian.htm)

Something new that I use in the s program was the scaner (http://puntocomnoesunlenguaje.blogspot.mx/2012/08/java-scanner.html)

WSQ07 – Babylonian Method in JAVA

BLOG POST NOT FINISH

WSQ07 – Babylonian Method in JAVA


WSQ07 – Babylonian Method in JAVA

Masterie: visibility modifiers in Java

--Originally published at Alan TC201

Masterie: visibility modifiers in Java

“Java provides a number of access modifiers to set access levels for classes, variables, methods and constructors. The four access levels are:

  • Visible to the package. the default. No modifiers are needed.
  • Visible to the class only (private).
  • Visible to the world (public).
  • Visible to the package and all subclasses (protected).

Default Access Modifier – No keyword:

Default access modifier means we do not explicitly declare an access modifier for a class, field, method, etc.

A variable or method declared without any access control modifier is available to any other class in the same package. The fields in an interface are implicitly public static final and the methods in an interface are by default public.”
Info( http://www.tutorialspoint.com/java/java_access_modifiers.htm)

Controlling Access to Members of a Class

Access level modifiers determine whether other classes can use a particular field or invoke a particular method. There are two levels of access control:

  • At the top level—public, or package-private (no explicit modifier).
  • At the member level—public, private, protected, or package-private (no explicit modifier).

A class may be declared with the modifier public, in which case that class is visible to all classes everywhere. If a class has no modifier (the default, also known as package-private), it is visible only within its own package (packages are named groups of related classes — you will learn about them in a later lesson.)

At the member level, you can also use the public modifier or no modifier (package-private) just as with top-level classes, and with the same meaning. For members, there are two additional access modifiers: private and protected. The private modifier specifies that the member can only be accessed in its own class. The protected modifier specifies that the member can only be accessed within its own package (as with package-private) and, in addition, by a subclass of its class in another package.

The following table shows the access to members permitted by each modifier.

Access Levels
Modifier 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

The first data column indicates whether the class itself has access to the member defined by the access level. As you can see, a class always has access to its own members. The second column indicates whether classes in the same package as the class (regardless of their parentage) have access to the member. The third column indicates whether subclasses of the class declared outside this package have access to the member. The fourth column indicates whether all classes have access to the member.

Access levels affect you in two ways. First, when you use classes that come from another source, such as the classes in the Java platform, access levels determine which members of those classes your own classes can use. Second, when you write a class, you need to decide what access level every member variable and every method in your class should have.

Let’s look at a collection of classes and see how access levels affect visibility. The following figure shows the four classes in this example and how they are related.

Masterie: visibility modifiers in Java

Classes and Packages of the Example Used to Illustrate Access Levels

The following table shows where the members of the Alpha class are visible for each of the access modifiers that can be applied to them.

Visibility
Modifier Alpha Beta Alphasub Gamma
public Y Y Y Y
protected Y Y Y N
no modifier Y Y N N
private Y N N N

Info (https://docs.oracle.com/javase/tutorial/java/concepts/)

 

BLOG POST NOT FINISH, THIS IS ONLY THE INFORMATION

Masterie: visibility modifiers in Java

 

 


Masterie: visibility modifiers in Java

Object-oriented concepts in practice in Java

--Originally published at Alan TC201

Here is a sum of all that I have published, the Journey for the Java programming its just starting, I am still learning every concept.

And to entretaing you, let’s see some hype.

  • Object-oriented concepts in practice in Java

 


Object-oriented concepts in practice in Java

Masteir: mechanics for class description

--Originally published at Alan TC201

Masteir: mechanics for class description

 

 

 

 

 

 

 

 

Java Program:  a set of instructions for the computer to follow.  The source code.

Data:  data for the Java program

Java Compiler:  translates the program from Java to a language that the computer can understand.  Compilers differ by make of machine and operating systems.

Byte Code Program:  the compiler translates Java into a language called byte-code.  Byte code is the machine language for a hypothetical computer called the Java Virtual Machine.

Byte Code Interpreter:  the interpreter translates each instruction of byte code into instructions that the computer in use can execute.

Machine Language:  is the language the computer in use understands.

Info (http://gee.cs.oswego.edu/dl/cpj/mechanics.html)

 

Masteir: mechanics for class description

 

 


Masteir: mechanics for class description

Masterie ”has-a” and “is-a” .

--Originally published at Alan TC201

One of cool thing you can do in Object-Oriented programming language is to reuse a code. There are two ways we can do code reuse, by implementation of inheritance or object composition. But you need to be careful how and what method you will use depending if it IS-A relationship or HAS-A relationship.

Masterie ”has-a” and “is-a” .

This image is very clear, but if you still can get the concept I will explain using the same example. You have a class with specifications about cars, like they uses some type of combustible, they move, and have doors, then you have a class name Maruti (a type of car) well that class is a relationship between the class car, everything inside the class car is valid for the class maruti.

Masterie ”has-a” and “is-a” .
On the other hand we have another class name engine, the maruti class HAS a relationship with the class engine because there are many types of engine but the maruti only cares about its engine, at the same time the engine has a relationship with the murati because that car needs an engine but the engine class does not care about the doors or of the car moves.

Masterie ”has-a” and “is-a” .

Down here are more specifications if you still are having trouble getting this.

IS-A relationship

  • This refers to inheritance or implementation.
  • Expressed using keyword “extends”.
  • Main advantage is code reusability.

In object oriented programming, the concept of IS-A is a totally based on Inheritance, which can be of two types Class Inheritance or Interface Inheritance. It is just like saying “A is a B type of thing”. For example, Apple is a Fruit, Car is a Vehicle etc. Inheritance is uni-directional. For example House is a Building. But Building is not a House.

It is key point to note that you can easily identify the IS-A relationship. Wherever you see an extends keyword or implements keyword in a class declaration, then this class is said to have IS-A relationship.

HAS-A relationship
Composition(HAS-A) simply mean use of instance variables that are references to other objects. For example: Maruti has Engine, or House has Bathroom.

  • Has-A means an instance of one class “has a” reference to an instance of another class or another instance of same class.
  • It is also known as “composition” or “aggregation”.
  • There is no specific keyword to implement HAS-A relationship but mostly we are depended upon “new” keyword.

More info (http://learnwithharsha.com/my-first-java-lesson-is-a-and-has-a-relationships/)

And a video that explains everything with details.


Masterie ”has-a” and “is-a” .

WSQ05- Coldcraft

--Originally published at Hell Yeah

As a final project for this class, we needed to make something object-oriented, not necessarily in Java, but preferably. What Arturo, Miguel and I chose to do was a mod for Minecraft, using Forge.

I had never used Minecraft on PC, but I have +200 hours in Skyrim, a game with a huge modding community, and I have always enjoyed using mods. They can add a whole new experience to the game. So, when I thought of good Skyrim mods to inspire myself for a Minecraft mod, I instantly thought of Frostfall, a great survival mod when you have to seek shelter from the northern province of Tamriel.

What I wanted to do was something similar, that you had to keep yourself warm on Minecraft, to make it more challenging. There is already one mod that does almost exactly what I want my mod to do, plus a few things that I don’t really want. The problem is that this mod has not been updated in a long time and it is a few versions behind from the current release of Minecraft.

We will try to make something similar to Frostfall, maybe a little bit more, if we can. You would have to protect yourself from cold and heat, trying to warm or refresh yourself often, using either fresh or warm clothing, and maybe with the help of a few consumables.

More info to come.


WSQ05- Coldcraft