Похожие презентации:
Declarative Vs. Imperative Programming
1.
2. Declarative Vs. Imperative Programming
Lesson objectivesBy the end of the lesson, a learner should be able to:
Define and give examples of declarative and imperative
programming languages
Compare declarative and imperative programming
languages
1 min
3. What is paradigm?
A paradigm is a fundamental style or way of programming— a set of concepts, principles, and practices that guide
how programmers structure and write code.
In other words, it’s a method of thinking about and
organizing code.
4. Examples of Programming Paradigms
• Imperative paradigm – Programs are written as sequences of instructions that changethe program’s state step by step. Examples: C, Java, Python (procedural style).
• Declarative paradigm – Programs describe what result is desired, not how to get it.
Examples: SQL, Prolog, HTML.
• Object-Oriented paradigm (OOP) – Organizes programs around “objects” that
combine data and behavior. Examples: Java, C++, Python (OOP style).
• Functional paradigm – Programs are built by composing pure functions, avoiding side
effects. Examples: Haskell, Lisp, Scala.
• And etc.
5. Declarative Vs. Imperative
5 minThink – Pair - Share
Students to gather information on imperative and declarative paradigms from
the resources below
https://www.geeksforgeeks.org/theory-of-computation/difference-betweenimperative-and-declarative-programming/
After then: first think individually about a question or problem, then pair up with
a partner to discuss their ideas, and finally share their thoughts with the class.
6. What is Declarative programming?
3 minGeneral programming paradigm in which programs express
the logic of a computation without describing its control flow.
Programs describe what the computation should accomplish,
rather than how it should accomplish it.
Typically avoids the notion of variable holding state, and
function side-effects.
7.
What is Declarative programming?Includes diverse languages/subparadigms such as:
• Database query languages (e.g. SQL, Xquery)
• XSLT
• Makefiles
• Constraint programming
• Logic programming (prolog)
• Functional programming
8. What is Imperative programming?
Programming with an explicit sequence of commands thatupdate state.
Control flow in imperative programming is explicit:
commands show how the computation takes place, step by
step. Each step affects the global state of the computation.
9. What is Imperative programming?
Imperative (also called Structured or Procedural)Programming
• FORTRAN, BASIC, COBOL, Pascal, C
10.
11. What does this code do? Is it an example of declarative or imperative?
2 minWhat does this code do?
Is it an example of declarative or imperative?
12.
This is an Structured Query Language query that returns acolumn with first_names from the employees table for the
employees hired in the year 200.
It is declarative since it is focussing on what (first_name of all
employees hired in the year 2000) as opposed to how.
13. What does this code do? Is it an example of declarative or imperative?
2 minWhat does this code do?
Is it an example of declarative or imperative?
14.
This is an Javascript code that parses through a list / array(numbers). The code has method to find even numbers from
the numbers array. It goes ahead to populate another list
called even with the even numbers from numbers.
It is imperative since it is focussing on how to identify if a
number from the array given is odd and populating odd
array.
15. Benefits of imperative and declarative language
Learners to read about the two (2) benefits of imperative anddeclarative language from
https://www.netguru.com/blog/imperative-vs-declarative
This is followed by an open class discussion
16. End of lesson activity
5 minA programming paradigm that seeks to describe a program
in terms of instructions which change its state.
Declarative
Imperative
17. End of lesson activity
• Which of the following is an example of imperativeprogramming
SQL
C programming
Prolog
5 min
18. End of lesson activity
5 min• A programming paradigm that it separates the process of
stating a problem from the process of solving it
Declarative
Imperative
19. End of lesson activity
5 min• In imperative programming languages, a programmer has
limited or no control over how his or her inputs are dealt with.
True
False
20. Reflection
Students to use the following emoji’s to rate their learning experienceso far. Post the emoji of their choice on teams chat.
I am able to define the two key terms declarative and
imperative at ease
I am able to define the two key terms declarative and imperative
but I would need some more help to consolidate my understanding
I really need support to boost my understanding
Информатика