COMP1000 Week 7

Unit Representatives

  • Nergis Ruzai is a unit representative for COMM1000.
  • Sasha and Terry are also representatives.
  • They collect confidential feedback.

Unit Convener

  • Ansgar is the unit convener.
  • Shavanya is away for a few weeks.

Unit Aim: Introduction to Programming

  • Goal: To provide enough programming knowledge for practical application.
  • Emphasis: Ease of learning with resources like rebound sessions and drop-in centers.

Core Programming Elements

  • Variables, if statements, and loops are essential for any programming language.

Modern Software Needs

  • Requires more than just loops, variables, and ifs.
  • Functions, objects, classes, and arrays for organizing larger programs.

Drop-in Center

  • Useful for students needing help.

Assessment Information

  • Second chance available for skills demonstration starting Wednesday.
  • Everyone can participate in the second round, no special consideration needed.
  • Access via iLearn.
  • The best attempt will be marked.

Functions

  • Key aspects: parameters and return type.
  • A named, reusable piece of code.

Function Components

  • Return type: Specifies the type of value the function computes.
  • Parameters: Inputs the function requires.
  • Return statement: Ends the function and returns a value.

Arguments vs. Parameters

  • Argument: Value passed into the function from the outside.
  • Parameter: The inside view of the input.

Function Example: bar(number)bar(number)

  • Takes a number, multiplies it by two, and returns the result.

Function Characteristics

  • Named piece of code.
  • Can be supplied with inputs.
  • Not all functions are void.

Local vs. Global Variables & Parameters

  • Parameters: What a function needs to know to do its job.
  • Local variables: Used for small, contained computations.
  • Global variables: Data shared across all parts of the program; use sparingly.

Objects and Classes

  • Objects: Components that encapsulate data (attributes) and behavior (methods).
  • Classes: Blueprints for creating objects.
  • Analogy: Class is the blueprint, object is the actual item made from it.

Object-Oriented Programming

  • Goal: To represent real-world entities (like a spaceship) as objects in code.

Core Concepts

  • Data and behavior are combined into reusable components.
  • Attributes: Variables that define the object's state.
  • Methods: Functions that define what the object can do.

Creating a Class

  • Use the class keyword followed by the class name.

Constructor

  • Special method that creates and initializes objects.

Dot Notation

  • Used to access an object's attributes and methods (e.g., Alice.display();).

Feature Envy

  • Avoid accessing an object's internal data directly from outside the object.
  • Use methods to interact with objects.

Encapsulation

  • Keep data and methods related to an object within the object itself.
  • Avoid external dependencies.