पोस्ट
जेनेरेटिव AI के साथ अपनी कोडिंग प्रोडक्टिविटी बढ़ाने के 5 तरीके
31 जनवरी 2025 • 8 मिनट पढ़ना

एक Software Craftsman के रूप में इस क्षेत्र में वर्षों के अनुभव के साथ, मैंने 2023 में ChatGPT की शुरुआत के बाद से सॉफ्टवेयर डेवलपमेंट पर जेनेरेटिव AI के प्रभाव को देखा है। व्यावहारिक अनुप्रयोग के माध्यम से, मैंने प्रोडक्टिविटी बढ़ाने के लिए इस तकनीक का लाभ उठाने के पांच शक्तिशाली तरीके पहचाने हैं।
1. बेहतर कोड सर्च
जेनेरेटिव AI का उपयोग करने का सबसे आम तरीका तकनीकी जानकारी खोजना है। पारंपरिक सर्च इंजन को सटीक शब्दावली की आवश्यकता होती है, जबकि जेनेरेटिव AI अवधारणाओं और संदर्भ को समझता है। उदाहरण के लिए, जब मैं method parameter optimization के सिद्धांत की खोज कर रहा था, तो मैंने पूछा:
Prompt
What's the name of the programming concept where you should only pass parameters that are actually used by the method? Passing parameters to a method that aren't used by the method creates unneeded dependencies.
जेनेरेटिव AI मेरे द्वारा वर्णित अवधारणा (Law of Demeter) को समझता है और सही उत्तर प्रदान करता है, जिससे कई खोजों की आवश्यकता समाप्त हो जाती है।
2. कुशल कोड जेनेरेशन
जेनेरेटिव AI दोहराए जाने वाले कोडिंग कार्यों को स्वचालित करने में उत्कृष्ट है। हाल ही में, मुझे एक बड़ी JSON फ़ाइल को डेटाबेस insert statements में बदलना था। थकाऊ conversion code लिखने के बजाय, मैंने MS SQL Server insert statements जेनेरेट करने के लिए स्पष्ट निर्देशों के साथ AI को JSON डेटा प्रदान किया। इस दृष्टिकोण ने मैन्युअल कोडिंग के घंटों की बचत की और त्रुटियों की संभावना को कम किया।
Prompt:
Use the JSON data provided below and generate insert statements for MS SQL Server to be inserted into the dbo.Users table.
[
{
"Username": "musiclover87",
"Lastname": "Smith",
"Firstname": "Alice",
"Birthdate": "1987-06-12",
"Password": "password123",
"FavoriteIceCream": "Chocolate Chip Cookie Dough",
"FavoriteSuperhero": "Spider-Man"
},
{
"Username": "bookworm92",
"Lastname": "Johnson",
"Firstname": "Bob",
"Birthdate": "1992-03-21",
"Password": "securePassword",
"FavoriteIceCream": "Mint Chocolate Chip",
"FavoriteSuperhero": "Batman"
},
{
"Username": "gamergirl01",
"Lastname": "Williams",
"Firstname": "Carol",
"Birthdate": "2001-11-05",
"Password": "gamer4life",
"FavoriteIceCream": "Strawberry",
"FavoriteSuperhero": "Wonder Woman"
},
{
"Username": "techieguy95",
"Lastname": "Brown",
"Firstname": "David",
"Birthdate": "1995-08-18",
"Password": "techmaster",
"FavoriteIceCream": "Vanilla Bean",
"FavoriteSuperhero": "Iron Man"
},
{
"Username": "foodiequeen89",
"Lastname": "Davis",
"Firstname": "Emily",
"Birthdate": "1989-04-29",
"Password": "delicious123",
"FavoriteIceCream": "Salted Caramel",
"FavoriteSuperhero": "Captain Marvel"
},
{
"Username": "traveler76",
"Lastname": "Miller",
"Firstname": "Frank",
"Birthdate": "1976-12-02",
"Password": "adventuretime",
"FavoriteIceCream": "Coffee",
"FavoriteSuperhero": "Thor"
},
{
"Username": "fitnessfanatic98",
"Lastname": "Wilson",
"Firstname": "Grace",
"Birthdate": "1998-09-15",
"Password": "strongandfit",
"FavoriteIceCream": "Mango Sorbet",
"FavoriteSuperhero": "Black Widow"
},
{
"Username": "photographylover85",
"Lastname": "Moore",
"Firstname": "Henry",
"Birthdate": "1985-05-23",
"Password": "pictureperfect",
"FavoriteIceCream": "Pistachio",
"FavoriteSuperhero": "Superman"
},
{
"Username": "musicjunkie93",
"Lastname": "Taylor",
"Firstname": "Isabella",
"Birthdate": "1993-02-08",
"Password": "musicislife",
"FavoriteIceCream": "Rocky Road",
"FavoriteSuperhero": "Black Panther"
},
{
"Username": "sportsfanatic88",
"Lastname": "Anderson",
"Firstname": "Jack",
"Birthdate": "1988-10-30",
"Password": "goteamgo",
"FavoriteIceCream": "Cookies and Cream",
"FavoriteSuperhero": "Captain America"
}
]
Output:
-- Inserting records into dbo.Users table
INSERT INTO dbo.Users (Username, Lastname, Firstname, Birthdate, Password, FavoriteIceCream, FavoriteSuperhero)
VALUES
('musiclover87', 'Smith', 'Alice', '1987-06-12', 'password123', 'Chocolate Chip Cookie Dough', 'Spider-Man'),
('bookworm92', 'Johnson', 'Bob', '1992-03-21', 'securePassword', 'Mint Chocolate Chip', 'Batman'),
('gamergirl01', 'Williams', 'Carol', '2001-11-05', 'gamer4life', 'Strawberry', 'Wonder Woman'),
('techieguy95', 'Brown', 'David', '1995-08-18', 'techmaster', 'Vanilla Bean', 'Iron Man'),
('foodiequeen89', 'Davis', 'Emily', '1989-04-29', 'delicious123', 'Salted Caramel', 'Captain Marvel'),
('traveler76', 'Miller', 'Frank', '1976-12-02', 'adventuretime', 'Coffee', 'Thor'),
('fitnessfanatic98', 'Wilson', 'Grace', '1998-09-15', 'strongandfit', 'Mango Sorbet', 'Black Widow'),
('photographylover85', 'Moore', 'Henry', '1985-05-23', 'pictureperfect', 'Pistachio', 'Superman'),
('musicjunkie93', 'Taylor', 'Isabella', '1993-02-08', 'musicislife', 'Rocky Road', 'Black Panther'),
('sportsfanatic88', 'Anderson', 'Jack', '1988-10-30', 'goteamgo', 'Cookies and Cream', 'Captain America');
3. सहज कोड ट्रांसलेशन
कोड ट्रांसलेशन एक और क्षेत्र है जहां जेनेरेटिव AI अमूल्य साबित होता है। एक C# एप्लिकेशन को Python में बदलने के हाल के प्रोजेक्ट के दौरान, हमने AI का उपयोग दो महत्वपूर्ण तरीकों से किया:
-
Python से C# में सीधा function conversion
-
Entity Framework से SQLAlchemy में जटिल ORM translation
इस क्षमता ने हमारी migration प्रक्रिया को काफी तेज़ किया और translations में consistency सुनिश्चित की।
Python को C# में बदलना:
Prompt:
Convert the following Python code to C#.
def reverse_string(text):
"""
Reverses a given string.
Args: text: The string to be reversed.
Returns: The reversed string.
"""
return text[::-1]
Output:
/// <summary>
/// Reverses a given string.
/// </summary>
/// <param name="text">The string to be reversed.</param>
/// <returns>The reversed string.</returns>
public static string ReverseString(string text)
{
return new string(text.Reverse().ToArray());
}
4. स्वचालित कोड डॉक्यूमेंटेशन
डॉक्यूमेंटेशन आवश्यक है लेकिन अक्सर थकाऊ होता है। जेनेरेटिव AI इस प्रक्रिया को दो तरीकों से सुव्यवस्थित करता है:
-
कोड सारांश: मौजूदा कोड का विश्लेषण करना और स्पष्ट, संक्षिप्त सारांश प्रदान करना
-
डॉक्यूमेंटेशन हेडर जेनेरेशन: व्यापक method documentation बनाना जो कोड गुणवत्ता मानकों को बनाए रखता है
उदाहरण के लिए, sorting algorithms या जटिल business logic को document करते समय, AI स्पष्ट, सटीक documentation जेनेरेट कर सकता है जो टीम के मानकों और सर्वोत्तम प्रथाओं का पालन करता है।
Prompt:
Generate a doc header for the below function adding the header and printing the complete function with the doc header.
def bubble_sort(list_):
n = len(list_)
for i in range(n):
# Flag to optimize, if no swaps occur, the list is sorted
swapped = False
# Last i elements are already in place
for j in range(0, n-i-1):
# Swap if the element found is greater than the next element
if list_[j] > list_[j+1]:
list_[j], list_[j+1] = list_[j+1], list_[j]
swapped = True
# If no two elements were swapped in inner loop, the list is sorted
if not swapped:
break
return list_
Output:
def bubble_sort(list_):
"""
Sorts a given list using the Bubble Sort algorithm.
Args:
list_: The list of elements to be sorted. Elements must be comparable.
Returns:
A new list containing all elements from the original list in ascending order.
Example:
>>> bubble_sort([64, 34, 25, 12, 22, 11, 90])
[11, 12, 22, 25, 34, 64, 90]
"""
n = len(list_)
for i in range(n):
# Flag to optimize, if no swaps occur, the list is sorted
swapped = False
# Last i elements are already in place
for j in range(0, n-i-1):
# Swap if the element found is greater than the next element
if list_[j] > list_[j+1]:
list_[j], list_[j+1] = list_[j+1], list_[j]
swapped = True
# If no two elements were swapped in inner loop, the list is sorted
if not swapped:
break
return list_
5. एप्लिकेशन स्कैफोल्डिंग
शायद जेनेरेटिव AI का सबसे प्रभावशाली अनुप्रयोग प्रारंभिक एप्लिकेशन संरचनाएं जेनेरेट करने की इसकी क्षमता है। एक स्पष्ट schema या specification दिए जाने पर, AI निम्नलिखित बना सकता है:
-
डेटाबेस creation scripts
-
ORM mappings
-
बुनियादी API endpoints
-
प्रारंभिक UI implementations
यह क्षमता boilerplate code पर खर्च होने वाले समय को काफी कम करती है और आगे के विकास के लिए एक consistent foundation सुनिश्चित करती है।
Prompt:
You are a Software Engineer working at a large corporation. Using the following database schema, generate the SQL scripts necessary to create these tables in Postgres. Then, generate the SQL Alchemy mapping files to use with FastAPI. Lastly, generate a simple web UI using FastAPI to list the orders.
User
- UserId
- FirstName
- LastName
- Address
- Address2
- City
- State
- ZipCode
- Username
- Password
- IsActive
Client
- ClientId
- Name
- Address
- Address2
- City
- State
- ZipCode
- IsActive
Order
- OrderId
- OrderDate
- InvoiceNumber
- DueDate
- ClientId
- UserId
OrderDetail
- OrderDetailId
- OrderId
- Description
- Rate
- Quantity
- LineTotal
Ledger
- TransactionId
- Debit
- Credit
- OrderId
- TransactionDate
Output:
...
मैं आपको output से बचा रहा हूं, लेकिन इसने FastAPI का उपयोग करके एक पूरा एप्लिकेशन जेनेरेट किया।
...
आइए पूछते हैं कि हम प्रारंभिक डिज़ाइन को बेहतर बनाने के लिए क्या कर सकते हैं।
Prompt 2:
That's a great start. What can we do to improve the application design?
Output:
बेहतर debugging और error handling के लिए logging implement करें।
logging.py (Optional)
import logging
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
def log_error(error):
logger.error(f"An error occurred: {error}")
Prompt 3:
Can you implement your suggestion to use Error Handling and generate the code for me?
Output:
यदि आप specific exceptions को globally handle करना चाहते हैं तो आप अपनी main.py
फ़ाइल में global exception handlers भी define कर सकते हैं।
main.py
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
import app.routers.order_router as order_router
from .exceptions import OrderNotFoundException, InvalidInvoiceNumberException
app = FastAPI()
# Include the router
app.include_router(order_router.router)
@app.exception_handler(OrderNotFoundException)
async def order_not_found_exception_handler(request: Request, exc: OrderNotFoundException):
return JSONResponse(
status_code=exc.status_code,
content={"detail": exc.detail},
)
@app.exception_handler(InvalidInvoiceNumberException)
async def invalid_invoice_number_exception_handler(request: Request, exc: InvalidInvoiceNumberException):
return JSONResponse(
status_code=exc.status_code,
content={"detail": exc.detail},
)
सर्वोत्तम प्रथाएं और विचारणीय बातें
जबकि जेनेरेटिव AI शक्तिशाली है, यह महत्वपूर्ण है कि:
- जेनेरेट किए गए कोड की समीक्षा और सत्यापन करें
- मौजूदा codebases के साथ consistency बनाए रखें
- सुरक्षा निहितार्थों पर विचार करें
- जेनेरेट किए गए कोड को अच्छी तरह से test करें
- AI का उपयोग engineering judgment के replacement के बजाय assistant के रूप में करें
निष्कर्ष
जेनेरेटिव AI आधुनिक सॉफ्टवेयर डेवलपमेंट में एक अपरिहार्य उपकरण बन गया है। इन पांच दृष्टिकोणों का लाभ उठाकर - बेहतर searching, कोड generation, translation, documentation, और application scaffolding - डेवलपर्स कोड गुणवत्ता बनाए रखते हुए अपनी प्रोडक्टिविटी को काफी बढ़ा सकते हैं।
मुख्य बात इन उपकरणों की क्षमताओं और सीमाओं को समझना और मानवीय विशेषज्ञता को बदलने के बजाय बढ़ाने के लिए रणनीतिक रूप से उनका उपयोग करना है। जैसे-जैसे ये तकनीकें विकसित होती हैं, development workflows में उनका integration तेजी से मूल्यवान होता जाएगा।
लेखक: चक कॉनवे सॉफ्टवेयर इंजीनियरिंग और जेनेरेटिव AI में विशेषज्ञता रखते हैं। उनसे सोशल मीडिया पर जुड़ें: X (@chuckconway) या उन्हें YouTube पर देखें।