Difference between revisions of "Language Logic"

esse quam videri
Jump to: navigation, search
m
m (Modifiers)
Line 111: Line 111:
  
 
==Modifiers==
 
==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===
 
===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====
 
====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.
 
====Integral====
 
====Integral====
 +
Integrals are any whole numbers that are handled using the basic math operators.
 
=====Boolean=====
 
=====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=====
 +
Floating-Point values are numbers with decimal values that present a number at the end to represent the degree of accuracy.
 
=====Decimal=====
 
=====Decimal=====
 +
True Decimal data types are typically very large in memory and gather very precise numeric data.
 
====Generic====
 
====Generic====
 +
Generic data types are capable of being handled in any way, and are not limited to a specific data type.
 
====Anonymous====
 
====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===
 
====Virtual====
 
====Virtual====

Revision as of 05:49, 12 September 2009

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 a pointer 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

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.

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

Virtual

Immutable/Mutable

Storage Classes

Internal/External

Static

Linkage Specifications

Access Modifiers

File

Method/Function

Class

Namespace

Global

Loops

Recursion

Repetition

Iteration

Programming Paradigms