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:

  1. A program is a sequence of instructions.
  2. Stacking Principle: Actions can be replaced by sequential actions.
  3. 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:

  1. Algorithmic Encapsulation: Modules as operators with input and output parameters.
  2. 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:

  1. Both perform repetition.
  2. Both have termination conditions.
  3. 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

  1. Encapsulation in Development Time: Defining class data and methods.
  2. Runtime Encapsulation: Objects as black boxes with services.
  3. Interface Definition: Collection of constants and abstract methods.
  4. Abstraction: Levels of abstraction in classes.
  5. Class Relationships: Is-a, association, unit.
  6. Generalization (Is-a): Inheritance relationship.
  7. Association: Class composition using objects.
  8. Unit: State change dependency.
  9. Constructor: Methods for object creation.
  10. References: Pointers to objects.
  11. Modifiers: Visibility, final, static.
  12. OOP Features: Encapsulation, inheritance, polymorphism.
  13. Polymorphism: Referencing objects of related classes.
  14. Utility of Abstraction: Forcing implementation in child classes.
  15. Exceptions: Checked and unchecked.
  16. Frameworks: Reusable application structures.
  17. Binary Trees: Node structures with root and descendants.