July 2009


Web Service merupakan sebuah layanan yang diakses melalui protokol HTTP.  Penggunaan protokol HTTP ini memungkinkan layanan ini dapat diakses dari berbagi platform yang berbeda. Nah itu sedikit pengertian dari Web Service.

Untuk lebih jelasnya apa itu web service silakan kunjungi link berikut ini.

Apa saja tools yang dibutuhkan? Beberapa Tools yang dibutuhkan yaitu:

  1. IIS 5.0
  2. Visual Studio Web Developer Express Edition 2008.
  3. Microsoft .NET Framework 3.5 SP 1
  4. Framework Spring .NET

Langkah-langkah untuk membuatnya:

  • Buka Visual Studio Web Developer ES 2008.
  • Ciptakan sebuah project .NET Web Application beri namanya “Calculator.WebService”(File > New Project > Visual C# > Web > ASP.NET Web Application).
  • Hapus File Default.aspx.
  • Tambahkan empat buah folder pada project Calculator.WebService dengan nama, Config, Handler, Interface, Service.
  • Tambahkan sebuah Interface pada folder Interface dan beri nama ICalculator“.
  • Beri akses modifier public untuk interface ini.
  • Tambahkan dua method untuk menjumlah dan mengali.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace CalculatorServiceHost.Interface
{
public interface ICalculator
{
int Tambah(int angkaPertama, int angkaKedua);
int Kali(int angkaPertama, int angkaKedua);
}
}

  • Tambahkan sebuah class pada folder Handler dan beri nama “CalculatorHandler”.
  • Berikan akses modifier public untuk class ini.
  • Tambahkan dua buah method yaitu Tambah dan Kali yang kedua-duanya menerima dua buah parameter masukan.
  • Pada method Tambah dan Kali inilah Anda memproses hasil keluaran apa untuk Service Tambah dan Kali yang Anda ciptakan. Mengapa bukan langsung pada class Service-nya saja diimplementasikan. Anda dapat membaca pendekatan “Tell, Don’t Ask” untuk lebih mudah memahaminya.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web; namespace CalculatorServiceHost.Handler
{
public class CalculatorHandler
{
public CalculatorHandler() { }
public int Tambah(int angkaPertama, int angkaKedua)
{
return (angkaPertama + angkaKedua);
}
public int Kali(int angkaPertama, int angkaKedua)
{
return (angkaPertama * angkaKedua);
}
}
}

(more…)

TDD (Test Driven Development). What is it? According to Extreme Programming, TDD is an incremental software development approach that relies on automated regression tests to steer development activities .

By using TDD, the steps for developin software are Test – Coding – Design. This is the simple life cycle for develop a system using TDD.

Life Cycle - Test Driven DevelopmetLife Cycle – Test Driven Developmet

Let me explain the life cycle for you:

  1. Provide some test lists (test cases).
  2. Create a simple code for test lists that you have been provided and compile the code.
  3. You will get some errors because the code is not complete.
  4. Implement your code and compile again.
  5. By using some testing framework run all the tests.
  6. If fail, observe and revice your code and compile again.
  7. If still fail, repeat the point number four until you get pass.
  8. If pass, improve again your code wihout changing the fungtionality of your code.
  9. If all the tests have been passed and fix, you can go to next step to begin a new cycle.

If you just read the theory without an example, it just like a folktale. Right? Now I will give an example to use the TDD approach.

Assume that we want to make a service to add and multiply.  Let start from provide some test lists. So what are the test lists. Add and multiply, these are the test lists.
using NUnit.Framework;
public class MyServiceFixture
{
Assert.AreEqual(4, myService.Add(2, 2));
}

This is test case for add. You want to ensure that the result of 2 + 2 is 4. You can use method AreEqual to check the result. Compile your code. Some erros will occur, because the object myService is not identified. So make instatiate of an object myService.
using NUnit.Framework;
public class MyServiceFixture
{
IMyService myService = new MyService();
Assert.AreEqual(4, myService.Add(2, 2));
}

Compile again your code. Some errors have been reduced. Wow interface IMyService and class MyService are not found. Create the interface and class.
public interface IMyService
{
int Add();
}

public class MyService : IMyService
{
public MyService() {}
public int Add(_firstNumber, _secondNumber)
{
return _firstNumber + _secondNumber;
}
}

Now lets compile again your class MyServiceFixture. What is the result. No errors will be occured. You can try for the multiply test case.

Semalam tepatnya tanggal 7 Juli 2009, merupakan malam hari yang sangat menyenangkan. Tau kenapa ??? Kami semua anak 2006 yang lagi KP di Batam ini diajak jalan-jalan ama abang-abang almuni PI Del yang ada di Batam. Jalan-jalannya sih nggak ke pantai ato temapt rekreasi seperti yang rame-rame itu, cuma nonton bareng kok di Bioskop XXI Mega Mall Batam.

Yang hadir semua yang abang-abang alumni ama satu orang kakak alumni yaitu kak Henny. Hahaha … Enak ya … Sebelum nonton tuh kami ada sekitar 8 orang, makan-makan malam dulu ceritanya disana. Ya kalo untuk pukulan kami yang bayar mana sangguplah kami yang masih sekolah ini untuk membayarin itu semua. Untunglah biaya untuk nonton ama makan-makannya dibayarin ama orang abang. Tw kan kalo anak sekolahan itu gimana ??? Hahaha …. :D

Selesai makan. Orang yang ditunggu-tunggu buat nonton belom datang-datang juga (Bang Jackbar ama Opung Joni – Nang). Maklumlah kawan abang itu pulanya si Joni Opung yang dah tua jadi abang itu harus mengurusi dia. Oh ya si Joni sekarang di Batam ini dah macam kayak direktur dia. Bedalah ama yang di kampus kian … Hep KIAN … Tw nggak kalo orang Batam itu nggak kenal ama si KIAN. Mereka anggap kalo KIAN itu nama orang. Padahal kalo di tanah batak arti kian kan “dulu”. Hahaha ….

Nonton apa ya ??? Itulah diskusi kami ??? Ada du pilihan utama, Ice Age ato The Tarik Jabrix. Akhirnya pilihan jatuh ke tangannya sih ………………………. The Tarik Jabrix.

Akhirnya kami nonton filmnya dari jam 8 malam ampe 10 malam. Selesai nonton trus kami di antar ama orang abang kembali ke tempat peristirahatan di asrama kampus Politeknik Batam. ….