Skip to content

Commit b90bfda

Browse files
authored
Merge pull request #77 from Deep1Shikha/patch-1
Comments
2 parents be30484 + 62f65ab commit b90bfda

File tree

1 file changed

+61
-61
lines changed

1 file changed

+61
-61
lines changed
Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
# Comments
1+
# टिप्पणियाँ
22

3-
As we know from the chapter <info:structure>, comments can be single-line: starting with `//` and multiline: `/* ... */`.
3+
जैसा कि हम अध्याय <info:structure> से जानते हैं, टिप्पणियाँ सिंगल-लाइन हो सकती हैं: `//` से शुरू, और मल्टीलाइन : `/* ... */` से शुरू।
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
14-
// This code will do this thing (...) and that thing (...)
15-
// ...and who knows what else...
16-
very;
17-
complex;
18-
code;
14+
// यह कोड यह काम करेगा (...) और वह काम (...)
15+
// ... और कौन जानता है ...
16+
बहुत;
17+
जटिल;
18+
कोड;
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+
### विधि: function को फ़ैक्टर आउट करें
2626

27-
Sometimes it's beneficial to replace a code piece with a function, like here:
27+
कभी-कभी किसी function के साथ कोड पीस को बदलना फायदेमंद होता है, जैसे यहाँ:
2828

2929
```js
3030
function showPrimes(n) {
3131
nextPrime:
3232
for (let i = 2; i < n; i++) {
3333

3434
*!*
35-
// check if i is a prime number
35+
// जांचें कि क्या i एक प्रमुख संख्या है
3636
for (let j = 2; j < i; j++) {
3737
if (i % j == 0) continue nextPrime;
3838
}
@@ -43,7 +43,7 @@ function showPrimes(n) {
4343
}
4444
```
4545

46-
The better variant, with a factored out function `isPrime`:
46+
फ़ैक्टर आउट function `isPrime` के साथ बेहतर संस्करण:
4747

4848

4949
```js
@@ -65,21 +65,21 @@ function isPrime(n) {
6565
}
6666
```
6767

68-
Now we can understand the code easily. The function itself becomes the comment. Such code is called *self-descriptive*.
68+
अब हम कोड को आसानी से समझ सकते हैं। function ही टिप्पणी बन जाता है। ऐसे कोड को *स्व-वर्णनात्मक* कहा जाता है।
6969

70-
### Recipe: create functions
70+
### विधि: functions बनाएँ
7171

72-
And if we have a long "code sheet" like this:
72+
और अगर हमारे पास इस तरह एक लंबी "कोड शीट" है:
7373

7474
```js
75-
// here we add whiskey
75+
// यहाँ हम whiskey जोड़ते हैं
7676
for(let i = 0; i < 10; i++) {
7777
let drop = getWhiskey();
7878
smell(drop);
7979
add(drop, glass);
8080
}
8181

82-
// here we add juice
82+
// यहाँ हम juice जोड़ते हैं
8383
for(let t = 0; t < 3; t++) {
8484
let tomato = getTomato();
8585
examine(tomato);
@@ -90,7 +90,7 @@ for(let t = 0; t < 3; t++) {
9090
// ...
9191
```
9292

93-
Then it might be a better variant to refactor it into functions like:
93+
फिर इसे functions में रिफैक्टर करने के लिए यह एक बेहतर संस्करण हो सकता है जैसे:
9494

9595
```js
9696
addWhiskey(glass);
@@ -111,70 +111,70 @@ function addJuice(container) {
111111
}
112112
```
113113

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.
114+
एक बार फिर, functions स्वयं बताते हैं कि क्या हो रहा है। टिप्पणी करने के लिए कुछ भी नहीं है। और विभाजित होने पर कोड संरचना भी बेहतर होती है। यह स्पष्ट है कि प्रत्येक function क्या करता है, यह क्या लेता है और यह क्या लौटाता है।
115115

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.
116+
वास्तव में, हम "व्याख्यात्मक" टिप्पणियों से पूरी तरह से बच नहीं सकते हैं। जटिल एल्गोरिदम होते हैं और अनुकूलन के प्रयोजनों के लिए चतुर "बदलाव" हैं। लेकिन आम तौर पर हमें कोड को सरल और स्व-वर्णनात्मक रखने का प्रयास करना चाहिए।
117117

118-
## Good comments
118+
## अच्छी टिप्पणियाँ
119119

120-
So, explanatory comments are usually bad. Which comments are good?
120+
इसलिए, व्याख्यात्मक टिप्पणियां आमतौर पर खराब होती हैं। कौन सी टिप्पणियाँ अच्छी हैं?
121121

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.
122+
संरचना का वर्णन करें
123+
: घटकों का एक उच्च-स्तरीय अवलोकन प्रदान करें, वे कैसे बातचीत करते हैं, विभिन्न स्थितियों में नियंत्रण प्रवाह क्या है... संक्षेप में - कोड के बारे में विहंगम दृष्टि। कोड की व्याख्या करने वाले उच्च-स्तरीय आर्किटेक्चर आरेख बनाने के लिए एक विशेष भाषा [UML](http://wikipedia.org/wiki/Unified_Modeling_Language) है। निश्चित रूप से ये अध्ययन करने लायक।
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+
दस्तावेज़ function पैरामीटर और उपयोग
126+
: किसी function का दस्तावेज़ीकरण करने के लिए एक विशेष सिंटैक्स [JSDoc](http://en.wikipedia.org/wiki/JSDoc) है: उपयोग, पैरामीटर, लौटाया गया मान।
127127

128-
For instance:
128+
उदाहरण के लिए:
129129
```js
130130
/**
131-
* Returns x raised to the n-th power.
131+
* Returns x को बढ़ाकर n-वें घात पर लौटाता है।
132132
*
133-
* @param {number} x The number to raise.
134-
* @param {number} n The power, must be a natural number.
135-
* @return {number} x raised to the n-th power.
133+
* @param {number} x संख्या बढ़ाने के लिए।
134+
* @param {number} n घात, एक प्राकृत संख्या होनी चाहिए।
135+
* @return {number} x को n-वें घात तक बढ़ा दिया गया है।
136136
*/
137137
function pow(x, n) {
138138
...
139139
}
140140
```
141141

142-
Such comments allow us to understand the purpose of the function and use it the right way without looking in its code.
142+
इस तरह की टिप्पणियाँ हमें function के उद्देश्य को समझने और इसके कोड को देखे बिना इसका सही तरीके से उपयोग करने की अनुमति देती हैं।
143143

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.
144+
वैसे, [WebStorm](https://www.jetbrains.com/webstorm/) जैसे कई संपादक उन्हें भी समझ सकते हैं और स्वत: पूर्ण और कुछ स्वचालित कोड-जांच प्रदान करने के लिए उनका उपयोग कर सकते हैं।
145145

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/>.
146+
साथ ही, [JSDoc 3](https://github.com/jsdoc3/jsdoc) जैसे टूल हैं जो टिप्पणियों से HTML-दस्तावेज़ीकरण उत्पन्न कर सकते हैं। आप JSDoc के बारे में अधिक जानकारी <http://usejsdoc.org/> पर पढ़ सकते हैं।
147147

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.
148+
इस तरह से कार्य क्यों हल किया जाता है?
149+
: क्या लिखा है महत्वपूर्ण है। लेकिन जो *नहीं* लिखा है, वह और भी महत्वपूर्ण हो सकता है समझने के लिए कि क्या हो रहा है। कार्य को ठीक इस तरह क्यों हल किया जाता है? कोड कोई जवाब नहीं देता है।
150150

151-
If there are many ways to solve the task, why this one? Especially when it's not the most obvious one.
151+
यदि कार्य को हल करने के कई तरीके हैं, तो यह क्यों? खासकर जब यह सबसे प्रत्यक्ष नहीं है।
152+
153+
ऐसी टिप्पणियों के बिना निम्नलिखित स्थिति संभव है:
154+
1. आप (या आपके सहयोगी) कुछ समय पहले लिखे गए कोड को खोलते हैं, और देखते हैं कि यह "उप-इष्टतम" है।
155+
2. आप सोचते हैं: "मैं तब कितना मूर्ख था, और अब मैं कितना होशियार हूं", और "अधिक स्पष्ट और सही" संस्करण का उपयोग करके फिर से लिखें।
156+
3. ...फिर से लिखने की ललक अच्छी थी। लेकिन इस प्रक्रिया में आप देखते हैं कि वास्तव में "अधिक स्पष्ट" समाधान की कमी है। आपको यह भी याद नहीं है कि क्यों, क्योंकि आप इसे बहुत पहले ही आजमा चुके हैं। आप सही संस्करण पर वापस जाते हैं, लेकिन समय बर्बाद होता है।
152157

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.
158+
समाधान की व्याख्या करने वाली टिप्पणियाँ बहुत महत्वपूर्ण हैं। वे विकास को सही तरीके से जारी रखने में मदद करते हैं।
157159

158-
Comments that explain the solution are very important. They help to continue development the right way.
160+
कोड की कोई सूक्ष्म विशेषताएं? उनका उपयोग कहाँ किया जाता है?
161+
: यदि कोड में कुछ भी सूक्ष्म और प्रति-सहज ज्ञान युक्त है, तो यह निश्चित रूप से टिप्पणी करने योग्य है।
159162

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.
163+
## सारांश
162164

163-
## Summary
165+
एक अच्छे डेवलपर का एक महत्वपूर्ण संकेत टिप्पणियाँ हैं: उनकी उपस्थिति और यहाँ तक कि उनकी अनुपस्थिति भी।
164166

165-
An important sign of a good developer is comments: their presence and even their absence.
167+
अच्छी टिप्पणियाँ हमें कोड को अच्छी तरह से बनाए रखने, देरी के बाद उस पर वापस आने और इसे अधिक प्रभावी ढंग से उपयोग करने की अनुमति देती हैं।
166168

167-
Good comments allow us to maintain the code well, come back to it after a delay and use it more effectively.
169+
**यह टिप्पणी करें:**
168170

169-
**Comment this:**
171+
- समग्र संरचना, उच्च स्तरीय दृश्य।
172+
- function का उपयोग।
173+
- महत्वपूर्ण समाधान, खासकर जब तुरंत स्पष्ट न हों।
170174

171-
- Overall architecture, high-level view.
172-
- Function usage.
173-
- Important solutions, especially when not immediately obvious.
175+
**टिप्पणियों से बचें:**
174176

175-
**Avoid comments:**
177+
- यह बताएं कि "कोड कैसे काम करता है" और "यह क्या करता है"।
178+
- उन्हें तभी डालें जब कोड को इतना सरल और स्व-वर्णनात्मक बनाना असंभव हो कि इसके लिए उनकी आवश्यकता न हो।
176179

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.
179-
180-
Comments are also used for auto-documenting tools like JSDoc3: they read them and generate HTML-docs (or docs in another format).
180+
टिप्पणियों का उपयोग JSDoc3 जैसे ऑटो-डॉक्यूमेंटिंग टूल के लिए भी किया जाता है: वे उन्हें पढ़ते हैं और HTML-डॉक्स (या किसी अन्य प्रारूप में डॉक्स) उत्पन्न करते हैं।

0 commit comments

Comments
 (0)