Document Details

EnergySavingMaroon

Uploaded by EnergySavingMaroon

Bicol University

Tags

object-oriented programming programming languages software development computer science

Full Transcript

INTRODUCTION TO OBJECT ORIENTED PROGRAMMING (OOP) Source: https://www.javatpoint.com/java-oops-concepts PROGRAMMING LANGUAGES PROGRAMMING LANGUAGES ALLOW PROGRAMMERS TO CODE SOFTWARE. THE THREE MAJOR FAMILIES...

INTRODUCTION TO OBJECT ORIENTED PROGRAMMING (OOP) Source: https://www.javatpoint.com/java-oops-concepts PROGRAMMING LANGUAGES PROGRAMMING LANGUAGES ALLOW PROGRAMMERS TO CODE SOFTWARE. THE THREE MAJOR FAMILIES OF LANGUAGES ARE: 1. MACHINE LANGUAGES 2. ASSEMBLY LANGUAGES 3. HIGH-LEVEL LANGUAGES Source: https://www.javatpoint.com/java-oops-concepts MACHINE LANGUAGES COMPRISED OF 1S AND 0S THE “NATIVE” LANGUAGE OF A COMPUTER DIFFICULT TO PROGRAM – ONE MISPLACED 1 OR 0 WILL CAUSE THE PROGRAM TO FAIL. EXAMPLE OF CODE: 1110100010101 111010101110 10111010110100 10100011110111 Source: https://www.javatpoint.com/java-oops-concepts ASSEMBLY LANGUAGES ASSEMBLY LANGUAGES ARE A STEP TOWARDS EASIER PROGRAMMING. ASSEMBLY LANGUAGES ARE COMPRISED OF A SET OF ELEMENTAL COMMANDS WHICH ARE TIED TO A SPECIFIC PROCESSOR. ASSEMBLY LANGUAGE CODE NEEDS TO BE TRANSLATED TO MACHINE LANGUAGE BEFORE THE COMPUTER PROCESSES IT. EXAMPLE: ADD 1001010, 1011010 Source: https://www.javatpoint.com/java-oops-concepts HIGH-LEVEL LANGUAGES HIGH-LEVEL LANGUAGES REPRESENT A GIANT LEAP TOWARDS EASIER PROGRAMMING. THE SYNTAX OF HL LANGUAGES IS SIMILAR TO ENGLISH. HISTORICALLY, WE DIVIDE HL LANGUAGES INTO TWO GROUPS: PROCEDURAL LANGUAGES OBJECT-ORIENTED LANGUAGES (OOP) Source: https://www.javatpoint.com/java-oops-concepts PROCEDURAL LANGUAGES PROCEDURAL LANGUAGES ARE CHARACTERIZED BY SEQUENTIAL SETS OF LINEAR COMMANDS. THE FOCUS OF SUCH LANGUAGES IS ON STRUCTURE. EXAMPLES INCLUDE C, COBOL, FORTRAN, LISP, PERL, HTML, VBSCRIPT Source: https://www.javatpoint.com/java-oops-concepts OBJECT-ORIENTED LANGUAGES MOST OBJECT-ORIENTED LANGUAGES ARE HIGH-LEVEL LANGUAGES. THE FOCUS OF OOP LANGUAGES IS NOT ON STRUCTURE, BUT ON MODELING DATA. PROGRAMMERS CODE USING “BLUEPRINTS” OF DATA MODELS CALLED CLASSES. EXAMPLES OF OOP LANGUAGES INCLUDE C++, VISUAL BASIC.NET AND JAVA. Source: https://www.javatpoint.com/java-oops-concepts JAVA OOPS CONCEPTS OBJECT-ORIENTED PROGRAMMING IS A PARADIGM THAT PROVIDES MANY CONCEPTS, SUCH AS: INHERITANCE, DATA BINDING, POLYMORPHISM, ETC. Source: https://www.javatpoint.com/java-oops-concepts SIMULA IS CONSIDERED THE FIRST OBJECT-ORIENTED PROGRAMMING LANGUAGE. SMALLTALK IS CONSIDERED THE FIRST TRULY OBJECT-ORIENTED PROGRAMMING LANGUAGE. Source: https://www.javatpoint.com/java-oops-concepts THE POPULAR OBJECT-ORIENTED LANGUAGES ARE JAVA, C#, PHP, PYTHON, C++, ETC. THE MAIN AIM OF OBJECT-ORIENTED PROGRAMMING IS TO IMPLEMENT REAL-WORLD ENTITIES, FOR EXAMPLE, OBJECT, CLASSES, ABSTRACTION, INHERITANCE, POLYMORPHISM, ETC. Source: https://www.javatpoint.com/java-oops-concepts OOPS (OBJECT-ORIENTED PROGRAMMING SYSTEM) OBJECT MEANS A REAL-WORLD ENTITY SUCH AS A PEN, CHAIR, TABLE, COMPUTER, WATCH, ETC. OBJECT-ORIENTED PROGRAMMING IS A METHODOLOGY OR PARADIGM TO DESIGN A PROGRAM USING CLASSES AND OBJECTS. IT SIMPLIFIES SOFTWARE DEVELOPMENT AND MAINTENANCE BY PROVIDING SOME CONCEPTS: OBJECT, CLASS, INHERITANCE, POLYMORPHISM, ABSTRACTION, ENCAPSULATION Source: https://www.javatpoint.com/java-oops-concepts APART FROM THESE CONCEPTS, THERE ARE SOME OTHER TERMS WHICH ARE USED IN OBJECT-ORIENTED DESIGN: COUPLING COHESION ASSOCIATION AGGREGATION COMPOSITION Source: https://www.javatpoint.com/java-oops-concepts Source: https://www.javatpoint.com/java-oops-concepts Object ANY ENTITY THAT HAS STATE AND BEHAVIOR IS KNOWN AS AN OBJECT. FOR EXAMPLE, A CHAIR, PEN, TABLE, KEYBOARD, BIKE, ETC. IT CAN BE PHYSICAL OR LOGICAL. THE ONLY NECESSARY THING IS THE TYPE OF MESSAGE ACCEPTED AND THE TYPE OF RESPONSE RETURNED BY THE OBJECTS. EXAMPLE: A DOG IDENTITY (NAME OF DOG)IS AN OBJECT BECAUSE IT HAS STATES/ATTRIBUTES LIKE AGE, COLOR, NAME, BREED, ETC. AS WELL AS BEHAVIORS LIKE SLEEPING, WAGGING THE TAIL, BARKING, EATING, ETC. Source: https://www.javatpoint.com/java-oops-concepts OBJECTS CONTAINS THE FOLLOWING PARTS: STATE : IT IS REPRESENTED BY ATTRIBUTES OF AN OBJECT. IT ALSO REFLECTS THE PROPERTIES OF AN OBJECT. BEHAVIOR : IT IS REPRESENTED BY METHODS OF AN OBJECT. IT ALSO REFLECTS THE RESPONSE OF AN OBJECT WITH OTHER OBJECTS. IDENTITY : IT GIVES A UNIQUE NAME TO AN OBJECT AND ENABLES ONE OBJECT TO INTERACT WITH OTHER OBJECTS. Source: https://www.javatpoint.com/java-oops-concepts CLASS COLLECTION OF OBJECTS IS CALLED CLASS. IT IS A LOGICAL ENTITY. A CLASS CAN ALSO BE DEFINED AS A BLUEPRINT FROM WHICH YOU CAN CREATE AN INDIVIDUAL OBJECT. CLASS DOESN'T CONSUME ANY SPACE. Source: https://www.javatpoint.com/java-oops-concepts CLASS EXAMPLE: IN THE IMAGE, THERE ARE THREE INSTANCES: POLO, MINI, AND BEETLE. HERE, WE WILL MAKE A NEW CLASS CALLED CAR, THAT WILL STRUCTURE A CAR OBJECT TO CONTAIN INFORMATION ABOUT THE CAR’S MODEL, THE COLOR, HOW MANY PASSENGERS IT CAN HOLD, ITS SPEED, ETC. A CLASS CAN DEFINE TYPES OF OPERATIONS, OR METHODS, THAT CAN BE PERFORMED ON A CAR OBJECT. FOR EXAMPLE, THE CAR CLASS MIGHT SPECIFY AN ACCELERATE METHOD, WHICH WOULD UPDATE THE SPEED ATTRIBUTE OF THE CAR OBJECT. Source: https://towardsdatascience.com/object-oriented-programming-and-the-magic-of-test- driven-development-d377acae85fa Source: https://www.javatpoint.com/java-oops-concepts INHERITANCE WHEN ONE OBJECT ACQUIRES ALL THE PROPERTIES AND BEHAVIORS OF A PARENT OBJECT, IT IS KNOWN AS INHERITANCE. IT PROVIDES CODE REUSABILITY. IT IS USED TO ACHIEVE RUNTIME POLYMORPHISM. Source: https://www.javatpoint.com/java-oops-concepts TYPES OF INHERITANCE SINGLE INHERITANCE : IN SINGLE INHERITANCE, SUBCLASSES INHERIT THE FEATURES OF ONE SUPERCLASS. IN THE IMAGE, THE CLASS A SERVES AS A BASE CLASS FOR THE DERIVED CLASS B. Source: https://www.geeksforgeeks.org/inheritance-in-java/ Source: https://www.javatpoint.com/java-oops-concepts TYPES OF INHERITANCE MULTILEVEL INHERITANCE : IN MULTILEVEL INHERITANCE, A DERIVED CLASS WILL BE INHERITING A BASE CLASS AND AS WELL AS THE DERIVED CLASS ALSO ACT AS THE BASE CLASS TO OTHER CLASS. IN THE IMAGE, THE CLASS A SERVES AS A BASE CLASS FOR THE DERIVED CLASS B, WHICH IN TURN SERVES AS A BASE CLASS FOR THE DERIVED CLASS C. IN JAVA, A CLASS CANNOT DIRECTLY Source: https://www.geeksforgeeks.org/inheritance-in-java/ ACCESS THE GRANDPARENT’S MEMBERS. Source: https://www.javatpoint.com/java-oops-concepts TYPES OF INHERITANCE HIERARCHICAL INHERITANCE : IN HIERARCHICAL INHERITANCE, ONE CLASS SERVES AS A SUPERCLASS (BASE CLASS) FOR MORE THAN ONE SUB CLASS. IN THE IMAGE, THE CLASS Source: https://www.geeksforgeeks.org/inheritance-in-java/ A SERVES AS A BASE CLASS FOR THE DERIVED CLASS B,C AND D. Source: https://www.javatpoint.com/java-oops-concepts POLYMORPHISM IF ONE TASK IS PERFORMED IN DIFFERENT WAYS, IT IS KNOWN AS POLYMORPHISM. FOR EXAMPLE: TO CONVINCE THE CUSTOMER DIFFERENTLY, TO DRAW SOMETHING, FOR EXAMPLE, SHAPE, TRIANGLE, RECTANGLE, ETC. IN JAVA, WE USE METHOD OVERLOADING AND METHOD OVERRIDING TO ACHIEVE POLYMORPHISM. ANOTHER EXAMPLE CAN BE TO SPEAK SOMETHING; FOR EXAMPLE, A CAT SPEAKS MEOW, DOG BARKS WOOF, ETC. Source: https://www.javatpoint.com/java-oops-concepts ABSTRACTION HIDING INTERNAL DETAILS AND SHOWING FUNCTIONALITY IS KNOWN AS ABSTRACTION. FOR EXAMPLE PHONE CALL, WE DON'T KNOW THE INTERNAL PROCESSING. IN JAVA, WE USE ABSTRACT CLASS AND INTERFACE TO ACHIEVE ABSTRACTION. Source: https://www.javatpoint.com/java-oops-concepts ENCAPSULATION BINDING (OR WRAPPING) CODE AND DATA TOGETHER INTO A SINGLE UNIT ARE KNOWN AS ENCAPSULATION. FOR EXAMPLE, A CAPSULE, IT IS WRAPPED WITH Source: DIFFERENT MEDICINES. https://www.geeksforgeeks.org/encaps ulation-in-java/ A JAVA CLASS IS THE EXAMPLE OF ENCAPSULATION. JAVA BEAN IS THE FULLY ENCAPSULATED CLASS BECAUSE ALL THE DATA MEMBERS ARE PRIVATE HERE. Source: https://www.javatpoint.com/java-oops-concepts ADVANTAGE OF OOPS OVER PROCEDURE-ORIENTED PROGRAMMING LANGUAGE 1) OOPS MAKES DEVELOPMENT AND MAINTENANCE EASIER, WHEREAS, IN A PROCEDURE-ORIENTED PROGRAMMING LANGUAGE, IT IS NOT EASY TO MANAGE IF CODE GROWS AS PROJECT SIZE INCREASES. 2) OOPS PROVIDES DATA HIDING, WHEREAS, IN A PROCEDURE-ORIENTED PROGRAMMING LANGUAGE, GLOBAL DATA CAN BE ACCESSED FROM ANYWHERE. 3) OOPS PROVIDES THE ABILITY TO SIMULATE REAL-WORLD EVENT MUCH MORE EFFECTIVELY. WE CAN PROVIDE THE SOLUTION OF REAL WORD PROBLEM IF WE ARE USING THE OBJECT-ORIENTED PROGRAMMING LANGUAGE. Source: https://www.javatpoint.com/java-oops-concepts WHAT IS THE DIFFERENCE BETWEEN AN OBJECT- ORIENTED PROGRAMMING LANGUAGE AND OBJECT- BASED PROGRAMMING LANGUAGE? OBJECT-BASED PROGRAMMING LANGUAGE FOLLOWS ALL THE FEATURES OF OOPS EXCEPT INHERITANCE. JAVASCRIPT AND VBSCRIPT ARE EXAMPLES OF OBJECT- BASED PROGRAMMING LANGUAGES. Source: https://www.javatpoint.com/java-oops-concepts

Use Quizgecko on...
Browser
Browser