WebHosting – Ramnode

Tags

,

I have ever hosted my website on GoDaddy, but I was not satisfied with the speed. Anyway, it was a shared hosting by the way. So what can I expect?

But recently one of my friends told me about this affordable VPS hosting called RamNodeI think the price is right so I decided to give it a try.

ramnode

Now I have been using it for about 1 week, install a shoutcast server and transcoder on it, and overall, i’m satisfied with the performance.

With less than 50 USD a year, I can get the following specs:

  • OpenVZ / CVZ-E5
  • Operating System CentOS 5 64-bit
  • Disk Space 120 GB
  • Bandwidth 1.95 TB
  • Memory 512 MB
  • VSwap 512 MB

Try to use this discount coupon: NOWAY42

If it is still valid, it will cut the cost by 42%

Aspect-Oriented Programming

Before talking about Aspect-Oriented Programming (AOP), let us think about the following situation:

I’d like to create a method that read from/write to database (a DAO class). And I end up doing the following:

  1. get the connection, create the prepared statement
  2. run the query, and process the result
  3. close the resultset and prepared statement

The problem is: everytime i create a method that read from/write to database, I end up doing all the above. If you notice, the first point and the last one are always repeated. If we could code the code such that it knows how to do the first point and the last one, life will be much easier.

Similarly for logging and transaction, most of the time they are repeated in every method and class. That replication is such a waste of effort.
We love to focus on 1 thing, 1 concern, which is the main functionality of our code. JDBC access, logging, and transaction are things we do to accomplish our secondary objective. They are repeated horizontally accross all class and methods, which makes these things called: cross-cutting concerns, or simply: Aspect. We definitely must deal with those Aspects, but can we do it once and for all instead of repeating it all over the place?

AOP

AOP is the answer. AOP is trying to separate these cross-cutting concerns (aspects) containing secondary objectives with our primary concern/objective of the code.

You may consider this similar to outsourcing. As a grocery supermarket company, the IT service, cleaning, and transportation service are the cross-cutting concerns of the company. Those services are used across ALL departments. It would be beneficial and cost-effective to the company if the company can focus on its core business competency i.e. selling groceries, and not being burdened by their IT, or cleaning, or transportation services. And thus, the company may decide to outsource those services/cross-cutting concerns/aspects.

Internally, in programming, Aspect-Oriented Programming works in such a way that: whenever it detects point(s) of interest (by matching a pattern), it will apply an operation to that part.
The points are called, Pointcuts. While the operation is called Advice.
Both Pointcuts and Advice together are called Aspect.

For JDBC above, we can use JDBCTemplate object of Spring so that we would not deal with the opening connection/preparedStatement/resultset and closing them.
For logging, we can define a pattern that matched all methods (pointcuts), and just after entering the methods, and exiting the methods we create Advice to print out some info into log.
For transaction, we can define a pattern that matched the create and update methods(pointcuts), so that just after entering method, transaction is started(Advice), and before exiting method successfully, we commit the transaction(another Advice), and when there is exception occured, we rollback (another Advice).

I hope it helps.

Dependency Injection

Dependency Injection means: “let the caller give an object its instance variables”.

Normally we have the following class:

public class TestDrive{
  private BMWCar myCar;
  public void takeASimpleRide(){
    myCar = new BMWCar();
    myCar.drive();
  }
}

See the above. You depends on BMW car object. You will have a hard time if you have a 2nd car which is Mercedes for example. You need to change the code using if-else if you want to drive another car.

Sometimes people use Factory class to instantiate the object as follows:

public class TestDrive{
  private BMWCar myCar;
  public void takeASimpleRide(){
    myCar = CarFactory.getBMWCar();
    myCar.drive();
  }
}

Still, the above class always set BMW for you. How if you want to drive other non-BMW cars?
This might have ever come to your mind: “Add an input parameter for method takeASimpleRide() so that it become takeASimpleRide(String carType) then use if-else in the method.”
But that one is ugly, you will constantly modify your code when new car coming in. This violates Open-Closed principle. Open for extension, but closed for modification.
The good answer for the problem above is: simply let the caller give you the car to drive. Let the caller give an object its instance variables. You simply drive whatever car the caller provides.
It is a good programming practice to use interface as a contract following Open-Closed principle. And secondly, we avoided tight coupling between TestDrive class and BMWCar class.

so do this:

public class TestDrive{
 private CarInterface myCar;
 public TestDrive(Car Interface myCar){
  this.myCar = myCar;
 }
 public void takeASimpleRide(){
  myCar.drive();
 }
}

or this:

public class TestDrive{
 private CarInterface myCar;
 public void setMyCar(CarInterface myCar){
  this.myCar = myCar;
}
 public void takeASimpleRide(){
  myCar.drive();
 }
}

DependencyInjection

Then the caller will need to pass the real car object when instantiating the TestDrive object. TestDrive simply drive the car passed to it. Problem solved.

I hope this benefits you.

Pragmatic Programming

Tags

Surfing website. I found 37signals dan Coding Horror recommend buku Pragmatic Programming. Lalu saya beli versi ebooknya disini http://pragprog.com/book/tpp/the-pragmatic-programmer.

ShowCover

Saya akan coba merangkum point2 penting yg saya dapatkan dari buku ini:

Karakter Pragmatic Programmer

  • Early Adopter: suka coba-coba sesuatu yg baru
  • Inquisitive: Suka bertanya. “wah, bagus designnya, bagaimana caranya?”
  • Critical Thinker: Ndak suka kalo cuma follow the pattern. Pengen tahu Why nya.
  • Realistic: understanding that process should be difficult and take some time.
  • Jack of all trades: mesti ngerti dan follow broad range of technologies and environments.
  • Care about his own craft: mesti ada passion sama hasil kerjaan sendiri.

Dengan begini, akan ada feeling of mastery and pleasure in continuous improvement.

Filosofi Pragmatic Programming

  • Provide options, don’t make lame excuses.
  • Don’t live with broken windows: kalo ada code/system yg broken ya diperbaiki jgn dibiarin, supaya team member yg lain tidak apatis terhadap code/system yg ada.
  • Be catalyst for change: start the ball rolling to get to solutions.
  • Remember the big picture: produce good enough software. Jgn sampai ada scope creeping sampai-sampai deviate dari requirement awal.
  • Invest Regularly in your knowledge portfolio: belajar bahasa pemograman baru tiap tahun, baca technical book tiap 3 bln sekali, baca non-technical book jg terutama masalah komunikasi.
  • Communicate with WISDOM: analyse audience mood, what is their interest, how much detail they want, and how to motivate them.

Semoga berguna! 🙂

Aib dan Nasihat

aku tidak sempurna, kamu pun tidak sempurna.
aku punya kekurangan, kamu pun punya kekurangan.
aku tidak akan mencari2 aibmu, krn aibku sendiri sudah terlalu banyak

so_embarassedjika aku melihat aibmu, tidak akan aku sebarkan ke manusia, selama aibmu itu tidak akan memudharatkan/menzhalimi saudara kita yg lain,
jika aku mampu, insyaAllah akan aku tolong dirimu dengan menasihatimu tanpa orang lain mengetahuinya

bagaimana mungkin aku menyebarkan aibmu, sedangkan aibku sendiri bisa jadi jauh lebih banyak dan lebih buruk keadaannya

dan bagaimana mungkin aku menyebarkan aibmu, padahal aku ingin Allah menutupi aibku di hari kiamat kelak dan dan menghisabku dengan perhitungan yg mudah

dan bagaimana mungkin aku menyebarkan aibmu, padahal aku TIDAK ingin diriku BANGKRUT di pengadilan akhirat. Cukuplah diriku menanggung beban dosaku sendiri, tidak menanggung beban dosamu, dan aku ingin pahalaku tetap pada tempatnya, tidak berpindah pada dirimu

bagaimana denganmu, sahabatku?
IKHLASKAH NIATMU?
inginkah engkau kebaikan buatku sebagaimana engkau ingin kebaikan bagi dirimu?
BENARKAH CARAMU?
apakah itu cara yg diajarkan oleh Rasulullah shallallahu’alahi wasallam, para shahabatnya, dan para ulama salaf kita?
sudahkah engkau menDOAkan ku sewaktu menasihatiku yg malaikat akan mengaminkan dan mendoakan yg serupa untuk mu?

akankah kita saling menasihati dalam ketaatan dan kesabaran?
ataukah menurutmu cara menasihati ini tidak lagi relevan dan engkau abaikan dengan dalih pergaulan zaman sekarang?

Sahabat Baik itu Bagaikan Cermin

sahabat yg baik itu bagaikan cermin… cermin itu memberi tahu kita dengan benar, rambut kita sudah rapih kah, pakaian kita sudah rapih kah, dan lain lain, lalu membuat kita memperbaikinya.. lalu cermin itu tidak memberitahukannya kepada manusia lainnya..

sahabat yg baik itu memberitahu kesalahan2/kejelekan2 kita, di depan kita, supaya kita menjadi lebih baik, dan tidak menyebarkan hal ini ke manusia. Bukan sebaliknya.

nah apakah diriku ini sahabat yg baik? apakah kamu sahabat yg baik pula? sudahkah engkau mengoreksi saudaramu seagama ikhlas krn Allah dan tidak menyebarluaskan kejelekan2nya ke manusia lainnya (baca: tidak ghibah)… Ataukah yg kamu lakukan itu sebaliknya?

Seorang mukmin itu mungkin tidak akan goyah akidahnya, bisa menjaga pandangan dan kemaluannya, tapi banyak yg tidak selamat dari lidahnya. Jgn lah jadi org yg bangkrut di akhirat gara2 lisan….

Sahabatku, nasihatilah aku. Dan jangan kau ghibahi diriku..
Ghibah itu nikmat, dan memberi nasihat itu memang berat..
Tapi kebalikannya lah yg engkau dapatkan di akhirat..

Playing Lubuntu Linux

Tags

,

I had quite a long weekend, so I thought of trying playing Linux again on my old laptop. I finally decided to wipe out the existing OS i.e. Ubuntu 10 and Win XP. And simply overwrote it with linux. My goal was to find a distro that is

  • fast;
  • quite complete (in terms of apps);
  • customizable;
  • stable (not frequently throwing out error/hangs).

I’d like to learn Linux as much as I can, but without sacrificing the time for my office work and my family. So, for a newbie like me, a complete linux with:

  • most drivers supported (including my mobile broadband modem); and
  • basic apps installed with options to install extra apps later; and
  • simple customization by editing files

is a perfect distro. Continue reading

Produktivitas

Tags

Kita cuma punya waktu 24 jam per hari.

Dari 24 jam itu kita perlu membagi menjadi waktu untuk: ritual ibadah(sholat), tidur, mencari nafkah, istri/anak/pekerjaan rumah, belajar dunia, belajar akhirat, olahraga, hiburan. Kalo dipikir2 lagi, alangkah sedikitnya waktu. Apalagi kalo kerja di kantor sampai lembur, krn keluarga juga membutuhkan kita di rumah. Alhasil kita harus mengganti waktu mereka yg hilang ketika itu, kalo ngga, nanti bisa ada yg ngambek. Akhirnya waktu kita buat belajar dunia/akhirat yang dikorbankan..

Saya punya solusi, meskipun masih teori.

Pertama bermimpi, setelah itu diaksi. Continue reading

Mencari Rumah Terbaik

Tags

, , ,

Siapa yang ndak mau dapat rumah yang indah, besar, luas, modern? Bukan cuma itu, rumahnya penuh dengan pelayan2 yang muda, yang melayani sepenuh hati. Dengan istri2 cantik belia yang setia, yang didalam hatinya cuma ada diri anda seorang. Anda tinggal disana bagaikan seorang raja. Tidak ada kotoran yang anda keluarkan. Dan anda tinggal di sana selamanya, abadi. Tidak ada lagi namanya kesusahan.

Too good to be true. Iya, kalau itu diharapkan terjadi di dunia. Bahkan, tidak mungkin terjadi.

Tapi semua itu bisa kita dapatkan di akhirat kelak. Itulah janji Allah. Nah, untuk mendapatkan rumah di surga, bisa kita usahakan dengan melakukan amalan shalih sebagai berikut ini: Continue reading

Design a site like this with WordPress.com
Get started