Language Logic

esse quam videri
Revision as of 22:45, 8 September 2009 by Tyler.kendrick (talk | contribs) (Association(Uses a...))
Jump to: navigation, search

Programming Club

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 const char* name = "value";
JAVA final String Name = "Value";
C# const 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.

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.

De-referencing

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

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.

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.

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.

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.

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.

LinkedLists

LinkedLists 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.

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.

Unions

Unions are objects that place multiple objects in the same location in memory.

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.

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 MUST be redefined when it is inherited.

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.

Containment (Has a...)

Containment occurs one object contains another object.

Association(Uses a...)

Association occurs when one object uses another object.

Modifiers

Object Types

Byte

Integral

Boolean
Floating-Point
Decimal

Generic

Anonymous

Type Modifiers

Virtual

Immutable/Mutable

Storage Classes

Internal/External

Static

Linkage Specifications

Access Modifiers

File

Method/Function

Class

Namespace

Global

Loops

Recursion

Repetition

Iteration

Programming Paradigms