Difference between revisions of "Multi-Paradigm Programming and Scripting"
Adelo Vieira (talk | contribs) |
Adelo Vieira (talk | contribs) (Tag: Visual edit) |
||
Line 1: | Line 1: | ||
− | Why Multi-Paradigm Programming and Scripting? | + | <br /> |
− | *Universal programming constructs (invariant of language), their functions, uses and how different paradigms/languages employ them. | + | {| class="wikitable" |
+ | |+ | ||
+ | ! colspan="4" |'''Why Multi-Paradigm Programming and Scripting?''' | ||
+ | |- | ||
+ | | colspan="4" | | ||
+ | * Universal programming constructs (invariant of language), their functions, uses and how different paradigms/languages employ them. | ||
+ | |||
*Improved background for choosing appropriate languages: | *Improved background for choosing appropriate languages: | ||
− | |||
− | + | <br /> | |
− | '''Content | + | |- |
− | + | ! colspan="4" |'''Content of this cours''' | |
− | + | |- | |
− | '''Programming Constructs:''' | + | |'''Programming Constructs:''' |
*The compilation process | *The compilation process | ||
*Data types (strongly-typed, weakly-typed) | *Data types (strongly-typed, weakly-typed) | ||
Line 15: | Line 20: | ||
*Conditionals (Selection) | *Conditionals (Selection) | ||
*Sequence | *Sequence | ||
− | *Repetition | + | *Repetition |
*Routines | *Routines | ||
*Concurrency | *Concurrency | ||
+ | |'''Programming Paradigms & Languages:''' | ||
− | |||
− | |||
*Abstraction (machine to very-high-level) | *Abstraction (machine to very-high-level) | ||
*Mark-up | *Mark-up | ||
Line 31: | Line 35: | ||
*Interpreted Languages | *Interpreted Languages | ||
*Comparison of all to Object Oriented Paradigm | *Comparison of all to Object Oriented Paradigm | ||
+ | |'''Scripting:''' | ||
− | |||
*Interpreters and system commands | *Interpreters and system commands | ||
*Shell Scripting (Linux/UNIX) | *Shell Scripting (Linux/UNIX) | ||
*PowerShell Scripting (Windows) | *PowerShell Scripting (Windows) | ||
*System Programming & Scripting | *System Programming & Scripting | ||
+ | |'''Applications of Shell Scripting:''' | ||
− | |||
*Job Control | *Job Control | ||
*Glue Code / Wrappers | *Glue Code / Wrappers | ||
Line 45: | Line 49: | ||
*System uses | *System uses | ||
*I/O tasks and functions | *I/O tasks and functions | ||
+ | |- | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | |- | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | |} | ||
+ | <br /> | ||
+ | |||
+ | * | ||
+ | |||
+ | :*Analyse and evaluate the strengths and weaknesses of various programming languages for use in solving particular problems. | ||
+ | |||
+ | |||
+ | '''Content:''' | ||
+ | |||
+ | |||
+ | * | ||
+ | |||
+ | * | ||
+ | |||
<br /> | <br /> | ||
==Examples from Introduction to Programming Using Python 3== | ==Examples from Introduction to Programming Using Python 3== | ||
Line 88: | Line 117: | ||
'''Uses of reflection for software tools:''' | '''Uses of reflection for software tools:''' | ||
+ | |||
*Class browsers need to enumerate the classes of a program | *Class browsers need to enumerate the classes of a program | ||
*Visual IDEs use type information to assist the developer in building type correct code | *Visual IDEs use type information to assist the developer in building type correct code | ||
Line 95: | Line 125: | ||
'''Downsides of Reflection:''' | '''Downsides of Reflection:''' | ||
− | * Performance costs | + | |
− | * Exposes private fields and methods | + | *Performance costs |
− | * Voids the advantages of early type checking | + | *Exposes private fields and methods |
− | * Some reflection code may not run under a security manager, making code nonportable | + | *Voids the advantages of early type checking |
+ | *Some reflection code may not run under a security manager, making code nonportable | ||
<br /> | <br /> | ||
===Reflection in Java=== | ===Reflection in Java=== | ||
+ | |||
*Limited support from <code>java.lang.Class</code> | *Limited support from <code>java.lang.Class</code> | ||
Line 108: | Line 140: | ||
*The <code>getClass</code> method of <code>Class</code> returns the <code>Class</code> object of an object | *The <code>getClass</code> method of <code>Class</code> returns the <code>Class</code> object of an object | ||
+ | |||
::<code>float[] totals = new float[100];</code> | ::<code>float[] totals = new float[100];</code> | ||
::<code>Class fltlist = totals.getClass();</code> | ::<code>Class fltlist = totals.getClass();</code> | ||
Line 113: | Line 146: | ||
*If there is no object, use class field: | *If there is no object, use class field: | ||
+ | |||
::<code>Class stg = String.class;</code> | ::<code>Class stg = String.class;</code> | ||
− | * '''Class has four useful methods:''' | + | *'''Class has four useful methods:''' |
− | :: <code>getMethod</code> searches for a specific public method of a class | + | |
− | :: <code>getMethods</code> returns an array of all public methods of a class | + | ::<code>getMethod</code> searches for a specific public method of a class |
− | :: <code>getDeclaredMethod</code> searches for a specific method of a class | + | ::<code>getMethods</code> returns an array of all public methods of a class |
− | :: <code>getDeclaredMethods</code> returns an array of all methods of a class | + | ::<code>getDeclaredMethod</code> searches for a specific method of a class |
− | :: The <code>Method</code> class defines the invoke method, which is used to execute the method found by <code>getMethod</code> | + | ::<code>getDeclaredMethods</code> returns an array of all methods of a class |
+ | ::The <code>Method</code> class defines the invoke method, which is used to execute the method found by <code>getMethod</code> | ||
+ | |||
+ | <br /> | ||
<br /> | <br /> |
Revision as of 18:40, 2 November 2019
Why Multi-Paradigm Programming and Scripting? | |||
---|---|---|---|
| |||
Content of this cours | |||
Programming Constructs:
|
Programming Paradigms & Languages:
|
Scripting:
|
Applications of Shell Scripting:
|
- Analyse and evaluate the strengths and weaknesses of various programming languages for use in solving particular problems.
Content:
Contents
Examples from Introduction to Programming Using Python 3
http://www.cs.armstrong.edu/liang/py/ExampleByChapters.html
C++ tutorial
http://www.cplusplus.com/doc/tutorial/program_structure/
Compilation vs Interpretation
Phases of Compilation
C++ Inheritance
https://www.w3schools.com/cpp/cpp_inheritance.asp
https://www.tutorialspoint.com/cplusplus/cpp_interfaces.htm
Difference Between Static and Dynamic Binding
https://techdifferences.com/difference-between-static-and-dynamic-binding.html
Reflection
A programming language that supports reflection allows its programs to have runtime access to their types and structure and to be able to dynamically modify their behavior
- The types and structure of a program are called
metadata
- The process of a program examining its metadata is called
introspection
- Interceding in the execution of a program is called
intercession
Uses of reflection for software tools:
- Class browsers need to enumerate the classes of a program
- Visual IDEs use type information to assist the developer in building type correct code
- Debuggers need to examine private fields and methods of classes
- Test systems need to know all of the methods of a class
Downsides of Reflection:
- Performance costs
- Exposes private fields and methods
- Voids the advantages of early type checking
- Some reflection code may not run under a security manager, making code nonportable
Reflection in Java
- Limited support from
java.lang.Class
- Java runtime instantiates an instance of
Class
for each object in the program
- The
getClass
method ofClass
returns theClass
object of an object
float[] totals = new float[100];
Class fltlist = totals.getClass();
Class stg = "hello".getClass();
- If there is no object, use class field:
Class stg = String.class;
- Class has four useful methods:
getMethod
searches for a specific public method of a classgetMethods
returns an array of all public methods of a classgetDeclaredMethod
searches for a specific method of a classgetDeclaredMethods
returns an array of all methods of a class- The
Method
class defines the invoke method, which is used to execute the method found bygetMethod