Docsity

Information and Communications Technology, Study notes of Information and Communications Technology (ICT)

Toggle sidebar
bg1
PROGRAMMING BASICS
Machine Languages
- they are machine dependent
- language that is directly understood by a
computer's CPU
- consists of binary code (sequence of 0s
and 1s)
Instructions and Data
Mnemonics
- help us to remember things by
remembering short rhymes
Assembly Languages
- a human-readable representation of
machine code (binary)
Assembler
- a tool or software program used to
convert human-readable assembly
language code into machine language
- uses mnemonics and symbols to
represent CPU instructions and memory
addresses
- what programmers use
PROGRAMMING LANGUAGES
English-like language
Compiler VS Interpreter
Compiler
- translates the entire source code program
into machine code or an intermediate
form before execution
- machine code can be executed multiple
times without the need for recompilation
(faster execution times)
- early error detection
- C, C++, Java, Rust
Interpreter
- translates and executes the source code
line by line or statement by statement
- reads, translates, and executes the code
sequentially
- can detect errors in the code as they
occur but may stop execution at the first
encountered error
- Python, Ruby, JavaScript
High-level Languages
- easier for programmers to write code that
is more readable, understandable, and
maintainable
- abstract away many of the complexities of
computer hardware, such as memory
management and CPU operations
- use human-readable syntax with
meaningful keywords and symbols
- portable, meaning it can run on different
computer platforms with minimal or no
modification
- built-in functions, libraries, and tools
- features that help prevent common
programming errors, such as type
checking, bounds checking, and
automatic memory management (e.g.,
garbage collection)
DEBUGGING
Types of Errors
1. Syntax Error
- when the code violates the rules of the
programming language's syntax
- typographical mistakes, missing or
misplaced punctuation, incorrect keyword
usage, etc.
- ex: forgetting to close a parenthesis,
misspelling a variable name, or using an
incorrect operator
2. Run-time Error
- typically caused by unexpected
conditions or inputs that the program
cannot handle
- division by zero, attempting to access an
out-of-bounds array index, using a
variable before it's initialized, etc.
- detected when the program is executed
(program termination or the generation of
error messages)
- ex: trying to open a file that doesn't exist
or attempting to divide by zero
3. Logic Error
- when the code's logic or algorithm is
incorrect, leading to unintended or
incorrect behavior
- result of mistakes in the program's design
or algorithm
- can be challenging because the code
runs without error messages
- code inspection, testing, and logic
analysis are used to identify and correct
logic errors
- ex: an incorrect formula for calculating the
area of a circle, leading to incorrect
results
OOP CONCEPTS
Class
- blueprint or template for creating objects
- defines a set of state/attributes and
methods (functions) that characterize the
objects created from the class
- encapsulate the common properties and
behaviors that objects of a certain type
share
- ex: "Car" class that defines the attributes
(color, make, model) and methods (start,
stop, accelerate)
pf3
pf4

Partial preview of the text

Download Information and Communications Technology and more Study notes Information and Communications Technology (ICT) in PDF only on Docsity!

PROGRAMMING BASICS

Machine Languages

  • they are machine dependent
  • language that is directly understood by a computer's CPU
  • consists of binary code (sequence of 0s and 1s) Instructions and Data Mnemonics
  • help us to remember things by remembering short rhymes Assembly Languages
  • a human-readable representation of machine code (binary) Assembler
  • a tool or software program used to convert human-readable assembly language code into machine language
  • uses mnemonics and symbols to represent CPU instructions and memory addresses
  • what programmers use PROGRAMMING LANGUAGES English-like language Compiler VS Interpreter Compiler
  • translates the entire source code program into machine code or an intermediate form before execution
  • machine code can be executed multiple times without the need for recompilation (faster execution times)
  • early error detection
  • C, C++, Java, Rust Interpreter
  • translates and executes the source code line by line or statement by statement
  • reads, translates, and executes the code sequentially
  • can detect errors in the code as they occur but may stop execution at the first encountered error
  • Python, Ruby, JavaScript High-level Languages
  • easier for programmers to write code that is more readable, understandable, and maintainable
  • abstract away many of the complexities of computer hardware, such as memory management and CPU operations
  • use human-readable syntax with meaningful keywords and symbols
  • portable, meaning it can run on different computer platforms with minimal or no modification
  • built-in functions, libraries, and tools
  • features that help prevent common programming errors, such as type checking, bounds checking, and automatic memory management (e.g., garbage collection) DEBUGGING Types of Errors
  1. Syntax Error
  • when the code violates the rules of the programming language's syntax
  • typographical mistakes, missing or misplaced punctuation, incorrect keyword usage, etc.
  • ex: forgetting to close a parenthesis, misspelling a variable name, or using an incorrect operator
  1. Run-time Error
  • typically caused by unexpected conditions or inputs that the program cannot handle
  • division by zero, attempting to access an out-of-bounds array index, using a variable before it's initialized, etc.
  • detected when the program is executed (program termination or the generation of error messages)
  • ex: trying to open a file that doesn't exist or attempting to divide by zero
  1. Logic Error
  • when the code's logic or algorithm is incorrect, leading to unintended or incorrect behavior
  • result of mistakes in the program's design or algorithm
  • can be challenging because the code runs without error messages
  • code inspection, testing, and logic analysis are used to identify and correct logic errors
  • ex: an incorrect formula for calculating the area of a circle, leading to incorrect results OOP CONCEPTS Class
  • blueprint or template for creating objects
  • defines a set of state/attributes and methods (functions) that characterize the objects created from the class
  • encapsulate the common properties and behaviors that objects of a certain type share
  • ex: "Car" class that defines the attributes (color, make, model) and methods (start, stop, accelerate)

Object

  • instance of a class
  • a concrete realization of the class's blueprint, with its own unique state (data) and behavior (methods)
  • encapsulate data (attributes) and provide methods to interact with and manipulate that data State
  • values of its attributes (data members)
  • characteristics or properties that describe the object Behavior
  • actions or operations that objects of a class can perform
  • actions are defined as methods in the class and allow objects to interact with their own data or with other objects
  • functionality A GLIMPSE OF JAVA Java
  • 1991, James Gosling at Sun Microsystems (now owned by Oracle Corporation)
  • initially called "Oak" but was later renamed "Java" for trademark reasons Java 1.
  • beginning of Java's journey as a programming language for building platform-independent, "write once, run anywhere" applications
  • Oracle open-sourced the Java platform through the OpenJDK project, allowing the community to participate in its development and fostering compatibility with other open-source projects and distributions Embedded Software/Systems
  • computer programs and hardware systems designed to perform specific tasks within larger devices or system  consumer electronics devices = smart TVs and Blu-ray players, use Java for their embedded software, allowing for cross-platform applications and interactivity  run on small, secure microcontrollers embedded in smart cards (for secure access control, payment systems, and other applications)  gaming consoles (Sony PlayStation) for certain aspects of their user interfaces and applications  medical devices = used for user interfaces and communication with external systems, such as electronic health record (EHR) systems  routers and networking equipment = for management interfaces and custom plugin systems JDK
  • Java Development Kit
  • March 21, 2023 from Oracle
  • Java 20 is the latest upgrade of standard Java
  • releases = incubator features that are not fully mature yet, or preview versions of various capabilities, including virtual threads and structured concurrency Characteristics of Java
  1. Platform Independent
  • write once, run anywhere
  • source code is first compiled into an intermediate representation called bytecode (not specific to any particular hardware or OS)
  • programs do not run directly on the host machine's hardware (they run on Java Virtual Machine (JVM))
  • provides a standard library with pre-built classes and functions for common tasks which are consistent among platforms
  1. Simple
  • has clean and readable syntax
  • takes care of memory management through automatic garbage collection (no manual allocation)
  • provides a comprehensive standard library
  • follows a strict OOP model (code organization and reuse through the use of classes and objects)
  • no pointers (errors: dereferencing null or invalid memory addresses)
  1. Object-oriented
  2. Robust
  • reliable
  • typed language so variables type checked
  • automatic memory management (cleans objects not in use)
  • prevent null pointer exceptions
  • array bounds checking
  • features like access controls for class for extra security
  • standard library = pre-built classes and functions for common tasks
  • compatibility = existing code continues to work with newer versions of the language
  • mechanism that combines data & operations in single unit Interface
  • collection of methods (empty methods)
  • defines a contract of methods that a class implementing the interface must provide
  • define a common set of methods that multiple classes can adhere to
  • declares a set of method signatures (method names, return types, and parameters) that classes implementing the interface must provide Packages
  • way of grouping related classes
  • a mechanism for organizing and structuring classes and interfaces into namespaces
  • provide a hierarchical structure to the Java codebase
  • classes within a package have access to one another without needing to use explicit access modifiers java.io
  • import java.io.BufferedReader
  • Java Input/Output
  • input and output operations, such as reading and writing files, streams, and serialization
  • ex: File, InputStream, OutputStream, Reader, Writer, BufferedReader, BufferedWriter, etc. java.util
  • import java.util.Scanner
  • contains utility classes and data structures
  • collections, data manipulation tools, date and time handling, and other general- purpose utilities
  • used for working with collections (lists, maps, sets), managing dates and times, and performing common utility operations
  • ex: ArrayList, HashMap, HashSet, Date, Calendar, Collections, Arrays, Random, etc. javax.swing
  • import javax.swing.Frame
  • part of the Swing framework, which is Java's GUI toolkit
  • provides a rich set of GUI components and classes for creating desktop applications with graphical user interfaces
  • including windows, dialogs, buttons, text fields, and other UI components
  • ex: JFrame, JPanel, JButton, JTextField, JTable, JComboBox, etc. java.lang
  • a special package that is implicitly imported in all Java programs
  • contains fundamental classes and core language features that are essential to the Java language itself
  • provides classes and features that are fundamental to Java, including the root Object class, primitive data types, basic exception handling, multi-threading support, and system-related operations
  • ex: Object, String, Integer, Boolean, Math, Exception, Thread, System, etc. DATA TYPES IN JAVA Primitive Type
  • its values are simple, indecomposable values, such as a single letter or a single number
  • begins with a lowercase letter
  • ex: int, double, char, float  boolean = true or false  char = single character  byte = integer  short = integer  int = integer  long = integer  float = decimal numbers  double = decimal numbers Class Type
  • a type for objects with both data and methods
  • begins with an uppercase letter
  • ex: Integer, Double, Float, String…. and classes that YOU create yourself Identifiers
  • includes name of a variable, name of a class, a method or an object Rules for Naming Identifiers
  1. may contain letters, digits, underscore (_) or dollar sign ($)
  2. may not begin with a digit
  3. cannot contain punctuation marks, math symbols, or other special symbols
  4. no limit to the length of the name
  5. words with predefined meaning cannot be used as identifiers