February 9, 2010 at 5:25 pm
· Filed under Software Development
George Westinghouse bir teorisyen değildi fakat 1800′lerin en büyük mucitlerindendi. En büyük icadı raylı sistemlerde kullanılan havalı frendir.
Bu yazıda Westinghouse’ın fikirleri ve bilgisayar bilimlerine yapmış olabileceği katkılar üzerinde duracağız.
Tren Frenleri
Atlar tarafından çekilen Wagonways isimli ilk tren 1550′lerde Almanlar tarafından kullanıldı. 1804 yılında Richard Trevithick buharlı tren ile 9 mil boyunca 10 ton demir ve 70 adam taşıdı. Bu kısa yolculuk modern trenlerin başlangıcıydı.
Read the rest of this entry »
Permalink
February 6, 2010 at 8:30 pm
· Filed under Java
Encapsulation
Do not expose class variables, instead of doing this, use setter and getter methods and keep class variables private.
public class Car {
private int price;
private int maxSpeed;
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public int getMaxSpeed() {
return maxSpeed;
}
public void setMaxSpeed(int maxSpeed) {
this.maxSpeed = maxSpeed;
}
}
What is the advantage of previous usage, first of all flexibility. For example you have changed your mind, decide to keep max speed read only. So we can just remove setMaxSpeed method or change it to private for internal use.
Another advantage is validation, if user want to set negative value for car price, so you can add a validation in setPrice that is it.
Is-A and Has-A Relationship
So, Ferrari is a Car, Cow is an animal lets codify these statements.
Read the rest of this entry »
Permalink