Posts filed under 'IT Hints & Tips'

Mis-redirection

Biasanya kalo kita buka halaman web ... terkadang ada tulisan "If your browser doesn't automatically redirect you to my blog within a few seconds, click here please.". Nah kalimat itu adalah kalimat umum untuk me-redirect halaman web ke URL tertentu. Tentunya untuk personal web seperti punya gw ... link itu dipergunakan biasanya untuk me-redirect current page ke URL sub-domain punya gw ... wich is blog.auliabig.com.

Cara untuk membuat redirection-page kayak gitu sebenernya mudah ... salah satunya dengan menggunakan HTML. Lihat contohnya di bawah :



HTML:
  1. <meta content="2; URL=http://blog.auliabig.com/" http-equiv="refresh" />
  2. <meta content="automatic redirection" name="keywords" />

dengan menambahkan sepotong meta HTML seperti itu di dalam tag HEAD anda dapat membuat halaman redirection dengan sangat mudah. Perhatikan properties content="2" ... itu artinya menandakan detik tunggu untuk melakukan redirection.

Tapi ada yang lucu juga sih .... ternyata pemakaian redirection page ini kadangkala "tidak tepat sasaran". Kenapa tidak tepat?? karena baru tadi pagi dengan tidak sengaja (kayaknya sengaja untuk mempromosikan blog gw ;) ) meredirect blognya ke halaman blog gw :D

Semoga bisa diambil hikmahnya .... untung salah redirect ke situs orang keren :p ... coba redirectnya ke situs porno hahahaha ^-^

PS : Benerin tuh linknya Pak :p

1 comment September 21st, 2006

Interface “Lelaki Buaya Darat”

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#:
  1. public interface ILelaki
  2. {
  3. void Makan();
  4. void Kerja();
  5. void Tidur();
  6. void Ngomong();
  7. }

Nah tadi kan disebutkan kalo interface itu tidak mempunyai implementasi, sekarang kita lihat bagaimana interface diatas diimplementasikan pada suatu class :



C#:
  1. public class LelakiPadaUmumnya : ILelaki
  2. {
  3. ///
  4. /// override method yang ada di interface
  5. ///
  6. public void Makan()
  7. {
  8. // Do something
  9. }
  10. ///
  11. /// override method yang ada di interface
  12. ///
  13. public void Kerja()
  14. {
  15. // Do something
  16. }
  17. ///
  18. /// override method yang ada di interface
  19. ///
  20. public void Tidur()
  21. {
  22. // Do something
  23. }
  24. ///
  25. /// override method yang ada di interface
  26. ///
  27. public void Ngomong()
  28. {
  29. // Say : MAU KU-ANTAR PULANG
  30. }
  31. /// METHOD BARU
  32. ///
  33. public void NyariIstri()
  34. {
  35. // Do something
  36. }
  37. }

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#:
  1. public class LelakiBuayaDarat : ILelaki
  2. {
  3. ///
  4. /// override method yang ada di interface
  5. ///
  6. public void Makan()
  7. {
  8. // Do something
  9. }
  10. ///
  11. /// override method yang ada di interface
  12. ///
  13. public void Kerja()
  14. {
  15. // Do something
  16. }
  17. ///
  18. /// override method yang ada di interface
  19. ///
  20. public void Tidur()
  21. {
  22. // Do something
  23. }
  24. ///
  25. /// override method yang ada di interface
  26. ///
  27. public void Ngomong()
  28. {
  29. // Say : CHECK-IN YUK
  30. }
  31. ///
  32. /// METHOD BARU (lelaki buaya darat, busyet!!! aku tertipu lagi ... ^-^)
  33. ///
  34. public void NyariCewek()
  35. {
  36. // Do something
  37. }
  38. }

Mulai ada gambaran ..??? ^-^
Mungkin sekarang anda bertanya-tanya bagaimana cara pengaplikasiannya? Coba kita lihat contoh dibawah ini :



C#:
  1. public class DuniaLelaki
  2. {
  3. private ILelaki lelaki;
  4.  
  5. public void UcapkanSesuatuSetelahKencanPertama(ILelaki interfaceLelaki)
  6. {
  7. lelaki = interfaceLelaki;
  8. lelaki.Ngomong();
  9. }
  10.  
  11. public DuniaLelaki()
  12. {
  13. LelakiPadaUmumnya lelakiPadaUmumnya = new LelakiPadaUmumnya();
  14. UcapkanSesuatuSetelahKencanPertama(lelakiPadaUmumnya);
  15.  
  16. LelakiBuayaDarat lelakiBuayaDarat = new LelakiBuayaDarat();
  17. UcapkanSesuatuSetelahKencanPertama(lelakiBuayaDarat);
  18. }
  19. }

Bagaimana? paham ^-^?
Mudah2 coding gw lebih memberi penjelasan daripada kata2 ;)

2 comments July 27th, 2006

C# Coding Standard

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 :

C# Coding Standard 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

2 comments July 14th, 2006