Basics Of Oops | Development | Online Course With Appy Pie Academy

Basics of OOPs

Lesson Details:
June 29, 2020


I: Introduction

A: Writing an outline is the first step towards writing a good article. The introduction section of an article should be captivating and attention-grabbing. The introduction should provide basic information about the topic being discussed in the article. It should capture the reader’s attention and interest making him or her want to read on.

The introduction of an article is the first thing that the reader reads. This means that it is important for the writer to make the introduction as appealing as possible.

Tips for writing an effective introduction:

A: Begin with a statement that attracts attention. For example, ‘what do you think of when you hear the word software?’ directly engages the reader’s attention.

B: Establish your position by outlining your stance on the issue. If you are writing an argumentative article, for example, this means stating your opinion or stance on the issue. However, if your article is descriptive, explain what the topic is. For example, if you are writing about software engineering, explain what software engineering is.

C: Use phrases like ‘in this article’ or ‘during this paper’ so that the reader knows that there is more to come.

D: Close with a sentence that invites the reader to continue reading. This may be a thought-provoking question or a statement that invites questions from the reader.

II: Body

A: Basics of oops programming involve classes, objects, variables, functions and methods.

Object-oriented programming (oop) is a computer programming paradigm based on the concept of objects. A programmer who is well versed in oop can easily code software which is modular and easy to maintain and update later. In addition, programmer friendly languages such as Python support oop as their default programming paradigm. In other words, by using Python as a programming language, you can take advantage of oop without having to worry about extra steps such as compiling your programs into machine code first before running them. In fact, instead of compiling your programs into machine code, Python converts your programs into bytecode first before running them. Python’s support for oop makes it a very powerful programming language because it allows programmers to model their real-world scenarios in a way that is more appropriate for computers. By doing so, programmers can create modular programs that are easier to maintain and update later compared to non-modular programs where everything is interdependent on each other.

B: OOP also supports encapsulation which means that it allows programmers to hide or protect certain elements of a program from being accessed or modified by other parts of the program. To understand how encapsulation works, let’s say you have a program where a character named John wants to find his friend Tom by going to a restaurant called Pizza Hut. The following statements could be used in a non-oop language such as Java:

1) John walks into Pizza Hut; 2) John sees that Tom is sitting at a table; 3) John sits next to Tom; 4) John says “Hi Tom! How are you?; 5) Tom answers “Hello John! I am fine; 6) John asks Tom if he wants to go home; 7) Tom answers “No thanks; 8) John asks Tom if he wants pizza; 9) Tom answers “Yes I do; 10) John orders two pizzas; 11) John pays for the pizzas; 12) John and Tom eat pizza

In the above example, we see that the program only runs properly if both John and Tom are present in the same place at the same time because one part of the program depends on another part of the program to work properly. This is not ideal because if either John or Tom wants to go home after eating pizza together, they will have to leave earlier than expected and this will cause problems for both parties involved. In addition, if John and Tom finish eating pizza and want to do something else together but John wants to order two pizzas by himself instead of sharing with Tom, the program will not run properly because it will depend on John ordering two pizzas so that Tom can eat together with him. This makes it difficult for programmers to use non-oop languages such as Java to build programs that model real-world scenarios more closely than non-oop languages allow programmers to do so. However, in an oop language such as Python, programmers can protect certain elements of their program from being accessed or modified by other parts of their program. For example, in Python, programmers can use Python’s class statement to create a class called PizzaOrder which will contain an attribute called pizas_number which stores the number of pizzas ordered by each customer. The class PizzaOrder can then be used in another class called PizzaCustomer which contains attributes like name, address and pizas_number. This way, if another part of the program (called customer_service in this example) needs to know how many pizzas each customer has ordered after delivery, it has access only to this attribute contained in PizzaCustomer instead of having access to all attributes contained in PizzaOrder since this information is hidden or protected by PizzaOrder itself. This capability makes it safer for programmers to use oop languages like Python to model real-world scenarios more closely than non-oop languages like Java do not allow programmers to do so safely yet.

C: Another feature of oop supported by programming languages such as Python is polymorphism which means that different forms of an object can behave differently even though they have equal rights to execute the features supported by the object class itself. Python supports polymorphism through inheritance which allows developers to create new classes based on one or more existing classes already defined in an existing object library called Python Standard Library which comes preinstalled with every copy of Python installed on any computer system running Python version 2 or higher including Windows operating systems running both 32 bit and 64 bit versions of Windows XP, Vista, 7 and 8 along with Mac OS X 10.5 or higher along with Linux operating systems running Ubuntu 12.04 LTS along with other Linux derivatives except for Raspbian Linux derived from Debian Linux version 6.0 Squeeze released on 6/13/2012 . For example, let’s assume that we have built a class in our object library called Customer in our object library called Person in our object library called ObjectLibrary . Now, let’s assume that we want to create another class called PersonMarriage which inherits from class Person in our object library called ObjectLibrary . The following statements can be used in our program file called PersonMarriageClassDemoProgram .py in order to create class PersonMarriage :

1) import ObjectLibrary; 2) 3) class PersonMarriage(Person): 4) 5) def __init__(self, name): 6) 7) self._name = name 8) 9) def get_name(self): 10) 11) return self._name 12) 13) class PersonMarriage(Person): 14) 15) def get_age(self): 16) 17) return self._age 18) 19) def set_age(self, age): 20) 21) self._age = age 22) 23) def get_weight(self): 24) 25) return self._weight 26) 27) def set_weight(self, weight): 28) 29) self._weight = weight 30) 31) def get_height(self): 32) 33) return self._height 34) 35) def set_height(self, height): 36) 37) self._height = height 38) 39) def get_eye_color(self): 40) 41) return self._eye_color 42) 43) def set_eye_color(self, eye_color): 44) 45) self._eye_color = eye_color 46) 47) def get_hair_color(self): 48) 49) return self._hair_color 50) 51) def set_hair_color(self, hair_color): 52) 53) self._hair_color = hair_color 54) 55) class PersonMarriage(Person): 56) 57) def get_foods(self): 58) 59) return [‘hamburger’] 60) 61) def get_dietary_preference(self): 62) 63) return [‘vegetarian’] 64) 65) 66) 67) 68) 69) 70) 71 ) 72 ) 73 ) 74 ) 75 ) 76 ) 77 ) 78 ) 79 ) 80 ) 81 ) 82 ) 83 ) 84 ) 85 ) 86 ) 87 ) 88 ) 89 ) 90 ) 91 ) 92

loader
Course content