Skip to content

Commit 0d7593a

Browse files
authored
Update article.md
Done upto line 121
1 parent ef6b5bf commit 0d7593a

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

1-js/03-code-quality/03-comments/article.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ code;
2222

2323
এ ব্যাপারে একটি সুন্দর নিয়ম আছেঃ "কোডটি যদি এতটাই অস্পষ্ট হয় যে এর জন্য একটি মন্তব্য প্রয়োজন, তবে সম্ভবত মন্তব্যের পরিবর্তে এটি পুনরায় লেখা উচিত"
2424

25+
### কৌশল: ফাংশন পুনর্গঠন
2526

26-
27-
### Recipe: factor out functions
28-
29-
Sometimes it's beneficial to replace a code piece with a function, like here:
27+
অনেক ক্ষেত্রে কোডের অংশবিশেষ এর বদলে ফাংশন ব্যবহার করাটা সুবিধাজনক। যেমনঃ
3028

3129
```js
3230
function showPrimes(n) {
@@ -45,8 +43,7 @@ function showPrimes(n) {
4543
}
4644
```
4745

48-
The better variant, with a factored out function `isPrime`:
49-
46+
`isPrime` ফাংশন দিয়ে এর এর শ্রেয়তর বিকল্পঃ
5047

5148
```js
5249
function showPrimes(n) {
@@ -67,11 +64,11 @@ function isPrime(n) {
6764
}
6865
```
6966

70-
Now we can understand the code easily. The function itself becomes the comment. Such code is called *self-descriptive*.
67+
এখন আমরা খুব সহজেই কোডটি বুঝতে পারছি। ফাংশনটি নিজেই মন্তব্য হিসবে কাজ করছে। এ ধরনের কোড কে বলা হয় "স্ব-বর্ণনামূলক"
7168

72-
### Recipe: create functions
69+
### কৌশলঃ ফাংশন তৈরি
7370

74-
And if we have a long "code sheet" like this:
71+
এবং যদি আমাদের নিচের মত এরকম দীর্ঘ কোড শিট থাকেঃ
7572

7673
```js
7774
// here we add whiskey
@@ -92,7 +89,7 @@ for(let t = 0; t < 3; t++) {
9289
// ...
9390
```
9491

95-
Then it might be a better variant to refactor it into functions like:
92+
সেক্ষেত্রে শ্রেয়তর বিকল্পের জন্য কোডটি কে নিচের মত ফাংশনে পুনর্ঘঠন করা যেতে পারেঃ
9693

9794
```js
9895
addWhiskey(glass);
@@ -113,15 +110,15 @@ function addJuice(container) {
113110
}
114111
```
115112

116-
Once again, functions themselves tell what's going on. There's nothing to comment. And also the code structure is better when split. It's clear what every function does, what it takes and what it returns.
113+
ফাংশন নিজেরাই কি ঘটছে ব্যাখ্যা করে। এখানে মন্তব্য লেখার কিছু নেই। এছাড়াও আলাদা আলাদা থাকলে কোডের গঠন ভালো হয়। এটা সুপষ্ট যে প্রতিটি ফাংশন কি করে, কি গ্রহণ করে এবং কি রিটার্ন করে।
117114

118-
In reality, we can't totally avoid "explanatory" comments. There are complex algorithms. And there are smart "tweaks" for purposes of optimization. But generally we should try to keep the code simple and self-descriptive.
115+
বাস্তবে,আমরা সম্পুর্ণরূপে ব্যখ্যা সম্বলিত মন্তব্য পরিহার করতে পারি না। এখানে উৎকর্ষতা সাধনের জন্য অনেক জটিল অ্যালগরিদম এবং অনেক সুক্ষ্ম সমন্বয় করা হয়। কিন্ত সাধারণভাবে আমাদের উচিৎ কোড কে সহজ-সরল এবং স্ব-বর্ণ্নামূলক রাখার জন্য চেষ্টা করা ।
119116

120-
## Good comments
117+
## ভালো মন্তব্য
121118

122-
So, explanatory comments are usually bad. Which comments are good?
119+
সুতরাং, ব্যাখ্যামূলক মন্তব্য সাধারণত খারাপ। সেক্ষেত্রে কোন ধরণের মন্তব্য ভাল?
123120

124-
Describe the architecture
121+
গঠনপ্রণালী বর্ণনা করুন
125122
: Provide a high-level overview of components, how they interact, what's the control flow in various situations... In short -- the bird's eye view of the code. There's a special language [UML](http://wikipedia.org/wiki/Unified_Modeling_Language) to build high-level architecture diagrams explaining the code. Definitely worth studying.
126123

127124
Document function parameters and usage

0 commit comments

Comments
 (0)