Difference between revisions of "Programming Paradigms"
(Created page with "=Paradigms= <youtube>https://www.youtube.com/watch?v=_iE5Tga8Jhw&list=PLCiOXwirraUAJPwNTW5gxfJK6Ej18fDP9</youtube> https://www.youtube.com/watch?v=_iE5Tga8Jhw&list=PLCiOXwirr...") |
(→Logical) |
||
(One intermediate revision by the same user not shown) | |||
Line 44: | Line 44: | ||
==Logical== | ==Logical== | ||
+ | A simple logic processing language is used to represent, as a set of facts and rules, the valid construction of sentences. A set of facts and rules are shown below: | ||
+ | #. Determiner (the) | ||
+ | #. Adjective (big) | ||
+ | #. Adjective (little) | ||
+ | #. Verb (is) | ||
+ | #. Verb (climbs) | ||
+ | #. Noun (Thomas) | ||
+ | #. Noun (hill) | ||
+ | #. Noun_phrase (X) IF noun (X) | ||
+ | #. Noun_phrase ( X, Y ) IF determiner (X) AND noun (Y) | ||
+ | #. Noun_phrase ( X, Y, Z ) IF determiner (X) AND adjective (Y) AND noun (Z) | ||
+ | #. Sentence ( A, B, C ) IF noun_phrase (A) AND verb (B) AND noun_phrase (C) | ||
+ | #. Sentence ( A, B, C, D, E ) IF noun_phrase (A) AND verb (B) AND noun_phrase ( C, D, E ) | ||
+ | #. Sentence ( A, B, C, D, E ) IF noun_phrase ( A, B, C ) AND verb (D) AND noun_phrase (E) | ||
+ | |||
+ | Clause 1 has the meaning ‘the is a determiner’ | ||
+ | |||
+ | Clause 9 has the meaning ‘X followed by Y is a noun_phrase if X is a determiner and Y is a noun’ | ||
+ | |||
+ | We can see from the above that 'Thomas climbs the little hill' would be a valid sentence, however we can also see that 'The little hill climbs Thomas' would also be a valid sentence even though it isn't logical. | ||
==Functional== | ==Functional== | ||
for more information see [[Fundamentals of functional programming]] | for more information see [[Fundamentals of functional programming]] |
Latest revision as of 08:34, 10 September 2018
Contents
Paradigms
https://www.youtube.com/watch?v=_iE5Tga8Jhw&list=PLCiOXwirraUAJPwNTW5gxfJK6Ej18fDP9
Object Oriented
OOP languages are based on the emulation of real world objects and their relationships and interactions with each other. The basis of object oriented programming is situated on the re-usability and conservation of large scale code/programming structures; for example, a video game makes extensive use of object oriented programming by defining complex object hierarchies, such as:
- Object
- Sprite
- PlayableSprite
- MainCharacter
- EnemySprite
- BossMonster
- BufferMonster
- StaticSprite
- Block
- TreasureChest
- PlayableSprite
- Sprite
etc...
for more information see Object Orientated Programming
Event Driven
Event driven programs continuously run, the user will need to quit or exit to stop the program. You will have used these for windows form applications.
Events
These are actions by the user or the system
Components
reusable interface elements such as buttons, textbox, or labels etc. Events can happen to individual components.
Event Loop
This is the part that continuously runs, it is designed to listen for the events programmed by the developer. Once this section is run it will be run again, and again, and again. Hence the term event loop.
Trigger Functions
Trigger functions are added to the event loop for each event the program should detect. These trigger functions will be triggered when the specific event is detected.
Event Handler
The trigger function will run the event handler when triggered. The event handler is therefore the code to run when the event is detected.
Procedural
Your experience of C# is procedural, it is the process of replacing often repeating code by giving it a name for the sub routine. Then any time you wish to run the code you can simply call it by name.
Logical
A simple logic processing language is used to represent, as a set of facts and rules, the valid construction of sentences. A set of facts and rules are shown below:
- . Determiner (the)
- . Adjective (big)
- . Adjective (little)
- . Verb (is)
- . Verb (climbs)
- . Noun (Thomas)
- . Noun (hill)
- . Noun_phrase (X) IF noun (X)
- . Noun_phrase ( X, Y ) IF determiner (X) AND noun (Y)
- . Noun_phrase ( X, Y, Z ) IF determiner (X) AND adjective (Y) AND noun (Z)
- . Sentence ( A, B, C ) IF noun_phrase (A) AND verb (B) AND noun_phrase (C)
- . Sentence ( A, B, C, D, E ) IF noun_phrase (A) AND verb (B) AND noun_phrase ( C, D, E )
- . Sentence ( A, B, C, D, E ) IF noun_phrase ( A, B, C ) AND verb (D) AND noun_phrase (E)
Clause 1 has the meaning ‘the is a determiner’
Clause 9 has the meaning ‘X followed by Y is a noun_phrase if X is a determiner and Y is a noun’
We can see from the above that 'Thomas climbs the little hill' would be a valid sentence, however we can also see that 'The little hill climbs Thomas' would also be a valid sentence even though it isn't logical.
Functional
for more information see Fundamentals of functional programming