Fundamentals of Computer Programming
Topic 1: Introduction to Computers
Computer: A collection of scientific knowledge, techniques, and technologies enabling automatic data processing.
Computer System: A system processing information through interrelated entities: hardware (processor), software (program), and peopleware (user).
Item 2: Programming and Languages
Software: A set of instructions directing the computer precisely and accurately.
Programs are not intelligent, lack initiative, imagination, and inventiveness.
Model: A simplified representation of reality, focusing on essential aspects.
Programming Language:
Based on Abstraction Level:
- Machine language
- Assembly language
- High-level language (e.g., C, C++)
- 4G Language (e.g., SQL)
- Component-based languages (e.g., NesC)
- Modeling language
Programming Style:
- Declarative (e.g., Prolog, LISP)
- Imperative (e.g., C, Java, C++)
Translation Process:
- Compilers
- Interpreters
Components of a Programming Language:
Syntax: Vocabulary and writing rules.
Semantics: Meaning of the written code.
Program Errors:
Systematic and orderly coding reduces semantic errors.
Design before coding is crucial.
Types of Errors:
- Compile-time errors (syntax errors)
- Runtime errors
- Non-programmer errors
- Bugs (programmer’s fault)
- Java’s exception mechanism
Algorithms: Optimal procedures for problem-solving.
Algorithm: A recipe for solving a problem.
Efficiency: Optimal task performance, measured by orders.
Effective: An algorithm correctly solves the intended problem.
Software Engineering: Principles and techniques for software development.
Analysis: Requirements capture and analysis (functional and non-functional).
Design: Creating various designs for client selection.
Implementation: Encoding the design.
Testing (V&V): Validation and verification.
Software Maintenance (80%):
- Extensions and upgrades (10%)
- Troubleshooting and error correction (60%)
- Periodic testing (30%)
Item 3: Introduction to Programming
Item 4: Structured Programming
Principles:
- A program is a sequence of instructions.
- Stacking Principle: Actions can be replaced by sequential actions.
- Nesting Principle: Actions can be replaced by control structures (sequence, selection, iteration).
All control structures have a single entry and exit point.
Item 5: Procedural and Data Abstraction
Structured Programming: (Item 4)
Modular Programming: “Divide and conquer” principle.
Benefits of Modular Programming:
- Algorithmic Encapsulation: Modules as operators with input and output parameters.
- Procedural Abstraction: Reusable modules (black boxes).
Java Methods: Modules in Java.
Java Class Types:
- Class
- School Library
- Bookstore-static methods
- Classes modeling objects
Method Input Parameters:
- Formal parameters (definition)
- Actual parameters (invocation)
- Passing arguments by value (Java)
Overloading: Multiple methods with the same name but different signatures.
Method Signature: Name + parameter list.
Method Identifier: Signature + return type.
Abstraction:
- Control abstraction (loops)
- Procedural abstraction (methods)
- Data abstraction (tables, classes)
Abstract Data Type (ADT): Template defining structure and behavior.
Wrapper Classes: Objects for primitive data types.
Non-static Methods: Run on request.
Static Methods: Run on classes.
Item 6: Recursion vs. Iteration
Recursion: A function calling itself.
Recursion vs. Iteration:
- Both perform repetition.
- Both have termination conditions.
- Both must converge to a solution.
Any recursive solution can be converted to an iterative one, but not always vice versa.
Theory of the 2nd Semester
- Encapsulation in Development Time: Defining class data and methods.
- Runtime Encapsulation: Objects as black boxes with services.
- Interface Definition: Collection of constants and abstract methods.
- Abstraction: Levels of abstraction in classes.
- Class Relationships: Is-a, association, unit.
- Generalization (Is-a): Inheritance relationship.
- Association: Class composition using objects.
- Unit: State change dependency.
- Constructor: Methods for object creation.
- References: Pointers to objects.
- Modifiers: Visibility, final, static.
- OOP Features: Encapsulation, inheritance, polymorphism.
- Polymorphism: Referencing objects of related classes.
- Utility of Abstraction: Forcing implementation in child classes.
- Exceptions: Checked and unchecked.
- Frameworks: Reusable application structures.
- Binary Trees: Node structures with root and descendants.