Posts filed under 'C#'
Coba anda lihat coding di bawah ini :
C#:
-
#region Summary
-
// CREATE DATE :
-
// PURPOSE :
-
// VERSION :
-
#endregion Summary
-
#region History
-
// LEGENDS :
-
// + --> Create
-
// - --> Delete
-
// * --> Modify
-
// ---------------------------------------------------------------------
-
// DATE | VERSION | STATUS | NAME | DESC
-
// ---------------------------------------------------------------------
-
#endregion History
-
#region Imports
-
using System;
-
#endregion Imports
-
-
namespace projects
-
{
-
...
-
}
Dulu ... pencatatan history dalam pembuatan program hampir tidak pernah gw lakukan. Tapi sekarang gw mulai melakukannya ... caranya ya seperti anda lihat pada coding di atas, ada 2 region penting yang kudu gw implementasikan pada tiap file coding ( .cs[1] ) yang gw buat, yaitu : Sumary dan History.
Yang perlu anda cermati adalah region History. Region ini sangat membantu gw maupun rekan se-team gw yang membacanya (just incase gwnya gak bisa masuk kerja
). Setiap kali ada perubahan pada coding file tersebut, gw harus menambahkan detail historynya pada region tersebut. Fungsinya ya tentunya gak lain gak bukan untuk mentrack progress apa saja yang pernah gw lakukan.
Proses ini memang sangat membantu gw dalam mendevelop file coding, kadang coding lama (misal : method/property) gw masukin juga di History Region Comment
. Soalnya lebih gampang ngetrack kalo coding kita yang baru ternyata tidak sesuai dengan yang kita harapkan dan perubahannya itu sendiri kita dapat mengerti alurnya darimana kemana (maklum ... kalo coding udah ditinggal 2 hari aja ... pasti lupa maksudnya apa), nah dengan melihat kembali ke history yang gw catet ... walhasil 80% gw bisa inget kembali maksud tuh coding gw apa
.
Kendalanya ... seringkali gw lupa ataupun males dalam pengimplementasiannya ... yang ada abis ngoding dan melakukan perubahan ... trus teken tombol save ... compile ... shutdown deh 
Anda sendiri bagaimana?
Linknotes
- .cs - Microsoft Visual C# extension class filename ↩
November 27th, 2006
Hari ini gw mo sharing tentang Interface, mudah2an berguna ^-^. Interface kurang lebih adalah suatu reference type yang berisikan hanya abstract members seperti Method, Event, Properties dan Indexer yang tidak mempunyai implementasi (kurang lebih seperti itu ^-^)
Coba kita lihat bentuk dan pemakaian interface berikut ini :
C#:
-
public interface ILelaki
-
{
-
void Makan();
-
void Kerja();
-
void Tidur();
-
void Ngomong();
-
}
Nah tadi kan disebutkan kalo interface itu tidak mempunyai implementasi, sekarang kita lihat bagaimana interface diatas diimplementasikan pada suatu class :
C#:
-
public class LelakiPadaUmumnya : ILelaki
-
{
-
///
-
/// override method yang ada di interface
-
///
-
public void Makan()
-
{
-
// Do something
-
}
-
///
-
/// override method yang ada di interface
-
///
-
public void Kerja()
-
{
-
// Do something
-
}
-
///
-
/// override method yang ada di interface
-
///
-
public void Tidur()
-
{
-
// Do something
-
}
-
///
-
/// override method yang ada di interface
-
///
-
public void Ngomong()
-
{
-
// Say : MAU KU-ANTAR PULANG
-
}
-
/// METHOD BARU
-
///
-
public void NyariIstri()
-
{
-
// Do something
-
}
-
}
Mulai ada bayangan? ... coba anda perhatikan, method2 yang sudah dideklarasikan pada interface ILelaki dioverride kembali pada class LelakiPadaUmumnya, tapi .... tentunya dengan implementasi didalamnya.
Sebagai catatan : "Class yang mengimplementasikan suatu interface harus mengimplementasikan semua anggota dari interface tersebut"
Sekarang coba kita lihat class dibawah ini :
C#:
-
public class LelakiBuayaDarat : ILelaki
-
{
-
///
-
/// override method yang ada di interface
-
///
-
public void Makan()
-
{
-
// Do something
-
}
-
///
-
/// override method yang ada di interface
-
///
-
public void Kerja()
-
{
-
// Do something
-
}
-
///
-
/// override method yang ada di interface
-
///
-
public void Tidur()
-
{
-
// Do something
-
}
-
///
-
/// override method yang ada di interface
-
///
-
public void Ngomong()
-
{
-
// Say : CHECK-IN YUK
-
}
-
///
-
/// METHOD BARU (lelaki buaya darat, busyet!!! aku tertipu lagi ... ^-^)
-
///
-
public void NyariCewek()
-
{
-
// Do something
-
}
-
}
Mulai ada gambaran ..??? ^-^
Mungkin sekarang anda bertanya-tanya bagaimana cara pengaplikasiannya? Coba kita lihat contoh dibawah ini :
C#:
-
public class DuniaLelaki
-
{
-
private ILelaki lelaki;
-
-
public void UcapkanSesuatuSetelahKencanPertama(ILelaki interfaceLelaki)
-
{
-
lelaki = interfaceLelaki;
-
lelaki.Ngomong();
-
}
-
-
public DuniaLelaki()
-
{
-
LelakiPadaUmumnya lelakiPadaUmumnya =
new LelakiPadaUmumnya
();
-
UcapkanSesuatuSetelahKencanPertama(lelakiPadaUmumnya);
-
-
LelakiBuayaDarat lelakiBuayaDarat =
new LelakiBuayaDarat
();
-
UcapkanSesuatuSetelahKencanPertama(lelakiBuayaDarat);
-
}
-
}
Bagaimana? paham ^-^?
Mudah2 coding gw lebih memberi penjelasan daripada kata2 
July 27th, 2006
Just recently ago ... me and my colleaques had a little training with Agus Kurniawan (AK), one of Microsoft MVP, about Object Oriented Programming (OOP) in DotNET. It's mostly about fundamental concept how to program and work in Object Oriented kinda way.
One of AKs topic was "Coding Standard in C#". He said : "... every team has to have a standard, in this case coding standard ..." -- something like that ^-^.
I thought I had a good programming standard ... I thought we had a good programming standard!!!. Then again ... we're not
. I admit it ... since I know how to write a code, actually, I know there's a standard, but ... even if I do, my coding standard kinda fuzzy hahaha
. I stick with one standard ... and all of a sudden BANG!!! one step backward to neanderthal programming
.
Not very consistent of me he10x. But comes to think of it ... we really do need a good standard, why??? ... to make one same perspective that's why!!.
Let's imagine this ... you have a crush on some nice girl who really adores a romantic kinda guy (which is me
, you couldn't possibly say that you love her with "Response.Write("I LOVE YOU")" would you?
.
Okay ... back to coding standard. In C# coding standard there are lots of terminologies and definitions, two of them are Camel Case and Pascal Case.
Camel Case
A word with the first letter lowercase, and the first letter of each subsequent word-part capitalized.
Example : customerName
Pascal Case
A word with the first letter capitalized, and the first letter of each subsequent word-part capitalized.
Example : CustomerName
These two terminolgy are generaly used in C# programming, Microsoft too implements these two. Take a look at this example :

Thanks to AK, He really brightening things up. Hey AK have you received our new company Coding Standard Policy yet?!? 
If you wanna know more about C# coding standard ... click here
July 14th, 2006