You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+53-58Lines changed: 53 additions & 58 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,10 +20,10 @@
20
20
21
21
اصول مهندسی نرم افزار، از کتاب [*کد تمیز*](https://www.digikala.com/product/dkp-4964829/%DA%A9%D8%AA%D8%A7%D8%A8-clean-code-a-handbook-of-agile-software-craftsmanship-%D8%A7%D8%AB%D8%B1-robert-c-martin-%D8%A7%D9%86%D8%AA%D8%B4%D8%A7%D8%B1%D8%A7%D8%AA-pearson/) نوشته ی Robert C. Martin، برای پایتون. این یک راهنمای تولید نیست، این یک راهنما برای تولید نرم افزار های خوانا، قابل استفاده مجدد و قابل از نو بازسازی است.
22
22
نیازی بر سرسختگیری بر هر اصل گفته شده در اینجا نیست، و فقط تعداد کمی از آنها به صورت عمومی مورد تایید هستند. این ها چیزی جز اصول نیستند، اما اصول کدنویسی شده ای توسط سالها تجربه از نویسنده های *کد تمیز* هستند.
23
-
## **Variables**
24
-
### Use meaningful and pronounceable variable names
23
+
## **متغیر ها**
24
+
### از اسم های متغیر با معنا و قابل تلفظ استفاده کنید
### Use the same vocabulary for the same type of variable
45
+
**[⬆ برگشت به بالا](#table-of-contents)**
48
46
49
-
**Bad:**
47
+
### از واژگان یکسان برای همان نوع متغیر استفاده کنید
48
+
**بد:**
50
49
Here we use three different names for the same underlying entity:
51
50
52
51
```python
@@ -55,18 +54,18 @@ def get_client_data(): pass
55
54
defget_customer_record(): pass
56
55
```
57
56
58
-
**Good**:
59
-
If the entity is the same, you should be consistent in referring to it in your functions:
57
+
**خوب**:
58
+
اگر موجودیت یکسان است، باید در ارجاع به آن در توابع خود ثابت قدم باشید:
60
59
61
60
```python
62
61
defget_user_info(): pass
63
62
defget_user_data(): pass
64
63
defget_user_record(): pass
65
64
```
66
65
67
-
**Even better**
68
-
Python is (also) an object oriented programming language. If it makes sense, package the functions together with the concrete implementation
69
-
of the entity in your code, as instance attributes, property methods, or methods:
66
+
**حتی بهتر**
67
+
68
+
پایتون (همچنین) یک زبان برنامه نویسی شی گرا است. اگر منطقی است، توابع را همراه با پیادهسازی مشخص موجودیت در کد خود، بهعنوان ویژگیهای نمونه، متدهای ویژگی یا متدها بستهبندی کنید
70
69
71
70
```python
72
71
from typing import Union, Dict
@@ -87,15 +86,12 @@ class User:
87
86
return Record()
88
87
```
89
88
90
-
**[⬆ back to top](#table-of-contents)**
89
+
**[⬆ برگشت به بالا](#table-of-contents)**
91
90
92
-
### Use searchable names
93
-
We will read more code than we will ever write. It's important that the code we do write is
94
-
readable and searchable. By *not* naming variables that end up being meaningful for
95
-
understanding our program, we hurt our readers.
96
-
Make your names searchable.
91
+
### از اسامی قابل جست و جو استفاده کنید
92
+
ما بیشتر کد میخوانیم تا بنویسیم. این خیلی مهم است که کدی که مینویسیم خوانا و قابل جستجو باشد. با نام گذاری *نکردن* متغیر هایی که برای برنامه قابل فهم باشد، به خواننده هایمان آسیب میرسانیم. اسامی متغیرهایتان را قابل جست و جو کنید.
97
93
98
-
**Bad:**
94
+
**بد:**
99
95
100
96
```python
101
97
import time
@@ -105,7 +101,7 @@ import time
105
101
time.sleep(86400)
106
102
```
107
103
108
-
**Good**:
104
+
**خوب**:
109
105
110
106
```python
111
107
import time
@@ -115,10 +111,10 @@ import time
115
111
SECONDS_IN_A_DAY=60*60*24
116
112
time.sleep(SECONDS_IN_A_DAY)
117
113
```
118
-
**[⬆ back to top](#table-of-contents)**
114
+
**[⬆ برگشت به بالا](#table-of-contents)**
119
115
120
-
### Use explanatory variables
121
-
**Bad:**
116
+
### از متغیر های توضیحی استفاده کنید
117
+
**بد:**
122
118
123
119
```python
124
120
import re
@@ -132,10 +128,9 @@ if matches:
132
128
print(f"{matches[1]}: {matches[2]}")
133
129
```
134
130
135
-
**Not bad**:
136
-
137
-
It's better, but we are still heavily dependent on regex.
131
+
**بد نیست**:
138
132
133
+
بهتر است، اما هنوز به شدت به رجکس وابسته ایم.
139
134
```python
140
135
import re
141
136
@@ -149,9 +144,10 @@ if matches:
149
144
print(f"{city}: {zip_code}")
150
145
```
151
146
152
-
**Good**:
147
+
**خوب**:
148
+
153
149
154
-
Decrease dependence on regex by naming subpatterns.
150
+
وابستگی به رجکس را با نام گذاری الگوهای فرعی کمتر کنید.
0 commit comments