Programming Paradigms

From TRCCompSci - AQA Computer Science
Jump to: navigation, search

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

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:

  1. . Determiner (the)
  2. . Adjective (big)
  3. . Adjective (little)
  4. . Verb (is)
  5. . Verb (climbs)
  6. . Noun (Thomas)
  7. . Noun (hill)
  8. . Noun_phrase (X) IF noun (X)
  9. . Noun_phrase ( X, Y ) IF determiner (X) AND noun (Y)
  10. . Noun_phrase ( X, Y, Z ) IF determiner (X) AND adjective (Y) AND noun (Z)
  11. . Sentence ( A, B, C ) IF noun_phrase (A) AND verb (B) AND noun_phrase (C)
  12. . Sentence ( A, B, C, D, E ) IF noun_phrase (A) AND verb (B) AND noun_phrase ( C, D, E )
  13. . 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