تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
مواصفات قياسية تنصح بها مايكروسوفت عند كتابة الأكواد
#1
كاتب الموضوع : Athman


مواصفات قياسية تنصح بها مايكروسوفت عند كتابة الأكواد

السلام عليكم ورحمة الله وبركاته

يعد إتقان اللغة الرمجة (أيا كانت ) تمثل 75% من تعلم لغة البرمجة تليها مرحلة صناعة الواجهات

و لكن طبعا لكل منا طريقته عند كتابة الأكواد

و أنا هنا بإذن الله أعرض عليكم القواعد المتبعة أثناء كتابة الأكواد وذلك حسب تفضيلات مايكروسوفت (Microsoft Recommend to …)

سأقسم القواعد إلى موضوعين بإذن الله

نبدأ بالقواعد على بركة الله

ترا على فكرة مالي خبرة بالترجمة

1-Hungarian Notation must be used to create variable, constant, sub-routine, function, object, property names etc. Hungarian Notation is a Microsoft Windows standard naming convention whereby each word (excluding prefixes which are all lower case) begins with an upper case letter while the balance of the word is all lower case. Variable, constant, sub-routine, object, property names, etc. must be meaningful names prefixed with the prefix from the variable name and scope prefix tables shown on the next page. Type declaration characters may not be used in variable or constant names.



1-يستخدم لإنشاء المتغيرات ،الثوابت،الإجراءات،الدوال،الكائنات،أسماء الخصائص ...إلخ مايعرف بالتدوينة المجرية أو Hungarian Notation حيث أنها تمثل إتفاقية مايكروسوفت ويندوز للتسميات الأساسية والتي تقتضي بأن كل كلمة (ماعدا السابقة حيث أنها كلها بالأحرف الصغيرة أو Lower Case ) تبدأ بحرف كبير والباقي يكون صغيرا بحيث يجب أن تكون نفس الكلمة ذات معنى مفهوم للشيء المكتوب عنه مسبوقة بسابقة Prefix من نوع المتغير ومجاله

2-The ByRef or ByVal keyword MUST precede all parameters for functions, sub-routines and property procedures.

2-يجب أن يسبق ByVal أو ByRef كل البارمترات في الدوال ،الإجراءات،العمليات على الخصائص

3-Use of the END statement to end a program is forbidden. Closing the main form or reaching the end of Sub Main will do this in a controlled manner. Using END does not allow Visual Basic.NET to shutdown your program in an orderly manner. Problems will occur using END.

3-استخدام END لإنهاء البرنامج ممنوع. حيث أن إغلاق النافذء الرئيسية أو الوصول إلى نهاية الإجراء سيؤدي إلى إغلاق البرنامج بطريقة منظمة ولأن استخدام END لايسمح للفيجوال بيسك بأن يغلق البرنامج بطريقة منظمة حيث أنه من الممكن أن يؤدي إلى حدوث مشاكل

4-The use of literals is prohibited. If you are tempted to use a literal, replace it with a standard Visual Basic.NET constant if one is available or create your own constant (see page 3 for constant naming standards) if Visual Basic.NET does not provide one.

4- هذي لم أفهمها



5-The plus sign (+) is to be used as a mathematical addition operator only. Do not use it for concatenation.

Use the & for concatenation.

5- علامة الجمع (+) تستخدم فقط وفقط للعمليات الحسابية ولا تستخدم لدمج النصوص بل يستخدم (&) بدلا منها

6-The visible property of the data control must always be set to false.

6- مش فاهم ايش هي Data Control



7-Only one statement per line is allowed including Dim statements. Only one variable may be defined in a Dim statement. Use of the separator command ( is forbidden.

7-فقط تعليمة واحدة في كل سطر مسموحة أثناء تعريف المتغيرات أما استخدام ( لإضافة أكثر من تعريفة فهي ممنوعة



8-Dimensioning a variable as Object is forbidden unless required by Visual Basic.NET or the supplier of an external control.

8-تعريف متغير على انه كائن أي عدك تعريفه على انه رقم او نص ممنوع عدا في الحالات اللتي تطلب من الفيجوال بيسك(مش فاهم ايش قصده هنا) أو عند جلب البيانات من أداة خارجية



9-All forms of the IF statement and the CASE statement must be preceded and followed by one blank line. All forms of the IF statement must be indented one tab stop (4 characters) on the line after the THEN and ELSE clauses. ELSE clauses must be properly lined up with the corresponding IF statements. A blank line must precede and follow all iteration construct instructions



9-حالات الشرط بكل أنواعها يجب أن تسبق بـسطر خالي وأن تبدأ بعد أربعة أحرف الذي يتكون بالظغط على Tab في السطر الذي يكون بعد الشرط .الحالة Else يجب أن تكون موجودة في أي حالة شرط .سطر خالي يجب أن يسبق ويلحق كل تركيبة

10-Statements must not extend beyond the width of the editor window. Statements longer than the width of the editor window must be broken into one or more subsequent lines. This is accomplished by use of an underscore preceded and followed by a space at the end of the line.

يجب 10-أن لايتجاوز الكود حدودو الشاشة حيث إن الأكواد الطويلة يجب تقسيمها إلى عدة اسطر باستخدام (_) تليها مسافة في نهاية السطر المراد تكسيره إلى عدة أسطر



11-GOTO statements are forbidden in all cases.

11-إستخدام التعليمة GoTo ممنوعة



The Return statement must be used when you need to exit from sub-routine, function, event or property procedure prior to the last statement within the procedure. When used to exit a sub-routine the Return statement is used with no parameters--in other words, just use Return with nothing else on that line.

12-التعليمة Return يجب أن تستخدم عند الحاجة للخروج من إجراء معين ،دالة،حدث، أو عملية الخاصية للعودة للتعليمة الأخيرة في العملية يراعى أنه في حالة استخدامها مع إجراء يجب أن لا تلحق ببارامترات



Menu names must be hierarchical. For example, the SaveAs option on the File menu would be named mnuFileSaveAs.

13-أسماء القوائم يجب أن تتبع النظام الهرمي أو hierarchicalعلى سبيل المثال الخيار Save As الموجودة في قائمة File تسمى mnuFileSaveAs وهكذا



يتبع ...
}}}
تم الشكر بواسطة:
#2
في البداية اتاسف على تاخري في إكمال الموضوع نظرا لانشغالي ...

There must be one blank line between the header and the first line of code in all function, subroutine, event, property routines, etc. There must be a blank line between the last line of code and the End statement (i.e. End Sub for subroutines) for all function, subroutine, event, property routines etc. Code must be indented at least one tab stop from the left margin. See examples on page 6.

في الوضائف،الإحراءات الفرعية ،الأحداث،الخصائص :يجب ان يكون السطر الأول فارغا وايضا بين السطر الأخير من الكود وجملة النهاية (End Sub مثلا) ويجب ان يكون الكود بين هذه الاشياء مسبوقا بفارغ 4 أحرف وذلك بالضغط على زر Tab
مثال عليه :
كود :
[b][FONT=Tahoma][FONT=arial][b]
Sub Print[/b][/FONT][/FONT][/b][COLOR=#000000][FONT=arial][b]
MsgBox("Print")
[FONT=Tahoma][FONT=arial][b]End Sub[/b][/FONT][/FONT][FONT=Tahoma]
[/FONT]
[/b][/FONT][/COLOR]
Use the FOR … EACH instruction instead of the FOR … NEXT instruction when dealing with object arrays and collections.
عند التعامل مع الكائنات ،المصفوفات أو المجموعات يفضل استخدام التعليمة For….Each بدلا من For……Next

Use variables within expressions instead of properties wherever possible. Properties generate events, variables don’t. An example would be when setting the LEFT property of several controls to be equal to the LEFT property of control A, you would assign the LEFT property of control A to an integer variable. You would then use that integer variable within the loop to assign it to the controls in the array.

استخدم المتغيرات بدل من الخصائص متى كان ممكنا في التعبيرات (إياك أعني واسمعي يا جارة) الخصائص تنشئ أحداثا بينما المتغيرات لاتنشئ كمثال عليه عندما نغير الخاصية Left لعدد من العناصر حتى تكون متساوية لنفس الخاصية في عنصر آخر وليكون اسمه A يجب ان تخصص الخاصية Left للعنصر A إلى قيمة عددية ثم تستخدم المتغير الرقيمة في تعليمة التكرار حتى تخصصها للعناصر الأخر


NOTE: The contents of table shown below will be used as a reference while developing your programs.
You DO NOT have to memorize the contents of this table.

الجدول التالي تستخدم كمرجع لدى تصميم برنامج معين (تذكر لست ملزما بحفظ الجدول)


Constant Naming
Constants must be used to improve readability and maintainability of your program. Constants MUST be defined using all upper case for the body of the constant name with words divided by underscores. The use and scope prefixes must precede the body of the constant name. The use and scope prefixes remain lower case. ALL constant definitions must use the As clause in the definition. For example, the definition for a global integer constant to indicate the maximum number of times the program will try to resend data would be defined as follows:
Const m_intMAX_NUMBER_RETRYS As Integer = 5

تسمية الثوابت
الثوابت يجب ان يستخدم لكي تبين امكانية قراءة برنامجك وانها ذات معنى مع مراعاة بانها يجب ان تعرف باستخدم الاحرف الكبيرة UPPER CASE مع ملاحظة بانها إذا كانت عبارة عن كلمتين تكون مفصولة بشرطة سفلية ( _ ) نوع ومدى الثابت يجب ان يضمن في تسمية الثابت حيث انها تسبق اسم الثابت وبشرط ان تكون أحرف صغيرة lower case جميع التعريفات عن الثوابت يجب ان تستخدم العبارة AS في التعريف المستخدمة لتبين نوعه ناخذ مثالا عاما نفرض انا لدينا ثابتا رقميا Integer هدفه حفظ القيمة القصوة لعدد المرات التي سيقوم البرنامج بمحاولة إعادة إرسال البيانات سيكون على الشكل التالي
كود :
Const m_intMAX_NUMBER_RETRYS As Integer = 5


Scope of Variables and Constants
All variables and constants must be defined locally unless absolutely necessary. This is good programming practice regardless of the programming language being used for development.

مدى المتغيرات والثوابت
جميع المتغيرات والثوابت يجب ان تعرف ضمن المدى المحلي إلا في حالة الضرورة المطلقة هذا النصيحة تعتبر تمرين برمجي جيد بغض النظر عن نوع لغة البرمجة المستخدمة
Naming of Visual Basic.NET and Add-on Controls
All controls MUST be given meaningful names using Hungarian Notation (described on first page). The name you assign to the control must be prefixed using one of the prefixes from the table on the next page.

التسمية في Visual Basic.Net وتسمية الأدوات :

يجب أن تسمى كل الأدوات بأسماء ذات معنى مع ملاحظة استخدام الطريقة المجرية أو Hungarian Notation (تم شرحه في البداية) مع ملاحظة بان اسم المتغير أو الداة يجب ان تسبق بسابقة باستخدام احد السوابق الموجودة في الجدول التالي
(تذكر لست ملزما بحفظه)

في المرة القادمة سنذكر بعض الأمثلة
}}}
تم الشكر بواسطة:



التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم