Java Programming Style जावा प्रोग्रामिंग की शैली

Programming style is a set of guidelines applied to use the instructions of a programming language correctly. Following a programming style is crucial because it helps the programmer understand the code easily, and it reduces the chances of errors.

प्रोग्रामिंग शैली, किसी प्रोग्रामिंग लैंग्वेज के निर्देशों को सही तरीके से उपयोग करने के लिए लागू किए गए दिशानिर्देशों का एक समूह होता है। एक प्रोग्रामिंग शैली का पालन करना अत्यंत आवश्यक होता है क्योंकि इसकी सहायता से प्रोग्रामर कोड को आसानी से समझ सकता है एवं कम त्रुटियां उत्पन्न होती हैं।

Important Rules of Java Programming Style | जावा प्रोग्रामिंग शैली के महत्वपूर्ण नियम:

1️⃣ A Java program should be easy to read and understand.
एक जावा प्रोग्राम पढ़ने एवं समझने में आसान होना चाहिए।

2️⃣ Each class should have Javadoc comments and @author tag.
प्रत्येक क्लास में जावाडॉक टिप्पणी एवं @author टैग होना चाहिए।

3️⃣ Each public method should have Javadoc comments.
हर पब्लिक मेथड में जावाडॉक टिप्पणी होनी चाहिए।

4️⃣ Variables should include a comment explaining their purpose.
वेरिएबल के उद्देश्य की व्याख्या करने वाली टिप्पणी होनी चाहिए।

5️⃣ Add comments inside method body to explain logic.
कोड लॉजिक को समझाने हेतु मेथड बॉडी में टिप्पणी जोड़ी जा सकती है।

6️⃣ Use indentation to show code structure.
कोड संरचना दिखाने के लिए इंडेंटेशन का प्रयोग करें।

7️⃣ Use separate lines for closing curly brace }; opening brace { can be same or next line.
बंद कोष्टक } एक नई पंक्ति में हो, और { उसी या अगली पंक्ति में।

8️⃣ Avoid placing multiple statements on the same line.
एक ही पंक्ति में एक से अधिक स्टेटमेंट न रखें।

9️⃣ Break long lines into smaller readable lines.
लंबी पंक्तियों को छोटे भागों में विभाजित करें।

🔟 Add space between method definitions.
मेथड परिभाषाओं के बीच थोड़ा रिक्त स्थान रखें।

1️⃣1️⃣ Use meaningful names (camelCase, PascalCase).
सार्थक नामों का प्रयोग करें (कैमल केस, पास्कल केस जैसे maxMarks, SimpleInterest).

1️⃣2️⃣ Use final static for constants and enum for grouped constants.
कांस्टेंट के लिए final static और समूह के लिए enum का उपयोग करें।

1️⃣3️⃣ Method should be short and focused.
हर मेथड छोटा और विशिष्ट उद्देश्य वाला हो।

1️⃣4️⃣ Prefer parameters and return values over instance variables.
इंस्टेंस वेरिएबल्स की बजाय पैरामीटर और रिटर्न वैल्यू का उपयोग करें।

1️⃣5️⃣ Class should represent a unique, identifiable concept.
क्लास एक स्पष्ट और पहचाने जाने योग्य अवधारणा को दर्शाए।

1️⃣6️⃣ Keep variables in private section, and getter-setter methods in public section.
वेरिएबल्स को प्राइवेट और गेट/सेट मेथड को पब्लिक सेक्शन में रखें।


Comments

Popular posts from this blog

What is a Web Browser? वेब ब्राउज़र क्या है?

Java's Support System जावा का सहयोगी तंत्र

The Internet and Java इंटरनेट और जावा का सम्बन्ध