Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Class 9: Language Overview and Procedural Programming

Class 9: Language Overview and Procedural Programming

Class notes for 1/30/2014

Ian Luke Kane

January 30, 2014
Tweet

More Decks by Ian Luke Kane

Other Decks in Technology

Transcript

  1. Programming Languages Programming languages are used for controlling the behavior

    of a machine (often a computer). Like natural languages, programming languages conform to rules for syntax and semantics. Objective C, Ruby, Python, PHP, C#, Go, Java, C, C++ Many, many, MANY others.
  2. How Should I Proceed? Early on, I would say it’s

    important to focus on some “non- functional requirements.” A requirement that specifies criteria that can be used to judge the operation of a system, rather than specific behaviors. Scalability, Maintainability, Reliability, Availability, Extensibility, Performance, Manageability, Security
  3. Where do I Start?! • Code Wars: Ruby vs Python

    vs PHP • Choosing a Programming Language: So easy, a caveman can do it • Programming Language Comparison • How to Pick the Right Programming Language • Choosing a Programming Language • How do you choose to use a specific programming language?
  4. Comparison to Human Language Different languages are capable of communicating

    ideas differently. Mamihlapinatapei: Yagan (indigenous language of Tierra del Fuego) – “the wordless, yet meaningful look shared by two people who both desire to initiate something but are both reluctant to start.” But languages share many commonalities. Same goes for programming languages. E.g. if you know the generalities of noun/verb interactions, it’s easier to learn a new language. !
  5. Procedural Programming A programming paradigm based upon the concept of

    the procedure call. Procedures, also known as routines, subroutines, methods, or functions simply contain a series of computational steps to be carried out. Any given procedure might be called at any point during a program's execution, including by other procedures or itself. !
  6. Procedural Programming In short, procedural programming could be regarded as

    a list of instructions telling a computer, step-by-step, what to do and usually having a linear order of execution from the first statement to the second and so forth with occasional loops and branches. Modularity is generally desirable, especially in large, complicated programs. Inputs are usually specified syntactically in the form of arguments and the outputs delivered as return values. !
  7. Procedural Programming Modularity is a software design technique that emphasizes

    separating the functionality of a program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of the desired functionality. Scoping is another technique that helps keep procedures strongly modular. It prevents the procedure from accessing the variables of other procedures (and vice-versa), including previous instances of itself, without explicit authorization. !
  8. Procedural Programming Design Method = Top Down. This is where

    you start with a problem (procedure) and then systematically break the problem down into sub problems (sub procedures). This is called functional decomposition, which continues until a sub problem is straightforward enough to be solved by the corresponding sub procedure. !
  9. Procedural Programming Issues The difficulties with this type of programming,

    is that software maintenance can be difficult and time consuming. When changes are made to the main procedure (top), those changes can cascade to the sub procedures of main, and the sub-sub procedures and so on, where the change may impact all procedures in the pyramid.
  10. SegSim Explanation “Segregation Simulation”: A simple model for investigating how

    over time communities can become segregated based on various prejudices. 1. Break the problem down into one dimension; a street initially populated with equal probability either black ‘B’, white ‘W’ or empty ‘ ‘ houses. 2. We then allow the system to evolve by randomly selecting houses and applying a simple condition: If the house is surrounded on both sides by a house different to itself, it will decide to move to an empty location in the street where this condition is not satisfied. In the unlikely event that a suitable location cannot be found after a designated number of attempts, the house will leave the street.
  11. SegSim Sample Output | BW W BWB BWBBWWBWWW W B

    BW BW WW BWW BWWW | : 17   | BW W BWB BWBBWWBWWW WBB BW BW WW WW BWWW | : 15   | BW W BWB BWBBWWBWWW WBB B BWWWW WW BWWW | : 13   | BBW W BWB BWBBWWBWWW WBB B WWWW WW BWWW | : 11   | BBW W BWBBBWBBWWBWWW WBB B WWWW WW WWW | : 8   | BBW BWBBBWBBWWBWWWWWBB B WWWW WW WWW | : 6   | BBW BWBBB BBWWBWWWWWBB B WWWW WW WWWW | : 5   | BBW WBBB BBWWBWWWWWBB BB WWWW WW WWWW | : 3   | BBWW BBB BBWWBWWWWWBB BB WWWW WW WWWW | : 1   | BBWW BBBB BBWW WWWWWBB BB WWWW WW WWWW | : 0
  12. SegSim Modified Rules Suppose we want to add a different

    type of house that plays by different rules, then see how the simulation differs? Consider a nomad type house (label ‘N’) which does not care about its neighbors. However, it remembers how long it has been in one location, and if longer than a specified threshold it moves to a new location. How must we modify the original program in order to account for these new rules?