1/38
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Backus-Naur Form (BNF)
is used to describe unambiguously syntax or grammar of a programming language
BNF number structire
Structure: <number> ::= 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0
BNF letter structure
Structure: <letter> ::= a | b | c ... x | y | z
BNF mutiples
Structure: <letters> ::= <letter> | <letters><letter>
Syntax Diagrams
They are used in a similar way to BNF but are a more visual representation.
High Level Languages
These are closer to English, use recognizable words
Low Level Languages
These are closer to internal workings of a computer, e.g. binary or short codes
Why use high-level language?
- Easier to understand, learn, and program as commands are more English-like.
- Identifiers can be long and meaningful
- They allow the use of powerful commands that perform quite complex tasks.
- Allows creation of modules that can be re-used and accessed by other parts of the program
Why use low-level languages?
- Ideal for critical execution speed, e.g. bootstrap loader
- More efficient than high-level language programs
- Require less time for translation into machine code
- Generally result in smaller executable programs
Applications requiring low level languages
i) Device Drivers: Low-level language must be used to directly access memory addressed to full control hardware.
ii) Embedded software: software that runs on simple devices using simple microprocessors, such as washing machines and microwaves, will need direct access to the hardware.
iii) Real-time software: simulators of ly-by-wire systems that require precise processing, timing, or accuracy could potentially benefit from using a low-level language.
iv) Assembly language can be produce more compact code which can be important when placing on a chip.
Types of Programming Languages
• Procedural
• Non-Procedural
• Object Oriented
• Event driven
• Visual
• Mark-up
Procedural Languages
i) They are used in traditional programming based on algorithms or a logical step-by-step process for solving algorithms
ii) They obeyed ordered instructions
iii) A procedural programming language provides the programmer a way to define precisely each step when performing a task
iv) Allows tight control over the underlying operation of the hardware
v) Used in (large complicated) programs where simlar operations may be carried out at varying stages of the program execution
Non-Procedural Language
i) They allow programmers to specify the results they want without specifying how to solve the problem.
ii) They are to do with rules / making queries / facts.
iii) They are used in database interrogation, where retrieving answers is more important than the exact steps required to calculate the result.
iv) Artificial intelligence, grammar checking, and language translation applications are often written in a non-procedural language.
Object Oriented Language / Programming (OOL/OOP)
i) Uses objects - include both data and associated processing
ii) Enables production of buttons/icons
iii) Uses features such as inheritance, encapsulation, etc
Advantanges of OOP
i) Improved productivity when devloping software due to the flexible and extendable nature of OOP
ii) Software is easier to maintain as OOP is modular and reusable.
iii) Development is faster due the reusable code and libraries
iv) Development is cheaper
v) Software can be tested more easily, making it more high quality
vi) Software is easier to design as model the real world
OOP - Disadvantages
i) OOP is difficult and not as 'logical' to some developers, it is complex to create application in OOP
ii) Software can become larger - more code than procedural programs
iii) OOP programs can run slower than PP as there is more code to execute.
iv) OOP cannot be used for all types of software application such as machine learning and AI.
v) OOP can be difficult to debug
Class (OOP)
It is a template or blueprint for a specific object. It defines an object's instance variables (attributes/properties) and behaviour (methods)
Object (OOP)
An instance of a class that when initiated it allocates memory for the defined attributes and methods of that class.
Method (OOP)
A method is a programmed behaviour/subroutine that is included in an object of a class. A method can only access data within its own object (encapsulation).
Inheritance (OOP)
i) Enables new objects to take on the properties of existing
objects
ii) Inheritance defines relationships between classes and organises classes into groups.
iii) Inheritance enables classes that are similar to existing classes to be created by indicating differences (rather than starting again) and thereby allows code to be organised and re-used effectively
Superclass (OOP)
Is used as the basis for inheritance.
Subclass (OOP)
It is a class that inherits from a superclass.
Abstraction (OOP)
Process of hiding non-essential features and showing essential features
By:
i Hiding complexity
ii Simplifying the interface
iii Facilitating easier use and understanding
Encapsulation (OOP)
It's the process of hiding implementation of a class and controlling access to its methods and attributes
Polymorphism (OOP)
is the characteristic of being able to assign a different meaning or usage to something in different contexts - specifically, to allow an entity such as a variable, a function, or an object to have more than one form.
Object Hierarchy (OOP)
It references descendants of objects acting as properties of an object
Event Driven Language
i) Used in situations relying on events
ii) Event could be triggered by input devices (on mouse click) or external sensors (e.g., pressure)
Event Driven Language concept
program will sit in a loop, waiting for the user to perform an action. When an action occurs, a function will run to process that action.
Visual Language
i) particularly suitable for production of objects / buttons/icons, etc
ii) particularly suitable for developing in a GUI/Windows/graphics content/event driven environment
iii) may be easier to learn / more intuitive because they are visual - there is very good help/tools available
Mark-up Languages
i) Mark-up languages use tags to specify the format of data Eg: HTML-Hypertext Markup Language
ii) The commands in HTML are called tags, are surrounded by chevrons. e.g., <h1>
iii) These can easily be written in any basic text editor.
iv) The tags are interpreted by the browser
when the page is displayed.
v) XML (eXtensible Mark-up Language) is another mark-up language that is commonly used in web applications.
vi) XML is used for structuring and marking-up data for storage rather than information for display.
vii)The developer is free to create their own tags and specify their own meaning to them.
viii)Mark-up languages are commonly combined with other languages, such as JavaScript with HTML.
Standardisation
Agreed standards in programming languages across different manufacturers
Ambiguity in natural language
Ambiguity in natural language means that a statement can be interpretd in more than one way.
This is difficult enough in English, but it makes it impossible for a computer to interpret.
Natural Language VS Computer Language
Natural language can be defined as the spoken and written words humans use to communicate with one another.
In natural language, words can be ambigious; one word can have more than one meaning.
An example of an ambigious word in English is 'break'.
Computer language syntax can be defined as the set of rules that a program statement must follow.
High-level compiter language syntax must be unambigious.
Each program statement must have a specific purpose.
If there was ambiguity in computer language syntax, it would be impossible to translate into machine code.
An example would be the statement 'break'. The break statement must force the program to leave only a construct and nothing else.
BIDMAS
Mathematical order of operations: brackets, indices, division/multiplication, addition/subtraction
What is a constructor?
A class constructor is a type of subroutine called to create an object. It is called automatically when an instance of a class is created and typically initializes the object's attributes.
What is a destructor?
It allows an object to clean up any memory allocated to it. It also released unmanged resources like file handles, and database connections.
Benefits of inheritance?
Simple and easy to reuse code
Efficient as unecessary repetition
Good as it eliminated code duplication
Benefits of encapsulation?
Protects objects from unwanted access
Reduces human errors
Simplifies maintenance
Makes the application easier to understand
Enhances security of data.
Benefits of polymorphism?
Inheritance – allows you to create a superclass with properties and methods that are general. This superclass becomes the abstract class, where objects are then only instantiated from the inherited subclasses. A sub class can access all properties and methods from the superclass, but will have its own unique set of properties and methods.
Method overloading – This occurs when multiple methods in the same class share the same name but have different parameter lists (different types, numbers, or both). E.g. a class might have a method called add(int a, int b), and another method add(double a, double b). The appropriate method is chosen at compile time based on the arguments passed.
Method overriding – This is where a sub class overrides a method that exists in the superclass. In this case the sub class will have the same method name, but will execute something different inside that method. The method in the sub class overrides the method in the superclass when it is called via the instantiated object.
Operator overloading – This is where the operator name or symbol can be used for multiple operations. i.e. an operator can be bound to more than one implementation of the operator.