Skip to content

Commit 225e982

Browse files
authored
Merge pull request #137 from shathee/master
Comments
2 parents f71c4b9 + c35e451 commit 225e982

File tree

1 file changed

+45
-49
lines changed

1 file changed

+45
-49
lines changed

Diff for: 1-js/03-code-quality/03-comments/article.md

+45-49
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# Comments
1+
# কমেন্ট
22

3-
As we know from the chapter <info:structure>, comments can be single-line: starting with `//` and multiline: `/* ... */`.
3+
ইতপূর্বে আমরা কোডের গঠন চ্যাপ্টারে দেখেছি যে কমেন্ট এক লাইনের (সিংগেল লাইন) যা `//` দিয়ে শুরু এবং একাধিক লাইনের (মাল্টি লাইন) যা `/* ... */` শুরু হতে পারে.
44

5-
We normally use them to describe how and why the code works.
5+
সাধারণত আমরা কোডটি কিভাবে এবং কেনো কাজ করছে তার বর্ণনা দেবার জন্য কমেন্ট ব্যাবহার করে থাকি।
66

7-
At first sight, commenting might be obvious, but novices in programming often use them wrongly.
7+
প্রাথমিকভাবে কমেন্ট সুস্পষ্ট মনে হতে পারে, তবে প্রোগ্রামিং এ নবাগতরা প্রায়শই কমেন্ট ভুলভাবে ব্যবহার করে থাকে।
88

9-
## Bad comments
9+
## ত্রুটিপূর্ণ কমেন্ট
1010

11-
Novices tend to use comments to explain "what is going on in the code". Like this:
11+
নবাগতদের মাঝে কমেন্ট ব্যবহার করে "এই কোডে কি ঘটছে" তা ব্যাখ্যা করার প্রবণতা দেখা যায়। এরকমঃ
1212

1313
```js
1414
// This code will do this thing (...) and that thing (...)
@@ -18,13 +18,13 @@ complex;
1818
code;
1919
```
2020

21-
But in good code, the amount of such "explanatory" comments should be minimal. Seriously, the code should be easy to understand without them.
21+
কিন্ত ভালো কোডে এরকম "ব্যাখ্যামূলক" কমেন্টে এর উপস্থিতি হওয়া উচিৎ ন্যূনতম। কমেন্ট ছাড়াই কোড সহজবোধ্য হওয়াটা গুরুত্বপূর্ণ।
2222

23-
There's a great rule about that: "if the code is so unclear that it requires a comment, then maybe it should be rewritten instead".
23+
এ ব্যাপারে একটি সুন্দর নিয়ম আছেঃ "কোডটি যদি এতটাই অস্পষ্ট হয় যে এর জন্য একটি কমেন্ট প্রয়োজন, তবে সম্ভবত কমেন্ট এর পরিবর্তে এটি পুনরায় লেখা উচিত"
2424

25-
### Recipe: factor out functions
25+
### কৌশল: ফাংশন পুনর্গঠন
2626

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

2929
```js
3030
function showPrimes(n) {
@@ -43,8 +43,7 @@ function showPrimes(n) {
4343
}
4444
```
4545

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

4948
```js
5049
function showPrimes(n) {
@@ -65,11 +64,11 @@ function isPrime(n) {
6564
}
6665
```
6766

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

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

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

7473
```js
7574
// here we add whiskey
@@ -90,7 +89,7 @@ for(let t = 0; t < 3; t++) {
9089
// ...
9190
```
9291

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

9594
```js
9695
addWhiskey(glass);
@@ -111,21 +110,20 @@ function addJuice(container) {
111110
}
112111
```
113112

114-
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+
ফাংশন নিজেরাই কি ঘটছে ব্যাখ্যা করে। এখানে কমেন্ট লেখার কিছু নেই। এছাড়াও আলাদা আলাদা থাকলে কোডের গঠন ভালো হয়। এটা সুপষ্ট যে প্রতিটি ফাংশন কি করে, কি গ্রহণ করে এবং কি রিটার্ন করে।
114+
115+
বাস্তবে,আমরা সম্পুর্ণরূপে ব্যখ্যা সম্বলিত কমেন্ট পরিহার করতে পারি না। এখানে উৎকর্ষতা সাধনের জন্য অনেক জটিল অ্যালগরিদম এবং অনেক সুক্ষ্ম সমন্বয় করা হয়। কিন্ত সাধারণভাবে আমাদের উচিৎ কোড কে সহজ-সরল এবং স্ব-বর্ণ্নামূলক রাখার জন্য চেষ্টা করা ।
115116

116-
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.
117+
## ভালো কমেন্ট
117118

118-
## Good comments
119+
সুতরাং, ব্যাখ্যামূলক কমেন্ট সাধারণত খারাপ। সেক্ষেত্রে কোন ধরণের কমেন্ট ভালো?
119120

120-
So, explanatory comments are usually bad. Which comments are good?
121+
গঠনপ্রণালী বর্ণনা করুনঃ কম্পোনেন্ট এর সার্বিক একটি রূপরেখা উল্লেখ করুন, এদের পারষ্পরিক মিথষ্ক্রিয়া এবং ভিন্ন ভিন্ন কন্ট্রোল ফ্লো সম্পর্কে বলুন। সংক্ষেপে, কোড এর বার্ডস আই ভিউ। কোড সহজবোধ্য উপস্থাপন করার জন্য সার্বিক রূপরেখা তৈরির বিশেষ ধরনের ল্যাংগুয়েজ [UML](http://wikipedia.org/wiki/Unified_Modeling_Language) রয়েছে।
121122

122-
Describe the architecture
123-
: 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.
123+
ফাংশন এর প্যারামিটার এবং ব্যাবহার লিপিবদ্ধ করুনঃ ফাংশন এর প্যারামিটার, ব্যাবহার, রিটার্ন ভ্যালু লিপিবদ্ধ করার জন্য বিশেষ ধরনের ল্যাংগুয়েজ [JSDoc](http://en.wikipedia.org/wiki/JSDoc) রয়েছে।
124124

125-
Document function parameters and usage
126-
: There's a special syntax [JSDoc](http://en.wikipedia.org/wiki/JSDoc) to document a function: usage, parameters, returned value.
125+
উদাহরণস্বরূপঃ
127126

128-
For instance:
129127
```js
130128
/**
131129
* Returns x raised to the n-th power.
@@ -139,42 +137,40 @@ function pow(x, n) {
139137
}
140138
```
141139

142-
Such comments allow us to understand the purpose of the function and use it the right way without looking in its code.
140+
এই ধরনের কমেন্ট এর মাধ্যমে আমরা কোড না দেখেই ফাংশনটির কাজ এবং ব্যবহার বুঝতে পারি।
143141

144-
By the way, many editors like [WebStorm](https://www.jetbrains.com/webstorm/) can understand them as well and use them to provide autocomplete and some automatic code-checking.
142+
প্রসঙ্গত উল্লেখ্য, অনেক এডিটর যেমন [WebStorm](https://www.jetbrains.com/webstorm/) এই ধরনের ল্যাংগুয়েজ বুঝতে পারে এবং অটোকমপ্লিট ও স্বয়ংক্রিয় কোড-পরীক্ষায় তা ব্যবহার করে থাকে।
145143

146-
Also, there are tools like [JSDoc 3](https://github.com/jsdoc3/jsdoc) that can generate HTML-documentation from the comments. You can read more information about JSDoc at <http://usejsdoc.org/>.
144+
এছাড়াও, কমেন্ট থেকে এইচটিএমএল-ডকুমেন্টেশন তৈরির জন্য [JSDoc 3](https://github.com/jsdoc3/jsdoc) এর মত টুল রয়েছে। JSDoc সম্পর্কে আরো জানতে <http://usejsdoc.org/> দেখতে পারেন।
147145

148-
Why is the task solved this way?
149-
: What's written is important. But what's *not* written may be even more important to understand what's going on. Why is the task solved exactly this way? The code gives no answer.
146+
কাজটি কেনো এভাবে সমাধান করা হয়েছে? : যা লিখিত থাকে তা গুরুত্বপূর্ণ। তবে যা *অলিখিত* সেটা কি ঘটছে তা বোঝার জন্য অধিক গুরুত্বপূর্ণ হতে পারে। এই কাজটি কেনো ঠিক এইভাবেই সমাধান করা হয়েছে? এক্ষেত্রে কোড কোন উত্তর দেয় না।
150147

151-
If there are many ways to solve the task, why this one? Especially when it's not the most obvious one.
148+
যদি কাজটি সমাধানের অনেকগুলো উপায় থাকে, সেক্ষেত্রে কেনো এইটি? বিশেষভাবে যখন এটি আপাতদৃষ্টিতে সবচেয়ে সুস্পষ্ট সমাধান নয়
152149

153-
Without such comments the following situation is possible:
154-
1. You (or your colleague) open the code written some time ago, and see that it's "suboptimal".
155-
2. You think: "How stupid I was then, and how much smarter I'm now", and rewrite using the "more obvious and correct" variant.
156-
3. ...The urge to rewrite was good. But in the process you see that the "more obvious" solution is actually lacking. You even dimly remember why, because you already tried it long ago. You revert to the correct variant, but the time was wasted.
150+
এইধরনের কমেন্ট ছাড়া নিম্নলিখিত পরস্থিতি হতে পারেঃ
151+
১। আপনি অথবা আপনার সহকর্মীরা কিছুক্ষণ পূর্বে লিখিত কোডটি দেখলেন এবং ভাবলেন কোডটি সাব-অপটিমাল
152+
২। আপনি ভাবলেনঃ " আমি কতটা বোকাটা ছিলাম,আর এখন কতটা বুদ্ধিমান ", এবং "আরো সুস্পষ্ট এবং সঠিক" বিকল্প ব্যবহার করে পুনরায় কোডটি লিখলেন
153+
৩। ... কোড পুনরায় লেখার তাগিদ থাকা ভালো। কিন্তু কাজকরার প্রক্রিয়াআপনি দেখলেন "অধিক সুস্পষ্ট" সমাধানটি তে আসলে ঘাটতি রয়েছে। এমনকি আপনি খুব অস্পষ্টভাবে মনে করতে পারবেন কেনো এমন হচ্ছে, কারণ আপনি অনেক সময় আগে এই চেষ্টা করেছেন। আপনি আবার সঠিক বিকল্পে ফিরে আসবেন কিন্তু এর মাঝে কিছু সময় অপচয় হলো।
157154

158-
Comments that explain the solution are very important. They help to continue development the right way.
155+
সমাধান কে ব্যখ্যাকারী কমেন্ট খুব গুরুত্বপূর্ণ। এই ধরনের কমেন্ট সঠিক প্রক্রিয়ায় ডেভেলপমেন্ট করতে সাহাজ্য করে।
159156

160-
Any subtle features of the code? Where they are used?
161-
: If the code has anything subtle and counter-intuitive, it's definitely worth commenting.
157+
কোড এ কোন সূক্ষ্ম বৈশিষ্ট রয়েছে? কেনো এই ধরনের বৈশিষ্ট ব্যবহার করা হয়েছে?: যদি কোড এ কোন সূক্ষ্ম অথবা সহজাত নয় এরকম কিছু থাকে তা অবশ্যই মন্তব্যে অন্তর্ভূক্ত করা উচিত।
162158

163-
## Summary
159+
## সারসংক্ষেপ
164160

165-
An important sign of a good developer is comments: their presence and even their absence.
161+
কমেন্ট এর উপস্থিতি/অনুপস্থিতি একজন ভালো ডেভেলপার এর বৈশিষ্ট।
166162

167-
Good comments allow us to maintain the code well, come back to it after a delay and use it more effectively.
163+
ভালো কমেন্ট আমাদের সঠিকভাবে কোড রক্ষণাবেক্ষণ এবং কিছু সময় এর ব্যবধানে কোডটিকে কার্যকরভাবে ব্যবহার করতে সাহাজ্য করে।
168164

169-
**Comment this:**
165+
**কমেন্ট করুনঃ**
170166

171-
- Overall architecture, high-level view.
172-
- Function usage.
173-
- Important solutions, especially when not immediately obvious.
167+
- সামগ্রিক গঠনকৌশল, বাহ্যিক কাঠামো।
168+
- ফাংশনের ব্যবহার।
169+
- গুরুত্বপূর্ণ সমাধান, বিশেষভাবে যখন তা সুস্পষ্টভাবে প্রতীয়মান নয়।
174170

175-
**Avoid comments:**
171+
**কমেন্ট পরিত্যাগ করুনঃ**
176172

177-
- That tell "how code works" and "what it does".
178-
- Put them in only if it's impossible to make the code so simple and self-descriptive that it doesn't require them.
173+
- যে কমেন্ট "কোড কিভাবে কাজ করে" এবং "কি কাজ করে" সেটা উপস্থাপন করে।
174+
- সহজ এবং স্ব-ব্যখ্যায়িত কোড, যা তে কমেন্ট প্রয়োজন হয় না, তা যদি অসম্ভব হয় কেবলমাত্র সেক্ষেত্রে কমেন্ট করুন।
179175

180-
Comments are also used for auto-documenting tools like JSDoc3: they read them and generate HTML-docs (or docs in another format).
176+
অধিকন্ত JSDoc3 এর মত স্বয়ংক্রিয়-লিপিবদ্ধ করার টুল () কাজে কমেন্ট ব্যবহার করা হয়ে থাকে। এরা কমেন্ট থেকে এইচটিএমএল ডকুমেন্ট তৈরি করে (অথবা অন্য কোন ফরম্যাট এর ডকুমেন্ট)

0 commit comments

Comments
 (0)