Further Programming
Advanced programming paradigms and techniques.
Topics
- Functional Programming
- Object-Oriented Design
- Concurrent Programming
- Declarative Programming
Key terms
20.1 Programming paradigms
- Programming paradigm
- A style or approach to programming, such as imperative, object-oriented or declarative.
- Low-level programming
- Writing instructions that closely match the hardware, such as assembly language and machine code.
- Imperative programming
- Writing a sequence of statements that tell the computer exactly how to do the task, step by step.
- Object-oriented programming (OOP)
- Organising a program around objects that combine data (attributes) with the methods that work on it.
- Class
- A blueprint that defines the attributes and methods that its objects will have.
- Object
- An instance of a class, with its own values for the attributes.
- Attribute and method
- An attribute is a data item belonging to an object. A method is a subroutine belonging to its class.
- Constructor
- A special method that runs when an object is created, setting up its attributes.
- Encapsulation
- Bundling data and methods together and hiding the data, so it can only be changed through the class's methods.
- Inheritance
- A subclass takes on the attributes and methods of a superclass and can add or change its own.
- Polymorphism
- Objects of different classes can be used through the same interface, each responding in its own way.
- Overriding
- A subclass provides its own version of a method that it inherited.
- Declarative programming
- Stating what result is wanted, or the facts and rules, and letting the system work out how to get it. SQL and Prolog are examples.
- Logic programming
- Programming with facts and rules, then asking queries that the system answers by logical reasoning.
- Fact and rule
- In logic programming, a fact states something that is true. A rule says one thing is true if others are true.
- Functional programming
- Building programs from functions that avoid changing data, so the same input always gives the same output.
- Concurrent programming
- Writing programs in which several tasks make progress at the same time.
20.2 File processing and exception handling
- Binary file
- A file that stores data in its raw binary form rather than as readable text.
- Random file access
- Going straight to a record by its position, using commands such as SEEK, GETRECORD and PUTRECORD.
- Append mode
- Opening a file so that new data is added at the end without erasing what is already there.
- Exception
- An error that happens while a program is running, such as dividing by zero or a missing file.
- Exception handling
- Detecting runtime errors and responding to them so the program can carry on or end cleanly.
- TRY ... EXCEPT ... ENDTRY
- Puts code that might fail in a TRY block, with the code to run when it does in an EXCEPT block.
- FINALLY
- A block that runs whether or not an exception happened, often used to close a file.
Practice questions for Further Programming