1.4-Software-Development-Principles

Terminologies

As a software designer you will spend a lot of time in which you discuss the project with others. That is why we need to have a certain set of common terms that everyone can use and understand. We will define a number of the most important common terms:

Statement

Definition: In programming, a statement is a complete instruction that performs some action. It can be an assignment, a function call, a control structure, etc.
Example:

int a = 5; // This is an assignment statement.
System.out.println(a); // This is a statement calling a function.

Expression

Definition: An expression is a combination of values, variables, and operators that is evaluated to a single value and type.
Example:

int sum = a + b; // 'a + b' is an expression that results in the sum of a and b.
boolean isEven = (a % 2 == 0); // '(a % 2 == 0)' is an expression resulting in a boolean value.

Condition

Definition: A condition is an expression that evaluates to a boolean value (true or false). It’s typically used in control flow statements like if-else, while, and for loops.
Example:


if (a > b) {
    // This is a condition that checks if 'a' is greater than 'b'.
}

State

Definition: In programming, the state refers to the status of an object or an application at any given moment. It’s determined by the values of its attributes (or porperties of the Objects) or variables at that time.
Example:

public class LightBulb {
    boolean isOn; // The state of the lightbulb, either on or off.

    public void turnOn() {
        isOn = true; // Changing the state of the lightbulb to on.
    }
}

Declaration and Definition

Definition: Declaring a variable means stating its type and name, so that the program knows about its existence and the kind of data it will hold.
Example:

int number; // Declaration of a variable named 'number' of type int.

Definition: Defining a variable means allocating memory for it and optionally initializing it with a value.
Example:

number = 10; // Definition of the variable 'number', assigning it a value.

In some languages, declaration and definition can happen simultaneously, but understanding the distinction is crucial for understanding how languages manage memory and scope.

Method Signatures

Definition: The combination of return type and argument types of a method. The name of the method doesn’t matter. Example:

int example(int a, int b); // Declaration of a method that accepts two integers and returns an integer.

String anotherExample(int q); // Declaration of a method that accepts an integer and returns a String.

Remember: Two overloaded methods cannot share the same signature.

void print(int number); // Method 1
void print(String text); // Method 2

void print(int anDifferentNumber); // Not allowed: signature matches method 1.