Total Pageviews

Friday, May 13, 2011

Top-Down Design – Unitizing a Problem into Modules


Top-Down design in Programming:
Top-Down Design is a strategy that is developed with a focus on advanced analysis. Top-Down Design, also known as step-wise design, is a programming approach where programmers examine a program or system in its entirety and then meticulously analyze the every part of the program to acquire a better understanding of the compositional sub-systems that make up the program. Programmers then take these compositional sub-systems and analyze and refine them even more to reach the program’s fundamental elements. By taking this programming approach, which is the backbone of conventional procedural languages, programmers are able to effectively focus on a single module at a time, rather than the entire program at once. Programmers, essentially, transform the complex pieces of the program and then divide them into successively smaller pieces.

To write a program using the Top-Down Design, programmers utilize the method of writing a main procedure that identifies all of the key operations the procedure will need. The next step in this process is for the programmer or programmers to thoroughly examine the requirements of each operation and then replicate each of these steps. This process will ultimately lead to the grouped sub-routines executing the simplified procedures that can be simply and concisely coded. Once each of the different sub-routines is coded, the program will be ready for testing. Establishing how the program will collaborate at the high level, the lower level work can be independent. Identifying how the lower level concepts will assimilate into higher level concepts will clearly define the interfaces.

Top-Down Design outside Programming:
Even though Top-Down Design works great in the world of programming, the strategy is not confined to the world of programming. There are a variety of instances, outside of programming, where a person can apply Top-Down Design strategy. An example of where someone can apply Top-Down Design strategy would be in the preparation of a big dinner, such as Christmas dinner or Thanksgiving dinner. For many people, these dinners are very important their execution the execution of these dinners has to be perfect. In most cases, these dinners require a lot of food preparation. The person responsible for preparing the dinners usually has to prepare the main dish, a turkey or ham or sometimes both, and then a variety of side dishes, such as mashed potatoes, green bean casserole, pies, stuffing, etc.

Utilizing the Top-Down Design strategy in this process can aid in its successful completion. The person responsible for preparing the dinner can implement the strategy by dividing the dinner into portions based on the time it takes to prepare the item. It would probably be best to identify and separate the items that take the longest to prepare. Once all the items have been grouped and sorted, the preparer will need to gather the ingredients and utensils required to prepare each item. Once everything is in order and all items necessary are where they should be, the preparer can start the actual meal preparation one group at a time.

Tuesday, May 10, 2011

Control Structures

In the world of programming, programmers incorporate control structures to create efficient and user-friendly programs. Similar to steps in a set of instructions with one or more possible outcomes, control structures are blocks of programming that evaluate variables and decide which direction to proceed based on a set of parameters. The four basic control structures in programming are sequence, selection, loop, and unconditional branch. Some of the common terms that can be found in control structures are if, then, else, while, and goto. Terms like these are utilized to set the direction of the program and determine its calculated outcome.
 
The simplest form of these programming control structures would be the Sequence control structure. In this form of control structure, the computer carries out the program statements in a designated sequence, one after the other. In addition, this type of structure is also considered the simplest type of programming structure because it can hold the more complex structures together. A simpler method to understand this form of programming structure is to imagine an employee who is required to carry out a set of procedures, in a designated order, in order to fulfill a daily task at their place of work.


Next, let us focus on the Selection control structure. This form of control structure is utilized to create the alternative to pursue a certain path or a different path. This structure is often programmed utilizing code such as an IF statement, or a CASE statement. An easier way to better understand this form of programming structure is to imagine an employee who is getting ready for work and has a decision to make. This employee gets their briefcase, gets their bag, and if it is raining, the person will get their coat. In both cases, programming and the example above, if the last statement is not true, then the process stops at the prior statement.

Now, let us focus on the Iteration control structure. This form of control structure, also known as loop control structure, is programming structure that is utilized to reiterate a process or processes in the program syntax. This structure is often programmed utilizing terms like loop, while, when, and for. Another way to look at this control structure is to imagine an employee whose job it is to fill a bucket with a gallon of water using a cup to transfer the water from a sink. The employee would have to repeat the process of filling the cup with water and transferring the water to the bucket until the bucket had a gallon of water in it.

Finally, let us focus on the Unconditional Branch control structure. This form of control structure, also known as goto control structure, is to provide a way for the execution of the program to jump to a labeled location in the program syntax. This structure is often programmed utilizing terms like goto, break, and exit. Another way to look at this control structure is to imagine an employee who works at the register, and receives a large a $100 bill as payment for $20 of rendered services and must provide change. Does the employee have enough change? If the employee does, they will provide the customer change. If the employee does not, the employee will get extra change, and then provide the customer with change.

Friday, May 6, 2011

Data Structures and Data Representation


This post is intended to help simplify some programming terms.

A Global Variable is a variable that can be accessed and utilized by any part of the program it is referenced by.

A Local Variable is a variable that can be accessed and utilized by only a certain part of the program that is referenced in.

Elementary Data Types are categories of types of data that establish the value type, the operations that the value type; and how the value is stored in a variable.
A Character data type is utilized to store fixed length character strings that include alphanumeric text, such as letters, numbers, spaces, symbols, and punctuation.
A String data type is utilized to store fixed length or variable length character data.
An Integer data type is utilized to store numerical information, but more specifically, whole numbers that can be positive, negative, or zero.
A Floating data type is utilized to store numerical information, but more specifically, numbers that contain a floating decimal.
A Boolean data type is utilized to store only True/False statements.

A Data Identifier (name) is a unique identifier that names a variable. In most cases, it can be a number, letter, or underscore.

A Data Type is the category of the type of information that indicates the possible values, operations, and storage methods.

The Memory Address identifies the memory location where information can be stored at and retrieved from.

The Actual Data is information that is stored as bits or bytes in the memory location.

A Variable is the name given that identifies a value.

A Literal is a series of characters in source code that do not require interpretation when translating to machine language.

A Constant is a value that does not change during program execution.

Number Base Systems are writing systems used in translating user input data into numbers that can be understood by computers.

BASE 2, also known as the Binary numeral system, uses 0s and 1s to symbolize values, which are more easily converted to computer language.

BASE 10, also known as the Decimal system, is the most commonly used number base system. This number system utilizes 10 as its base, which derived from people counting on their fingers.

BASE 16, also known as the Hexadecimal system, is a positional number system that is based on 16 symbols. These symbols are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and A, B, C, D, E, and F. This gives 16 variations to each placeholder.

Floating Point is a system that symbolizes real numbers using decimal places. In this system, real numbers have a sign, a significand, and an exponent.

Decimal Data Representation (or type) is similar to Floating Point except it can store a maximum of 38 digits.

In Direct Addressing, a given value, which is stored in memory, identifies the instruction value.

In Relative Addressing, the instruction value is based on the loaded value plus the fixed offset value.
Data Types are groups of values the groups of operations on those values. Data Abstraction is the process of identifying data with a depiction of its significance while keeping its operation details concealed.

A File is a collection of data or a source to store information. A Record is the most simplistic method to store data, which consists of more than one value or variable. An Array is a data structure comprises of values or variables that are identified by an index. A Single Dimension array is a linear array that is used to store a number of items of a predefined type and a Multi Dimension array is simply an array of arrays.

Language Statements are the smallest standalone elements that make up a program.
Natural Language Statements/Grammar and Logic are statements created in a naturally evolved language, which was created to communicate with one another. Artificial Language Statements/Syntax and Semantics are statements created in a language that did not naturally evolve but instead was create by a person or group of people. Input/Output Statements are statements created to provide instructions to the computer to identify where the data is to be attained and where the data is to be produced. Assignment Statements is a set of instructions that set or reset the value of a variable.

Program Design Language (PDL) - Meta Language is a process for developing and recording procedures and systems in programming. Syntax Diagrams are graphical road maps of programs there progression of logic. BNF is a notation method used in describing the syntax in a program.

Elementary Language Statements and Structured Language Statements are statements that are primarily comprised of commands in most programming languages. Assignment and Unconditional Statements is a statement that indicates no more than one probable execution sequence. Selection and Looping Statement are statements that are in most imperative programming languages and selection control apparatus’ that allow the value of a variable or expression to regulate the flow of program implementation via a multiway branch.
Expressions Components are elements which make up expressions and are interpreted according to the particular rules of precedence and of association for a particular programming language.
Operators, Operands and Results
Unary is an operation with only one operand. Binary is an operation involving two opperands.

Simple Types
Arithmetic statements are used for simple computation that utilize operations like the ADD, SUBTRACT, MULTIPLY, and DIVIDE statements. Logical statements are statements that can have only two values, true or false. Relational statements are two or more expressions whose values are compared to determine whether the relationship stated by the relational operator is satisfied.

Result
Unconditional (Not Boolean) are statements that perform calculations or actions without testing any conditions.
Conditional statements are statements that perform different calculations or actions based on whether the outcome of the boolean condition is true or false.

Tuesday, March 29, 2011

Source Code vs. Executable Code


In the world of programming, programmers should familiarize themselves with a number of programming terms to become effective programmers. Amongst the terms a programmer should familiarize themselves with are Source Code, Executable Code, Object Code, Assembly Language, Compiler, and Interpreter. Of the aforementioned programming terms, non-programmers often misunderstand and confuse Source Code, Executable Code, and Object Code with one another.  In some cases, non-programmers consider these three terms to mean the same thing. My goal for this commentary is to provide a description of the above-mentioned terms and how they pertain to Source Code verses Executable Code.

Let us start with Source Code. Source Code is the foundation of a program because it is the programmer’s original syntax for a computer program, which the programmer writes in certain programming language (e.g. Visual Basic). Computers do not understand Source Code. Another way to think of Source Code is to imagine a person writing a set of instructions, in their native language, for another person to execute. For this scenario, let us assume the native language is Spanish and the person who must carry out the instructions only knows English.

Next, we need a Compiler. A Compiler is a program that changes Source Code into Object Code. To add to our metaphors above, a Compiler would be like a Spanish/English translator who reads the instructions and then organizes them to an understandable format that the translator can then transform. This understandable format would be what is considered Object Code. Object Code, is the Source Code instructions after they have been collected and organized. Another option a programmer has besides a Compiler is an Interpreter. An Interpreter is program, which executes commands written in a high-level language. An interpreter translates high-level instructions into an intermediate form, which it then executes. In contrast, a compiler translates high-level instructions directly into machine language. Utilizing an Interpreter instead of a Compiler would be like having the translator carry out the instructions because the translator can read, interpret, and execute the instructions.

Once the Source Code is compiled into Object Code, the programmer would then need to convert the Object Code to Machine Language or Assembly Language. Machine Language is the lowest-level programming language, which is the only language that computers comprehend. Assembly Language is similar in construction to Machine Language but it allows programmers to utilized names instead of numbers. This conversion would be the translator rewriting the instructions in English so the person responsible for carrying out the instructions comprehends what they need to carry out.

The final step is the Executable Code, which is the code that is carried out by the computer. Executable code is like instructions, after they are translated and written in English, and then read by the person responsible for executing the instructions. Once all these stages are complete, the programmer should be able to successfully their program on the computer for which they wrote the program. In addition, the person who received the instructions from the person who spoke a completely different language should be able to successfully execute the them.

Wednesday, March 9, 2011

GUI Object oriented languages


In programming today, there are several tools available to facilitate many programming endeavors. The tools that will most benefit the programmer will be dependent on the programmer’s objective. Since there are an abundance of potential programming objectives out there today, let us focus on something simple, more specifically, a simple game. In addition, since there are so many programming languages / tools available today, we will limit our selection to one of the following programming languages:

BlueJ
Visual Basic
# Matisse in Netbeans
# JFormDesigner
# BuoyBuilder
# Visual Editor for Eclipse.
# SwiXML
# JAXX

If I were creating a simple game with a GUI (Graphical User Interface), I would have lean towards using an Integrated Development Environments (IDE) because I feel they make object-oriented programming faster, easier, and more efficient. From the IDEs above, I would definitely utilize Visual Basic because the programming language facilitates the creation of simple GUI applications and the more complicated applications. Another important factor is that Visual Basic developers devised the programming language to make programming easier for advanced programmers, but also enables new programmers to easily comprehend and utilize the language. Furthermore, Visual Basic allows the programmer to visually assemble controls on a form and since the attributes and actions for these controls are pre-defined, a programmer can develop an easy application without the programmer needing to write a lot of code. 

Programmers can also utilize Visual Basic to create executable files, ActiveX controls, or DLL files; but in most cases, programmers utilize Visual Basic to develop Windows applications and to interface database systems. Additionally, in Visual basic, programmers can utilize dialog boxes with limited functionality to supply pop-up capabilities and programmers can insert additional logic within the appropriate event handlers, while controls provide the basic functionality of the application. To put this into perspective, imagine a drop-down combination box that will automatically display a list and permit the user to select an item from the list. The event handler would then be called to execute additional code when an item is selected; which would execute an action based on the item that was selected, such as populating a related list. 

Another plus for me is the fact that programming in Visual Basic is the same as programming in Visual Basic for Applications (VBA). This is a plus because I have not written any programs in Visual Basic but I have written some small enhancements in certain office applications utilizing VBA. Based on this alone, I am pretty much sold on Visual Basic. One of the disadvantages of Visual Basic is that “all versions of the Visual Basic development environment from 1.0 to 6.0 have been retired and are now unsupported by Microsoft”. In addition, Microsoft does not support the related runtime environments. As of now, Microsoft only supports the Visual Basic 6 core runtime environment, and will continue to support it for Windows 7. I am happy to say that I am a Windows 7 holder, so I would still choose Visual Basic over the other programming languages.