10. Principles of programming Flashcards
What are the 5 paradigms?
- event driven (imperative)
- mark up (declarative)
- procedural (imperative)
- object oriented
- visual
What is the event driven paradigm?
The flow of the program is determined by external events. The program will remain in a loop state, waiting for user input. When an action occurs, a function will process that action. They use trigger functions to select which event handler to run, depending on what event has occurred.
What is the mark up paradigm?
Mark up languages add commands to text documents. These commands give instructions to an application reading the file on how to display and interpret the text. Commands are opened and closed so that any text written within them have that format applied to it.
What is the procedural paradigm?
Procedural languages work top to bottom and follow ordered instructions. Statements can be used to change the state of the program, e.g. selection and iteration.
What is the visual paradigm?
Visual languages make use of intuitive user interfaces to help build programs. It requires the programmer to think logically, rather than being able to write syntax.
What is the object oriented paradigm?
Objects are used as the building blocks of the software. An object is a unit that contains data and code, which is defined by it’s class.
What is a class?
A template for an object which defines it’s attributes and methods.
What is a method?
A programmed behaviour that is included in an object of a class. It can only access data within its own object. They carry out specific tasks on data within an object (private) or from another part of a program (public).
What are the access modifiers?
protected
+ public
- private
(hashtag) protected
Give a private attribute called amount of type real.
- amount : Real
Give a public method called getID that returns an integer.
+ getID() : Integer
Give a protected method called setName that accepts a string parameter.
(hashtag) setName(String)
What is encapsulation?
Encapsulation is the hiding of the implementation of a class and controlling access to it’s methods and attributes.
What is inheritance?
When a new object takes on the properties of an existing object. A subclass inherits from a superclass.
What is polymorphism?
When a general object is created that can be used with a wide range of data types.