Lecture 3
Decomposition
1. Definition
o Decomposition involves breaking down complex problems into
smaller, manageable parts. This makes it easier to understand,
solve, and implement solutions.
Example:
2. Importance in Programming
o Decomposition allows for better organization of code, making it
modular and easier to debug. Each smaller problem can be solved
independently, contributing to the overall solution.
Functions in Programming
1. Definition and Purpose
o Functions are named blocks of code designed to perform a specific
task. They enhance code reusability and help in organizing complex
programs into smaller, manageable parts.
Example:
, 2. Types of Functions
o Instance Methods: Tied to a specific instance of a class, typically
used to manipulate instance data.
o Static Methods: Bound to the class itself and cannot modify object
state. They are used when a method logically belongs to the class
but does not need to access or modify class instances.
Examples:
3. Function Parameters and Arguments
o Function parameters are the variables listed in the function
definition. Arguments are the values passed to the function when it
is called.
Example: