اليوم شاهدت شخص يقول حاول الاجتناب عن كتابة التعليقات في كودك، في نظرة اولية يظهر راي غير جيد، لكن أرى الحق معه!
في الحقيقة، لا معني للتعليقات، لا تؤثر في الكود النهائي و الـCompiler يتجاهل التعليقات.
لماذا أملئ الشاشة و أتعب أصابعي لكتابتها خاصة لو كانت لوحة المفاتيح من منتجات Acer - لا قدر الله.
لكتابة الـComments سبب واحد، وهو شرح هدف الكود، يمكن القيام بهذا بدون تعليق وبشكل واضح، كيف؟
مثلا هذا الكود:
// ensure we don't send a notification to
// important people
if (account.IsVip && account.IsPastDue)
{
SendNotification = false;
}يمكن كتابته بشكل آخر، واضح، جميل وبدون تعليق:
CancelNotificationForVipAccounts();
طبعا لا أقصد التعليقات التي نستخدم للـDocumentation أو Intellisense في Visual Studio مثلا.
-----------------
اثناء القراءة حول هذا الموضوع رايت مواضيع جميلة، هذا مثلا :D :
public class Program
{
static void Main(string[] args)
{
/* This is a for loop that prints the
* words "I Rule!" to the console screen
* 1 million times, each on its own line. It
* accomplishes this by starting at 0 and
* incrementing by 1. If the value of the
* counter equals 1 million the for loop
* stops executing.*/
for (int i = 0; i < 1000000; i++)
{
Console.WriteLine("I Rule!");
}
}
}

