Thursday, February 26, 2009

I Am Fading

Omaygolay!! I haven't been able to do some readings for some time now due to my constant busyness about our projects...and the sad fact is that we haven't been able to receive our salary for almost 2 freaking months now..waaaaaa!! good thing i have some savings..whew..still, it sucks..grrr x-(

Friday, August 8, 2008

Class Immutability: Never thought of them before

"Classes should be immutable unless there's a very good reason to
make them mutable....If a class cannot be made immutable, limit its mutability as much as possible."

- Josh Bloch

I never thought of class immutability and its importance until I read Josh Bloch's statement quoted on a site about Java practices. There must be something about it that Bloch would quote such a tough statement. And it's true! A programmer must defend his class's instance variables from being changed from outside itself (except for instantiating the class, in which case you'll use a constructor or a static factory), unless there is a very good reason for it. Yeah, that is coolness to the uttermost level. Another point learned. :]

Continually learning,
Jep

Tuesday, July 29, 2008

Encapsulation in OOP

Level: Basic

Two of the main features of the Object-Oriented Programming (OOP) paradigm is flexibility and maintainability. It is so desirable for one's source code to be flexible in spite of changes in its internal implementations. Programmers don't have to worry about their codes getting broken due to changes in the implementation of the Application Programming Interfaces (API) that they are using. All they have to know is that public methods of a given API behave the way they know it should regardless of its implementation details. Through this sense of flexibility in one's code, users of such API are guaranteed that their own code will behave accordingly for a very long time. This advantage is offered by OOP through encapsulation. Encapsulation hides the implementation details of an API to accomodate maintainability and flexibility in its use. It serves as a protection for a class's attributes by forcing client users of the class to access its protected attributes through publicly accessible methods or behaviors.
An example implementation of encapsulation in class would be the following (using the Java programming language):

public class Person {
private String name;
private String age;

public void setName(String name){
this.name = name;
}
public String getName(){
return this.name;
}

public void setAge(int age){
this.age = age;
}
public int getAge(){
return this.age;
}
}


Notice that class Person's attributes are declared as private to protect them from being accessed directly outside Person. Instead, they are accessed through what we call setters (setName,setAge) and getters (getName, getAge). Clients of this class will have to use setters to set the value of its attributes and getters to determine the value of its attributes. By doing so, we will not be able to see others codes accessing Person's name and age as follows:

public class Tester {
void testPerson(){
Person person = new Person();
person.name = "Juan dela Cruz";
person.age = 20;
}
}


Instead, Tester will class will use Person class as follows:

public class Tester {

void testPerson(){

Person person = new Person();

person.setName"Juan dela Cruz");

person.setAge(20);

}

}


Also, since Tester class accesses Person's age through Person's setAge setter, we could be sure that Person's age will not have 0 or any negative value by adding a checker into Person's setAge method like the following:

//preceeding code removed
public void setAge(int age) throws
IllegalAgeValueException{
if (age > 0) {
this.age = age;
} else {
throw new IllegalAgeValueException(); //in which
IllegalAgeValueException is a //custom exception
}
}


Encapsulation in OOP leverages an API's maintainability and flexibility if used properly. Of course it doesn't mean that since OOP offers encapsulation the programmer does not have to do anything in order to take advantage of such feature. In order to do so, one has to write his code in an encapsulated manner. :]

Continually learning,
Jep

Monday, July 28, 2008

Back to the Basics

It has been a few weeks now since I started reviewing my Java basics. There are so many trivial matters about programming that I seem not to pay attention to just because they are, as I said, trivial. One example would be optimization. Due to busyness and all the rush, I seldom check my code if it runs the optimized way. If it works, then it works. But an excellent programmer should not treat his code as so. A programmer's code is his essence. Show me your code and I'll tell you what kind of programmer you are. I am just so thankful to God that He made me see this weakness of mine at this early stage of my software development career. Optimization is just one of those programming weaknesses of mine. There are still lots of them and I am hoping to realize them as I go back to my Java basics and then see what action plans I could come up with to improve on those areas. :]

Friday, July 25, 2008

PicLens : Redifining FireFox Experience

While I was searching for a really cool add-on that I could plug into my FireFox browser, I came accross this one called PicLens. It gives the user a far better net-surfing experience by making image and video searches a lot more interactive and enjoyable. It has something what they call as "The Wall" which is a 3-D interface to one's search results. It feels like picking one's choice from a wall of images and videos. Videos could be watched on the wall by clicking on it, which means users don't have to go out of the wall and go to the video's main page just to watch it. This gives the user more convenience in searching for the media that they are interested with. I give it a 9 out of 10 points, the 1 point less is for the fact that it does not run linux machines..hehe :] For more information about this cool add-on, just visit the site http://www.piclens.com/ and enjoy a better and much cooler FireFox :]

Thursday, July 17, 2008

NASA Mars Lander's Robotic Arm shuts down to save its self

Yesterday I read an article from PC World about NASA Mars Lander's robotic arm shutting down its self to avoid getting hurt which would make its situation worse.
The Mars Lander found its self on a very crucial situation during execution of its mission. After receiving commands from NASA's command center, the robotic arm decided to shutdown its self instead of compromising and getting its wrist into a bad shape. Further details of the story can be found in this link: http://www.pcworld.idg.com.au/index.php/id;593684490 .
I just get so excited whenever I get to read news such as this. It has always been a dream of mine to be a robotics engineer. I get so amazed by how a robot could execute the commands given to it by its developer. So far I don't have yet a comprehensive plan on how I am going to pursue this dream of mine. Still, I believe there is always a time for everything under the sun. (Ecclesiastes 3:1) :]
If there is anyone out there who could help me on this, please do kindly lend me a hand by sharing your knowledge. I would greatly appreciate it :]

Continually learning,
Jep


The Joy of Helping Others

In spite of the heavy workload that I have been juggling this week, by God's grace, He enabled me to help other people in our office in some way or another. To help other people and see them get relieved somehow with the stress that they are carrying on their shoulders is a joy for me. To see someone smile in spite of being tired relieves me of my own tiredness. By God's enabling I would love to continually help other people with the hope that someday our world, starting from my office, would get to learn the true spirit of volunteerism, offering their selves for the benefit of the people around them.

2 Corinthians 9:8
And God is able to make all grace abound to you, so that in all things at all times, having all that you need, you will abound in every good work.


Continually learning,
Jep