2021-04-23
slides.com/jod/pt_17b
Docent: Jo Devriendt
Assistent: Ann Philips
Coördinator: Joost Vennekens
voornaam.achternaam@kuleuven.be
Programmeertechnieken [B-KUL-YI0855]
De Nayer, IIW, E-ICT, 2Ba + schakel, 2020-2021
Programmeertechnieken [B-KUL-YI0855]
De Nayer, IIW, E-ICT, 2Ba + schakel, 2020-2021
Programmeertechnieken [B-KUL-YI0855]
De Nayer, IIW, E-ICT, 2Ba + schakel, 2020-2021
Imperatief
Declaratief
...
Programmeertechnieken [B-KUL-YI0855]
De Nayer, IIW, E-ICT, 2Ba + schakel, 2020-2021
Programmeertechnieken [B-KUL-YI0855]
De Nayer, IIW, E-ICT, 2Ba + schakel, 2020-2021
Programmeertechnieken [B-KUL-YI0855]
De Nayer, IIW, E-ICT, 2Ba + schakel, 2020-2021
typedef struct {
char naam[100];
} Persoon;
void print(Persoon* p){
printf("%s\n",p->naam);
}
typedef struct {
char naam[100];
int nummer;
} Student;
void print(Student* s){
printf("%s %d\n",s->naam,
s->nummer);
}
// C++
class Persoon {
protected: char naam[100];
public: void print(){
printf("%s\n",this->naam);
}
};
class Student: public Persoon {
int nummer;
public: void print(){
printf("%s %d\n",this->naam,
this->nummer);
}
};
Attribuut
Methode
Klasse
Overerving: elke Student is een Persoon
Verwijst naar de naam van Persoon
Programmeertechnieken [B-KUL-YI0855]
De Nayer, IIW, E-ICT, 2Ba + schakel, 2020-2021
Programmeertechnieken [B-KUL-YI0855]
De Nayer, IIW, E-ICT, 2Ba + schakel, 2020-2021
fib :: Integer -> Integer
fib 1 = 0
fib 2 = 1
fib n = fib (n-1) + fib (n-2)
Programmeertechnieken [B-KUL-YI0855]
De Nayer, IIW, E-ICT, 2Ba + schakel, 2020-2021
fib :: Integer -> Integer
fib 1 = 0
fib 2 = 1
fib n = fib (n-1) + fib (n-2)
{x*x for x in range(0,n) if x % 2 == 0}
Map-functie
Filter-functie
int result[100];
int size = 0;
for(int x=0; x<n; ++x){
if(x%2 == 0){
result[size]=x*x;
++size;
}
}
Programmeertechnieken [B-KUL-YI0855]
De Nayer, IIW, E-ICT, 2Ba + schakel, 2020-2021
Programmeertechnieken [B-KUL-YI0855]
De Nayer, IIW, E-ICT, 2Ba + schakel, 2020-2021
fib(1,0).
fib(2,1).
fib(N,X) :- N>2,
N1 is N-1, fib(N1,X1),
N2 is N-2, fib(N2,X2),
X is X1+X2.
Programmeertechnieken [B-KUL-YI0855]
De Nayer, IIW, E-ICT, 2Ba + schakel, 2020-2021
Programmeertechnieken [B-KUL-YI0855]
De Nayer, IIW, E-ICT, 2Ba + schakel, 2020-2021
Volgende lesvideo :)
Programmeertechnieken [B-KUL-YI0855]
De Nayer, IIW, E-ICT, 2Ba + schakel, 2020-2021
Ja: steeds abstractere concepten kunnen op steeds natuurlijkere, compactere wijze uitgedrukt worden in nieuwere programmeertalen
Echter: er is geen zilveren kogel (die de weerwolf doodt)
There is no single development, in either technology or management technique, which by itself promises even one order of magnitude improvement within a decade in productivity, in reliability, in simplicity. [...] we cannot expect ever to see two-fold gains every two years [in software development, as Moore's law has shown in hardware development.]
- Fred Brooks in "There is no silver bullet", 1987
Programmeertechnieken [B-KUL-YI0855]
De Nayer, IIW, E-ICT, 2Ba + schakel, 2020-2021
...
Imperatief
Declaratief
Maar er is helaas geen zilveren kogel