summaryrefslogtreecommitdiff
path: root/tutorials/module_1/classes_and_objects.md
diff options
context:
space:
mode:
Diffstat (limited to 'tutorials/module_1/classes_and_objects.md')
-rw-r--r--tutorials/module_1/classes_and_objects.md33
1 files changed, 32 insertions, 1 deletions
diff --git a/tutorials/module_1/classes_and_objects.md b/tutorials/module_1/classes_and_objects.md
index 759a3a3..ba1dab9 100644
--- a/tutorials/module_1/classes_and_objects.md
+++ b/tutorials/module_1/classes_and_objects.md
@@ -42,6 +42,31 @@
- D. Bonus: Integrate two objects to simulate interaction
---
+# Background
+To understand what modular programming is and why using it, let's take a look a the origin of computer code.
+# Traditional Programming
+Procedural Oriented Programming.
+
+| OOP | POP |
+| ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
+| [Object oriented](https://www.geeksforgeeks.org/dsa/introduction-of-object-oriented-programming/). | [Structure oriented](https://www.geeksforgeeks.org/computer-networks/difference-between-structured-programming-and-object-oriented-programming/). |
+| Program is divided into objects. | Program is divided into functions. |
+| Bottom-up approach. | Top-down approach. |
+| Inheritance property is used. | Inheritance is not allowed. |
+| Encapsulation is used to hide the data. | No data hiding. |
+| Concept of virtual function. | No virtual function. |
+| Object functions are linked through message passing. | Parts of program are linked through parameter passing. |
+| Adding new data and functions is easy | Expanding new data and functions is not easy. |
+| The existing code can be reused. | No code reusability. |
+| use for solving big problems. | Not suitable for solving big problems. |
+| Python, [C++](https://www.geeksforgeeks.org/cpp/c-plus-plus/), [Java](https://www.geeksforgeeks.org/java/java/). | [C](https://www.geeksforgeeks.org/c/c-programming-language/), Pascal. |
+
+
+https://www.geeksforgeeks.org/cpp/difference-between-oop-and-pop/
+## POP vs. OOP
+
+
+
# Modular Programming
Modular programming or better known as Object-Oriented Programming (OOP) is a way we can structure programs so that properties and behaviors of objects are grouped together. It allows us to re-use code which simplifies the code for better readability in larger programs and reduces the potential for bugs. You're probably familiar with the saying "Don't re-invent the wheel". OOP is the programmers solution to this. Python allows us to import libraries so that we don't have to write everything from scratch. The libraries used in this course provide us with algorithms to calculate a solution, structure data and plot data. When looking at the source code of these library you may see keywords, such as `class`. This tutorial will delve into the fundamental concepts of OOP.
@@ -51,6 +76,10 @@ One analogy for OOP goes as follows. Imagine you are an urban planner in the tow
#### Objects
Once we have the general structure of what a house is going to look like, we can use this blueprint to start building houses faster. With this blueprint defined. We can start building houses from the blueprint. In python we call this *initializing objects*. Where an actual house built from this blueprint with specific attributes (e.g. house #305, blue house, single-hung window, attached garage) is referred to as an `object`.
+>[!NOTE] Difference between functions and objects
+> **Functions:** A procedure. Such as a force.
+> **Objects:** Include properties. Such as a spring, with a defined spring constant.
+
#### Example
Let's take a look at an example. Of how this looks like in python. Do not worry if you don't understand the syntax below, we will explain this later. Let's define the class:
```python
@@ -270,4 +299,6 @@ Notice how the `__init__` method defaults the inputs`breed="Mixed"` and `age=1`
```python
-``` \ No newline at end of file
+```
+
+https://eng.libretexts.org/Courses/Arkansas_Tech_University/Engineering_Modeling_and_Analysis_with_Python/01%3A_Introduction_to_Engineering_Modeling_and_Analysis_with_Python \ No newline at end of file