Difference between revisions of "Language Logic"

esse quam videri
Jump to: navigation, search
m (Programming Paradigms)
m (Polymorphism)
Line 610: Line 610:
 
<br/>
 
<br/>
 
=====Polymorphism=====
 
=====Polymorphism=====
 
+
Polymorphism describes objects that can be implemented or derived from others such that one object can take the place of or be used as another.
 
<br/>
 
<br/>
 
<br/>
 
<br/>
Line 621: Line 621:
 
<br/>
 
<br/>
 
<br/>
 
<br/>
 +
 
====Conditional Inheritance====
 
====Conditional Inheritance====
 
Conditional inheritance is similar to multiple inheritance in that it allows for an object (such as a human) to be considered as multiple objects (like a mammal, '''AND''' a biped); However, this type of association requires the programmer to explicitly define the conditions where the object is defined as one ''or'' the other.
 
Conditional inheritance is similar to multiple inheritance in that it allows for an object (such as a human) to be considered as multiple objects (like a mammal, '''AND''' a biped); However, this type of association requires the programmer to explicitly define the conditions where the object is defined as one ''or'' the other.

Revision as of 16:29, 4 November 2009

Programming Club


Contents

Objects

Objects in any programming language are sections of memory in a computer that store data.

Variables

Variables are objects that store data, and are given names, values and sometimes object types. The purpose of variables, are to store data for later use in a program. To do this, the computer's processor takes up a part of its memory and remembers the data you put into the variable.

Examples
Language Type Name Value
C/C++ int name = 0;
JAVA String Name = "Value";
C# string VariableName = "SomeValue";











Pointers

Pointers are created to "point" to parts of the computer's memory and keep track of an object in memory. When a variable is created in one part of a program, and used in a different part, it is common for a pointer to be used in its place; This way, a new variable doesn't have to be created, and less memory is used.

Examples
Language Declaration
C/C++ char* charPTR;
MC++ char^ charPTR;











Referencing

Pointers are references to an object's memory location - which store an object's data. Pointers can change the value of the object it is pointing to, and can keep an updated value from the object.

Examples
Language Referencing
C/C++ char* myVarPTR = &myVar;
MC++ char^ myVarPTR = &myVar;











De-referencing

When a pointer is de-referenced, the original object still retains its data, but the pointer becomes empty, and retains a null(empty) value.

Examples
Language De-referencing
C/C++ char myVar = *myVarPTR;
MC++ char myVar = ^myVarPTR;












Changing Values

By changing the value of a pointer member, you change the value of the object that it is pointing to.









Collections

Collections are groups of objects that share an object type, and can be managed as a group. Anytime you are using multiple objects for the same purpose, it is usually preferred to use a collection.

Examples
Language Declaration Initialization
C/C++ char[][2] name = {{"a", "b", "c"} {"d", "e", "f"} {"g", "h", "i"}};
JAVA int[] Name = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
Python L = [1, 2, 3, 4, 5]











Arrays

Arrays are a specific type of collection with a defined amount of items - meaning that it can only hold a maximum number of items.











Single-Dimensional Arrays

Single-Dimensional Arrays are among the most common collections in a program. These type of arrays simply keep an ordered, numbered collection of each object in the array - and are limited by a maximum defined number of objects they can hold.

Examples
Language Declaration Initialization
C/C++ char name[3] = {0, 2, 4};
Visual Basic Dim a() As Double = New Double(3) {0.1, 1.4, 4.3}
C# int[4] VariableName = {0, 1, 2, 3};











Multi-Dimensional Arrays

Multi-Dimensional Arrays are less common, and more complex than their single-dimensional counter-parts. These arrays contain a matrix of objects and are also limited by a maximum defined number of objects they can hold.

Examples
Language Declaration Initialization
Visual Basic Dim a(,) As Double = New Double(3, 2) {{1.0, 2.1, 3.2} {2.1, 1.2, 3.2}}
C# int[4, 2] VariableName = {{4, 5, 6, 7} {0, 1, 2, 3}};
Ada type MyType is array (1..4, 1..4, 1..4) of CHARACTER : MyVariable; PUT(MyVariable(2, 2, 2);











Jagged/Nested Arrays

Jagged Arrays (a.k.a. Nested Arrays) are exponentially more complex than single-dimensional arrays. These arrays contain other arrays that contain data, instead of the data itself. These arrays are also limited by a maximum defined number of arrays they can hold.

Examples
Language Declaration Initialization
C/C++ int jagged[][3] = { {0,1}, {1,2,3} };
Visual Basic Dim a()() As Char = New Char(1)() {New Char() {"a"c, "b"c}, New Char() {"p"c, "q"c}}
C# int[][] VariableName = new int[3][];











Lists

Lists are a specific type of collection with an undefined amount of items - meaning that it can hold as many items as the computer's memory allows. Lists are dynamic, and the size can be changed dynamically.

Examples
Language Declaration Initialization
JAVA List list = new LinkedList();
Visual Basic Dim list = List(Of Int)
C# List<int> list = new List<int>();
Python list = [1, 2, 3, 4, 5, 6]











Linked Lists

Linked Lists are complex structures that contain pointers to an object of the same structure type. The list is created by pointing to a new object of the same type, and creating a list where the pointers create a sequence of objects that they can then iterate through.

Examples
Language Declaration Initialization
C/C++ char name[3] = {0, 2, 4};
Visual Basic Dim a() As Double = New Double(3) {0.1, 1.4, 4.3}
C# LinkedList<int> list = new LinkedList();











Doubly-Linked Lists

Doubly-Linked Lists contain two pointers in a structure. These pointers then point to a new object of the same type, just like linked-lists; However, one pointer will point to the next object in the list, and the other will point to the previous item in the list. This way, the list can be iterated through in both directions.











Circular-Linked Lists

Circular-Linked Lists are most like normal Linked Lists in that they iterate in a single direction, through the use of a pointer to a structure of the same type contained within the structure. The difference, is that the structure contains a pointer to the beginning of the list, once it reaches the end. This way, it will repeat from the beginning of the list if needed.












Custom Objects

All objects listed below are commonly found in programs, and are defined by the programmer.












Functions/Methods

Functions and Methods are the reusable portions of code that tell our program how to interact with the data we give it. They both manipulate, and can return new data as a result of the action. Methods, however, differ from functions because they are contained within objects. A method is an object's way of interacting with data.











Structs/Interfaces

Structs and Interfaces are objects that contain only a single type of data or instructions. Structs are objects that can only contain data and pointers; Interfaces, however, are only able to contain methods and instructions that can be redefined elsewhere in a program (see virtual inheritance).











Classes/Modules

Classes and Modules are objects that contain a variety of data and methods to act as a single object.











Unions

Unions are objects that create multiple objects from the same location in memory.












Namespaces

Namespaces can contain any type of data or instruction. All previously mentioned objects can be contained in, and called from a namespace.












Object Relationships

This section is about the different ways that objects can interact with each other.











Inheritance (Is a...)

Through inheritance, an object can be considered to be another object. For example, a human is a mammal; a mammal is an animal; an animal is a creature; etc.

Wherever you can associate objects with one another with the term "...is a...", you can represent this through inheritance.












Single Inheritance

Single inheritance is the simplest form of inheritance, and allows one object to be considered as another object. For example: A human is a mammal; A mammal is an animal; An animal is a creature. However, through this type of association, objects cannot be considered as multiple types of objects. For example: A human is a mammal; A human cannot be a reptile.











Multiple Inheritance

Through Multiple inheritance, objects can be multiple types of objects. For example: A human is a mammal, AND a biped.

This creates many problems however, because the computer then has to decide, in which situation, the object is considered one object or the other.











Virtual Inheritance

Virtual inheritance occurs when an object inherits from a virtual object - meaning that the object becomes redefined by the derived member when it is inherited.











Polymorphism

Polymorphism describes objects that can be implemented or derived from others such that one object can take the place of or be used as another.









Conditional Inheritance

Conditional inheritance is similar to multiple inheritance in that it allows for an object (such as a human) to be considered as multiple objects (like a mammal, AND a biped); However, this type of association requires the programmer to explicitly define the conditions where the object is defined as one or the other.











Typed Inheritance

Typed inheritance allows a base object of a generic type to inherit a type from derived members for each derivation - allowing "conditional" inheritance through the use of derived objects.











Containment (Has a...)

Containment occurs one object contains another object.











Encapsulation











Association(Uses a...)

Association occurs when one object uses another object.











Operators

Operators are symbols that will perform various operations on objects which are then called "operands".











Conditional

Conditional operators return values based on the relation and states between two or more operands.









Ternary

Ternary operators check conditions, and return data based on the conditions. These operators are cascading as well, meaning they allow you to return another ternary operator.











Coalesce

Coalesce operators are equivalent to Ternary operators, but only check for null types. These operators are cascading as well, which allow you to return another coalesce operator.











Comparative

Comparative operators are considered to be logical operators, and perform specific comparison operations between two or more objects.











Greater Than

Returns a boolean value of true based on whether or not the corresponding operand is greater than the comparing operand.











Less Than

Returns a boolean value of true based on whether or not the corresponding operand is less than the comparing operand.











Equal To

Returns a boolean value of true based on whether or not the corresponding operand is equivalent to the comparing operand.











Not Equal To

Returns a boolean value of true based on whether or not the corresponding operand is not equivalent to the comparing operand.











Logical

Logical operators check for comparison types between two objects, such as equivalency, numerical seniority, and











AND

Returns a boolean value based on all true conditions and/or boolean values as in the operands for comparison.











OR

Returns a boolean value based on a single true condition and/or boolean values in the operands for comparison.











NOT

Returns a the inverse result of a boolean value or condition.











Bitwise

Bitwise operators perform binary operations on data in a computer program. They can shift data forward and backwards, as well as mask/alter the binary data.











AND

ANDing bits together will return a result with ones in the position where ones in the comparing operands match.









OR

ORing bits together will return a result with ones in the position where ones in the comparing operands exist.









XOR

XORing bits together will return a result with ones in the position where ones in the comparing operands don't exist.









NOT

NOTing bits will flip the value(s) of the bits from zero to one, and vice-versa.









LEFTSHIFT

Left-shifting bits will place zeros to the right of the binary number corresponding to the number indicated for shifting, and will delete any digits outside of the bounds of the data structure.









RIGHTSHIFT

Right-shifting bits will place zeros or ones to the left of the binary number (based on the sign of the numeric value), corresponding to the number indicated for shifting, and will delete any digits outside of the bounds of the data structure.









RIGHTSHIFTZEROS

Right-shifting bits will place zeros to the left of the binary number, corresponding to the number indicated for shifting, and will delete any digits outside of the bounds of the data structure.











Mathematical

In any language, a mathematical operator performs a simple mathematical expression on one or two variable types, resulting in a new instance of the object type, populated with the results of the mathematical operation.









Addition











Subtraction











Multiplication











Division











Absolute Value











Exponential











Functional











Lambda

Lambda expressions are usually exclusive to functional programming languages (languages that are optimized for manipulating collections of data objects). These operators create temporary, inline, anonymous methods or functions that apply a given expression to an operand.











Modifiers

Modifiers tell the compiler how the object will be stored; They determine what type of object it will be, where it will be stored, if it can be changed, and how it can be accessed. An object's modifiers are just as important as the data the object stores.











Object Types

An object type determines how the data will be handled; Will it be interpreted as a letter, or a number? Will the number handle decimals or will it ignore them?

There are many different object types, but most are variations of the following objects.











Byte

Bytes are objects that contain binary data up to a maximum value of 256. The data stored in this type is usually unhandled - meaning the programmer may choose how he/she would like to use it.











Character











String











Integral

Integrals are any whole numbers that are handled using the basic math operators.











Boolean

Boolean values are values that abide by the basic boolean logic - False exists, and true is anything that is not false. (Usually, 0 is false, and anything else is considered true.)











Floating-Point

Floating-Point values are numbers with decimal values that present a number at the end to represent the degree of accuracy.











Decimal

True Decimal data types are typically very large in memory and gather very precise numeric data.











Generic

Generic data types are capable of being handled in any way, and are not limited to a specific data type.











Anonymous

Anonymous data types enable you to create objects without writing a class definition for the data type. Instead, the compiler generates a class for you.











Type Modifiers

Type modifiers tell the compiler how an object can be changed in a program.











Virtual

Virtual types allow for objects to be overridden in derived objects.











Immutable/Mutable

Mutable data types are objects that are subject to change. These are usually the default object types for a statement-based object-oriented language; Where Immutable data types are the standard for functional programming languages - which are data types that cannot be changed after they have been initialized (They have a constant value).











Linkage Specifications











Access Modifiers

Access modifiers define the scope and lifetime of an object in memory. Even though an object may be defined within an object, it is possible to give the object a higher scope and lifetime than the object that contains it.











File

File access objects are only accessible within files that are located in the same assembly.











Method/Function

Method/Function access objects are only accessible within the Method/Function being called, and are destroyed immediately after being used.











Object

object accessible objects are contained within the scope of the containing object, and can be used from within an instance of the object.











Namespace

Namespace accessible objects are available to any other object contained within the namespace.











Global

Global/Static accessible objects are available for use anywhere in a program.











Keywords

Keywords are reserved words that are specific to each language for accomplishing a specific, usually common, task.











Loops

Loops are methods of executing a function or series of functions, a number of times; This could be infinite or finite, and can even execute the commands only once.











Recursion

Recursion occurs when a method calls itself under specific conditions, resulting in a loop.











Repetition

Repetition occurs when a method is repeated a set number of times, in a consecutive sequence for a variable number of times.











Iteration

Iteration continues a repeated sequence of commands for a constant number of times.











Programming Paradigms

Programming Paradigms can be thought of as "features" of a language that describe how the structures within a language are arranged.










Agent-oriented

Agent based language models are similar to the object model, but makes decisions based on a "behavior", rather than statement-oriented attribute or method/function. These type of languages are powerful for AI, and interpretive processes because the language determines when it should run the defined process.











Component-based

Components create modules (modular objects) that store sets of related data or functions, and can be dynamically swapped out with each-other without creating any problems.











Flow-based

Flow-based languages treat applications as networks (objects working together), asynchronously passing messages between each-other to accomplish a shared task.











Pipeline

The Pipeline paradigm for programming languages can be described when the application creates a data flow structure which the data can then be transmitted to, and processed as it passes through the structure.











Concatenative

In these languages, all terms evaluate to a function returning a value. These languages are excellent for use in mathematical applications for intuitively solving algebraic solutions.











Concurrent computing

These types of languages allow for the possibility of distributing a process to another processor for asynchronous processing which may be done in parallel to a current process.











Declarative

Declarative languages require only that you explicitly describe what must be done in a program, rather than how it must be interpreted.











Functional

Functional languages evaluate terms as mathematical expressions and are a computational representation of lambda calculus.











Reactive

Reactive languages allow data defined in previous positions of a program to be changed, once a relying data member has been changed in a structure.











Event-driven











Service-oriented











Feature-oriented











Function-level (contrast: Value-level)











Imperative (contrast: Declarative)











Non-structured











Array (contrast: Scalar)











Iterative











Structured











Procedural











Modular











Recursive











Object-oriented











Class-based











Prototype-based











Automata-based











By separation of concerns:











=Aspect-oriented=











=Subject-oriented=











=Role-oriented=











Metaprogramming











Attribute-oriented











Automatic











Generic











Template











=Policy-based=











Language-oriented











Domain-specific











Grammar-oriented











=Dialecting=











Intentional











Reflective











Nondeterministic











Parallel computing











Process-oriented











Programming in the large and programming in the small











Value-level (contrast: Function-level)