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
এগুলো এক্সেপশন। বেশিরভাগ সময় ফাংশন নাম অর্থপূর্ন ও বিস্তারিত হওয়া উচিৎ।
403
403
```
404
404
405
-
## Functions == Comments
405
+
## ফাংশন == কমেন্টস
406
406
407
-
Functions should be short and do exactly one thing. If that thing is big, maybe it's worth it to split the function into a few smaller functions. Sometimes following this rule may not be that easy, but it's definitely a good thing.
407
+
ফাংশন ছোট হওয়া উচিৎ ও একটা নির্দিষ্ট কাজ করা উচিৎ। যদি কোনো ফাংশন বড় কাজ করে থাকে, তাহলে তাকে ছোট ছোট অংশে ভাগ করে ফেলা জরুরি। মাঝে মাঝে এই ব্যাপারটা বিরক্তিকর লাগতে পারে, কিন্তু অবশ্যই ভবিষ্যতের জন্য অত্যন্ত ভালো অভ্যাস।
408
408
409
-
A separate function is not only easier to test and debug -- its very existence is a great comment!
409
+
ছোট ছোট ফাংশন যে টেস্ট ও ডিবাগ করতে সুবিধাজনক তা-ই শুধু না, বরং -- এটা প্রোগ্রামকে অর্থপূর্ন কমেন্টের কাজে সাহায্য করে থাকে!
410
410
411
-
For instance, compare the two functions `showPrimes(n)`below. Each one outputs [prime numbers](https://en.wikipedia.org/wiki/Prime_number) up to`n`.
411
+
উদাহরণস্বরূপ, দুইটা ফাংশন `showPrimes(n)`এর পার্থক্য নিচে দেখানো হলো। প্রতিটা-ই [মৌলিক সংখ্যা](https://en.wikipedia.org/wiki/Prime_number) রিটার্ন করে`n` অব্ধি।
412
412
413
-
The first variant uses a label:
413
+
প্রথমটা একবারে কাজ করেঃ
414
414
415
415
```js
416
416
functionshowPrimes(n) {
@@ -424,7 +424,7 @@ function showPrimes(n) {
424
424
}
425
425
```
426
426
427
-
The second variant uses an additional function `isPrime(n)`to test for primality:
427
+
পরেরটা নতুন ফাংশন `isPrime(n)`কল করে মৌলিক সংখ্যা চেক করার জন্যঃ
428
428
429
429
```js
430
430
functionshowPrimes(n) {
@@ -444,9 +444,9 @@ function isPrime(n) {
444
444
}
445
445
```
446
446
447
-
The second variant is easier to understand, isn't it? Instead of the code piece we see a name of the action (`isPrime`). Sometimes people refer to such code as _self-describing_.
447
+
দ্বিতীয়টা বুঝতে সুবিধাজনক, তাই না? ভিতরের ফাংশন (`isPrime`) দেখে এর কাজ বুঝে যাওয়া যায়। মাঝে মাঝে প্রোগ্রামাররা এইধরনের কোডকে _স্ব-বর্ণনাকারী (সেলফ-ডেস্ক্রাইবিং)_ বলে থাকে।
448
448
449
-
So, functions can be created even if we don't intend to reuse them. They structure the code and make it readable.
449
+
এর মানে ফাংশন তৈরি করা যেতে পারে যদি আমরা পরে ব্যাবহার না করতে চাই তবুও। সেটা কোডকে সাজাতে ও বুঝতে সাহায্য করে।
0 commit comments