BCA / B.Tech 13 min read

Object-Oriented-Design in Hindi

RK

लेखक Ratan Kumawat · संस्थापक, NotesMedia

प्रकाशित:

त्वरित सारांश और मुख्य बिंदु

  • • विषय फोकस: Java Notes in Hindi | जावा नोट्स हिंदी में (BCA / B.Tech Syllabus)
  • • मुख्य विषय: Object-Oriented-Design in Hindi - General Topics
  • • अवलोकन: Quick Answer: Software engineering में Object Oriented Design (OOD) एक ऐसी design process है जिसमें software system को आपस में interact करने वाले discr...
  • • मुख्य अवधारणाएं: Object oriented design, OOD principles patterns Hindi, UML case studies,
Quick Answer: Software engineering में Object Oriented Design (OOD) एक ऐसी design process है जिसमें software system को आपस में interact करने वाले discrete objects के रूप में plan और structure किया जाता है। इसमें real-world entities को software objects में बदला जाता है, जहाँ हर object का अपना state (data) और behavior (methods) होता है। OOD मुख्य रूप से four core OOP principles—encapsulation, abstraction, inheritance और polymorphism—पर काम करता है, ताकि software modular, reusable और maintainable बने।

Object Oriented Design in Software Engineering in Hindi क्या है?

Software development life cycle (SDLC) में analysis phase के बाद design phase आता है। Object Oriented Analysis (OOA) में हम यह समझते हैं कि system को क्या करना है (What to do), जबकि Object Oriented Design (OOD) में हम यह तय करते हैं कि system उस काम को कैसे करेगा (How to do it)।

आसान शब्दों में कहें तो, OOD एक blueprint तैयार करने की technique है। जब भी आप Java या किसी अन्य language में बड़ा project बनाते हैं, तो सीधे coding शुरू नहीं करते। पहले आप तय करते हैं कि system में कौन-कौन सी classes होंगी, उनके पास क्या data fields होंगे, वे कौन से methods execute करेंगी, और एक class दूसरी class से कैसे जुड़ेगी।

OOD real-world world को software world से जोड़ता है। उदाहरण के लिए, एक Banking System को design करते समय Bank, Customer, Account और Transaction को अलग-अलग objects मान लिया जाता है। इस पूरे model को code में उतारने के लिए आप class और object का इस्तेमाल करते हैं।

Advertisement

Object Model in Software Engineering in Hindi

Software engineering में Object Model वह conceptual framework है जो किसी software system को real-world objects के collection के रूप में describe करता है। यह traditional procedural approach से बिल्कुल अलग है, जहाँ system को functions और procedures के हिसाब से सोचा जाता था।

Object model के चार मुख्य आधार (foundational pillars) होते हैं:

  • Abstraction: सिर्फ ज़रूरी features और behavior को user के सामने दिखाना और internal background complexity को छुपाना। Java में इसे abstract classes और interfaces से achieve किया जाता है। Detail में समझने के लिए देखें: Abstraction in Hindi.
  • Encapsulation: Data (variables) और methods (functions) को एक single unit (class) में बाँधना, और data को direct unauthorized access से सुरक्षित रखना। इसके लिए data variables को private बनाया जाता है और access के लिए getters/setters दिए जाते हैं।
  • Modularity: पूरे बड़े system को छोटे-छोटे, loosely coupled modules या classes में बाँटना, ताकि testing और debugging आसान हो जाए।
  • Hierarchy: Classes के बीच relationship और ranking तय करना। यह दो तरह की होती है: "is-a" hierarchy (inheritance) और "part-of" hierarchy (aggregation/composition)। Inheritance की पूरी जानकारी: Inheritance in Hindi.

Object Oriented Design की Process (Step-by-Step Steps)

Software engineering में OOD को पूरा करने के लिए systematic steps follow किए जाते हैं:

  1. Real-world Problem Analysis: System requirements specification (SRS) document को पढ़कर यह समझना कि system में कौन-कौन से actors और resources शामिल हैं।
  2. Identification of Classes and Objects: Problem domain से nouns को ढूँढकर candidate classes चुनी जाती हैं (जैसे User, Order, Product, Payment)।
  3. Attributes और Methods Define करना: हर class के पास क्या data होगा (attributes) और वह क्या काम करेगी (methods/operations), यह तय किया जाता है। Verbs आमतौर पर methods बनते हैं (जैसे calculateTotal(), makePayment())।
  4. Define Relationships: Classes आपस में कैसे interact करेंगी, यह तय किया जाता है। क्या एक class दूसरी class की child है (inheritance), या एक class दूसरी class का हिस्सा है (association, aggregation, composition)?
  5. Apply Design Patterns: Common software problems को solve करने के लिए standard industry design patterns (जैसे Singleton, Factory, Observer) का use किया जाता है।
  6. Detailed Design & Class Diagram: UML (Unified Modeling Language) का इस्तेमाल करके visual class diagrams, sequence diagrams और interaction models बनाए जाते हैं, जिन्हें developers सीधे code में बदल सकें।

Object Relationships: Association, Aggregation और Composition

OOD में सबसे महत्वपूर्ण काम objects के बीच connection तय करना होता है। Objects अकेले काम नहीं करते, वे एक-दूसरे से communicate करते हैं। Relationships तीन मुख्य categories में बांटी जाती हैं:

1. Association

यह दो independent classes के बीच का simple connection है। इसमें एक object दूसरे object की service लेता है। इसे "uses-a" relationship कहते हैं। उदाहरण: Teacher और Student। Teacher students को पढ़ाते हैं, लेकिन दोनों की life cycle independent होती है।

2. Object Aggregation in Software Engineering in Hindi

Aggregation association का एक specialized form है। यह एक "has-a" relationship को represent करता है, लेकिन इसमें weak ownership होती है। इसका मतलब है कि child object, parent object के बिना भी स्वतंत्र रूप से exist कर सकता है। दोनों की life cycle एक-दूसरे पर completely depend नहीं करती।

Real-world Example: Department और Teacher। एक Department में Teachers होते हैं ("Department HAS Teachers")। अगर किसी कारण से Department बंद हो जाए या delete हो जाए, तो भी Teacher object नष्ट नहीं होता; वह Teacher किसी दूसरे Department में जा सकता है।

3. Composition

Composition aggregation का एक strictly strong रूप है। इसमें strong ownership होती है। इसका मतलब है कि child object का existence पूरी तरह parent object पर depend करता है। अगर parent object delete हुआ, तो child object अपने आप delete हो जाएगा।

Real-world Example: Car और Engine, या House और Room। एक House में Rooms होते हैं। अगर पूरा House destroy हो जाए, तो उसके Rooms का अलग से कोई स्वतंत्र अस्तित्व नहीं रहता।

Relationship Hierarchy:
[Association]  --> Basic connection ("uses-a")
      |
      v
[Aggregation]  --> Weak "has-a" (Child survives if parent dies)
      |
      v
[Composition]  --> Strong "has-a" (Child dies if parent dies)

Table 1: Aggregation vs Composition में अंतर

BCA और B.Tech university exams में यह question बहुत बार पूछा जाता है। नीचे दी गई table से इसे याद रखें:

Feature / Point Aggregation (Weak HAS-A) Composition (Strong HAS-A)
Relationship Type Weak "has-a" relationship Strong "has-a" relationship
Ownership Shared ownership (कोई strict master-slave नहीं) Sole / Exclusive ownership (parent ही मालिक है)
Lifecycle Dependency Child object स्वतंत्र रह सकता है (Independent) Child object parent के बिना exist नहीं कर सकता (Dependent)
UML Notation Hollow Diamond (खाली हीरा) symbol Filled / Solid Diamond (भरा हुआ हीरा) symbol
Example College और Student (College बंद हो तो भी Student रहेगा) Human और Heart (Human नहीं रहा तो Heart भी काम नहीं करेगा)

Is Java Fully Object Oriented? (Pure vs Hybrid OOP)

बहुत से students सोचते हैं कि Java 100% pure object oriented language है, लेकिन सच यह है कि Java is NOT a purely / fully object-oriented language। Java एक hybrid / practical object-oriented language है। इसके 4 technical कारण हैं:

  • Primitive Data Types का support: Pure OOP language (जैसे Smalltalk) में हर चीज़ एक object होनी चाहिए। लेकिन Java में int, float, char, boolean, double, byte, short, long जैसे 8 primitive types होते हैं। ये objects नहीं हैं, और memory में stack पर directly store होते हैं। Performance fast रखने के लिए Java creators ने इन्हें रखा था।
  • static Keyword का इस्तेमाल: Java में static methods और static variables class से जुड़े होते हैं, object से नहीं। आप बिना कोई object बनाए ClassName.methodName() call कर सकते हैं, जो pure OOP philosophy का उल्लंघन है।
  • Multiple Inheritance of Classes नहीं होना: Java classes के level पर diamond problem से बचने के लिए multiple inheritance allow नहीं करता (हालाँकि interface से इसे achieve किया जाता है)।
  • Wrapper Classes भी syntactic sugar हैं: Java में Integer, Float जैसी wrapper classes और Autoboxing मौजूद हैं, लेकिन background में primitive types तब भी वैसे ही काम करते हैं।

Java के core features और structure को detail में समझने के लिए पढ़ें: OOPs Concepts in Java in Hindi.

Table 2: Object Oriented Design (OOD) vs Structured / Procedural Design

Parameter Object Oriented Design (OOD) Structured / Procedural Design
Approach Bottom-up approach Top-down approach
Core Focus Data और Objects पर focus Functions और Procedures / Algorithms पर focus
Data Security High (Data hiding और Encapsulation से data safe रहता है) Low (Data freely functions के बीच global variable की तरह घूमता है)
Reusability High (Inheritance, Polymorphism और Composition के ज़रिए) Low (Code reuse करना कठिन होता है)
Modification & Maintenance Easy (एक class बदलने से बाकी code disturb नहीं होता) Hard (एक function बदलने पर पूरे program में side-effects आते हैं)
Real-world Mapping Direct और Natural (Real-world entities को object बनाया जाता है) Abstract (Real world को code में map करना मुश्किल होता है)
Advertisement

Solved Example: Real-World OOD Implementation in Java (Aggregation)

नीचे दिए गए code example में University और Department के बीच Aggregation relationship को design किया गया है। यहाँ Professor एक independent class है। Department class, Professor object का reference अपने अंदर रखती है (HAS-A relationship)।

// Independent class: Professor
class Professor {
    private String name;
    private String subject;

    public Professor(String name, String subject) {
        this.name = name;
        this.subject = subject;
    }

    public String getName() {
        return name;
    }

    public String getSubject() {
        return subject;
    }
}

// Department class has Professor (Aggregation)
class Department {
    private String deptName;
    private Professor professor; // Weak HAS-A link

    public Department(String deptName, Professor professor) {
        this.deptName = deptName;
        this.professor = professor;
    }

    public void showDetails() {
        System.out.println("Department: " + deptName);
        System.out.println("Faculty Incharge: " + professor.getName());
        System.out.println("Subject Specialization: " + professor.getSubject());
    }
}

public class OODDemo {
    public static void main(String[] args) {
        // Step 1: Independent professor object बनाया
        Professor prof = new Professor("Dr. R. K. Sharma", "Software Engineering");

        // Step 2: Department को professor assign किया
        Department dept = new Department("Computer Science", prof);

        // Details display करना
        dept.showDetails();
    }
}

Output:

Department: Computer Science
Faculty Incharge: Dr. R. K. Sharma
Subject Specialization: Software Engineering

OOD Point: अगर dept = null; कर दिया जाए, तो भी prof object memory में सुरक्षित रहेगा। यही Aggregation की खासियत है।

Exam में कैसे लिखें (5 Marks Answer)

अगर exam में 5 marks का question आए "Define Object Oriented Design (OOD) in Software Engineering", तो answer sheet में सीधे इस structure में points लिखें:

  • Definition: OOD एक ऐसी software design process है जिसमें software requirements को classes, objects और उनके आपसी relationships के रूप में convert किया जाता है।
  • Main Goal: Complex software systems को modular, maintainable, scalable और reusable बनाना।
  • Core Concepts: यह चार pillars पर टिका है—Encapsulation (data hiding), Abstraction (essential features दिखाना), Inheritance (code reuse) और Polymorphism (many forms)।
  • OOD के 4 Major Steps:
    1. Identify Classes & Objects from requirements.
    2. Define Attributes (data) and Methods (behavior).
    3. Establish Relationships (Association, Aggregation, Composition, Inheritance).
    4. Construct Class Diagrams (UML)।
  • Key Advantage: Structured design की तुलना में इसमें data security बहुत high होती है और बड़े enterprise applications आसानी से manage होते हैं।
  • Small Diagram: Class box बनाएँ जिसमें 3 sections हों: Class Name, Attributes, Methods।

Common Mistakes जो Students करते हैं

  1. OOA और OOD को एक समझ लेना: Object Oriented Analysis (OOA) में हम problem को समझते हैं ("क्या बनाना है"), जबकि Object Oriented Design (OOD) में technical architecture और solution design करते हैं ("कैसे बनाना है")।
  2. Java को Pure OOP मान लेना: Exam में यह गलती कभी न करें। Java में primitive types (int, float आदि) और static methods होने की वजह से यह Pure OOP नहीं है।
  3. Aggregation और Composition में confuse होना: Aggregation में child object independent जिंदा रह सकता है (weak bond), जबकि Composition में parent के destroy होने पर child भी destroy हो जाता है (strong bond)।
  4. Encapsulation ignore करना: OOD में class variables को direct public नहीं रखा जाता। उन्हें हमेशा private रखें और getters/setters का use करें।

Advantages और Disadvantages of Object Oriented Design

Advantages (फायदे) Disadvantages (नुकसान)
Code Reusability: Inheritance और libraries की वजह से एक बार लिखा code बार-बार use होता है। Steep Learning Curve: Procedural programming की तुलना में OOD को सीखना और design pattern समझना कठिन है।
Easy Maintenance: Code modular होता है। एक class का bug पूरी application को crash नहीं करता। Design Overhead: छोटे projects और simple scripts के लिए OOD overkill है, फालतू complexity बढ़ जाती है।
Better Security: Data encapsulation और access specifiers से critical data safe रहता है। Performance Overhead: Function calls, dynamic binding और memory management की वजह से execution time थोड़ा बढ़ सकता है।
Real-World Mapping: Business logic को code में represent करना आसान और natural होता है। Larger Program Size: Classes और abstraction layers की वजह से overall lines of code और file size बढ़ जाता है।

Exam के लिए Important Questions

Short Questions (2–3 marks)

  1. Object Oriented Design (OOD) क्या है? (System को interacting objects और classes के रूप में model करने की process)
  2. Aggregation और Composition में मुख्य अंतर क्या है? (Aggregation में weak ownership होती है, Composition में strong ownership होती है)
  3. Is Java a pure object oriented language? Why? (नहीं, क्योंकि इसमें primitive data types जैसे int, char और static methods होते हैं)
  4. OOD में "is-a" और "has-a" relationship क्या दर्शाते हैं? ("is-a" inheritance को और "has-a" association/aggregation को दर्शाता है)
  5. Object model के चार foundational elements के नाम लिखिए। (Abstraction, Encapsulation, Modularity, Hierarchy)

Long Questions (5–10 marks)

  1. Object Oriented Design in software engineering क्या है? इसके steps और core principles को detail में समझाइए।
  2. Object relationships क्या हैं? Association, Aggregation और Composition को suitable Java examples और diagrams के साथ समझाइए।
  3. Structured Design और Object Oriented Design के बीच तुलना कीजिए। Software engineering में OOD को बेहतर क्यों माना जाता है?

FAQs

Object oriented design in software engineering in hindi में मुख्य steps क्या हैं?

OOD के मुख्य steps हैं: problem domain से classes और objects की पहचान करना, उनके data attributes और methods define करना, classes के बीच relationships (inheritance, aggregation) तय करना, और अंत में UML class diagram तैयार करना।

Is Java fully object oriented or purely object oriented?

नहीं, Java fully या purely object-oriented programming language नहीं है। Java में primitive data types (जैसे int, float, double, char) सीधे memory stack में store होते हैं और objects नहीं होते। इसके अलावा static methods को बिना object बनाए class name से call किया जा सकता है।

Object aggregation in software engineering in hindi क्या है?

Aggregation दो classes के बीच weak "has-a" relationship को कहते हैं। इसमें एक class दूसरी class का reference रखती है, लेकिन दोनों की life cycle independent होती है। अगर parent object delete हो जाए, तो भी child object बना रहता है (जैसे University और Teacher)।

Object Oriented Analysis (OOA) और Object Oriented Design (OOD) में क्या अंतर है?

OOA का focus "What to build" पर होता है, जहाँ user की requirements समझकर problem domain model बनाया जाता है। OOD का focus "How to build" पर होता है, जहाँ technical architecture, classes, interfaces और database interactions को design किया जाता है।

अक्सर पूछे जाने वाले प्रश्न (FAQs)

Quick Answer: Software engineering में Object Oriented Design (OOD) एक ऐसी design process है जिसमें software system को आपस में interact करने वाले discrete objects के रूप में plan और structure किया जाता है।
Java Notes in Hindi | जावा नोट्स हिंदी में के पाठ्यक्रम में Object-Oriented-Design in Hindi एक महत्वपूर्ण अध्याय है। यह मुख्य सिद्धांतों, परीक्षा प्रश्नों और सूत्रों को समझने के लिए अत्यधिक आवश्यक है।
हाँ, NotesMedia पर आपको Object-Oriented-Design in Hindi के महत्वपूर्ण प्रश्नोत्तर, हल किए गए उदाहरण और नोट्स बिल्कुल मुफ्त मिलेंगे। अधिक अभ्यास के लिए आप हमारा ऐप भी डाउनलोड कर सकते हैं।
Advertisement

In this Chapter

Object-Oriented-Design in Hindi
BCA || Java 2024 Paper || MDSU Exam Paper
What is Java, Characteristics of Java - Java क्या है और जावा की विशेषताएं
Difference between Java and C++ in Hindi. (Java और C++ में अंतर )
Applications of Java Programming in Hindi
OOPS concepts in Java Hindi
What is JVM and JRE in hindi
Features of JAVA in hindi
What is Java bean in hindi & advantage in Hindi
Difference between Java and JavaScript in Hindi
JIT Compiler in Hindi
What is Control Statement (structure) in Hindi
What is variable in hindi (वेरिएबल क्या होता है?):-
Java URL Class in Hindi
What is Java swing and its methods in Hindi
Operators in Java in Hindi
Class & Method in Hindi
Inheritance in Java in Hindi | जावा में इनहेरिटेंस हिंदी में
instance Operator in Hindi
Token in Hindi
Data Types in Hindi
Constructor in Hindi
Conditional Operator in Hindi
Constant in Hindi
Reference Variable in Hindi
Type Casting in Hindi
Literals in Hindi
Identifiers in Hindi
Array in Hindi
Anonymous Array in Hindi
Access Modifiers in Hindi
Enum Data type in Hindi
Keywords in Hindi-Java
Super Keywords in Hindi
Static Keywords in Hindi
Final Keywords in Hindi
New Operator in Hindi
Method Types in Hindi
Method Overloading in Hindi
Method Overriding in Hindi
Method Hiding in Hindi
Class & Object in Hindi
Diffrence Beetween Class & Object in Hindi
Math Class in Hindi
Abstraction in Hindi
Adapter Pattern in Hindi
Package in Hindi
Class & Structure in Java in Hindi
Exception Handling in Hindi