Saturday, March 7, 2009

Programming Tutorial

Programming Tutorial - Computer Programming Functions: Get to Know What They Are

When it comes to computer programming vocabulary, there are so many terminologies that people who do not have enough know-how tend to become lost and confused. One term could be translated into so many different names in different languages. For example, the following words are quite similar: Functions, Programs, Subroutines, Procedures, Subprograms, or Subqueries. The only question now is which of these terms could stand on their own.

Theoretically speaking, computer programming avoids the duplication of any code in multiple spaces. For example, one institution utilizing the programs could have some libraries of different thousands or even more programs with billions of basic code lines. With such intricate case, duplication could still be avoided. Let us say that an error message occurs because the collection now needs to have an additional ‘member’.

A good example is the addition of another global currency called the Euro. If each and every program will be told to update itself because of this new addition, it could be complex. But with sub-programs or functions specifically designed to handle diverse situations, then the only function that would take care of the change would be the one assigned to handle such a scenario.

In the same way that we write new programs, many of the components that it will need are already in existence (e.g. accessing a certain file to dig up a certain data, computing inventories on hand). In cases such as this, a good alternative to writing different source code lines to work on the new function (and eventually replication of the code onto numerous other programs), the sub-program is accessed to work on the specified function.

In a handful of programming languages, there are certain parameters that are being passed from a specific program name to the program that is being called to do a task. A secondary program usually makes the values altered and then the control is brought back to the main program. These actions could be levels deeper. The various programs that are being used to call each other are written in so many varying languages. The reasons behind this are: to have a reasonable controllable function pieces and having various languages means being better able to suit different function types.

To further define the uses of programming functions, a function may appear in two different locations or even a single location. This depends on whether it is multi-line or single-line function. A function that is single line is one that gives back a value after performing tasks (all of this in a single line). The multi-line function, however, is stretched on many different lines.

A single line function could show in a code block all because it only responds when called by a certain name. The multi-line function does otherwise. If it is a multi-line function that is being defined in a block of code, then the statements that follow the definition are done in a non-sequential manner.

In its simplicity, functions are code blocks that can be reusable. These code blocks often return single values (sometimes they don’t’). Common examples of these code blocks are Mathematical functions (e.g. tan or log), date functions (figures between two dates), or string functions (looking for incidents of 1 string located within another string). Functions are also kept separately from the primary program code. A lot of programming language has specific functions which are delegated as entry points to a certain program.

Knowing what functions are in computer programming could take sometime to non-computer savvy individuals. But the basics are all here. Looking at the many complex things that functions do, you get to appreciate the things that the computer does for you each day, don’t you?
…Read more >>

Wednesday, February 25, 2009

Programming Code

Programming Code - Looking Adeptly at Programming Function Examples

Before looking at the different examples of programming functions, it is best to understand the purpose and definition of function. A function is the means by which someone who uses a program can execute a code block which has two purposes: to finish a certain task and to return values. Although functions are expected to return a certain value, it is not always that values are returned.

A function is also considered as a procedure in some programming languages. On the other hand, functions are commonly known as any term that is being used in referring to names of code blocks. Take note that it is the C programming language which solely uses the keyword function. Functions accept restrictions, they also return values, and they are maintained on a separate location from the code of primary program. The C language uses main function as the point of entry to certain programs.

Functions can show up in a single or two locations. This is dependent on whether the function is single line or multi-line. Having a single line function means a value is returned after the performances of work (in a single line) while the multi-line function is broadened over different lines.

Perhaps, the most common example of a programming function is a mathematical function. Log and tan are examples of mathematical functions. The other two known functions are string functions and the date functions.

Simply defined, a programming function allows you to assign certain values where results can be calculated in a matter of seconds while saving yourself from the task of doing the computations manually.

On the declaration or calling of a function which has two or more parameters, the use of comma is needed to separate the different parameters. One function declaration could resemble this :

function print_two_strings($var1, $var2)
{
echo $var1;
echo "\n";
echo $var2;
return NULL;
}

For these functions to be called, a value must be assigned to the parameters, hence :

Function call :
Print two strings (“hi”, “guys”);

The output should appear as:

hi
guys


One other good way to have active parameters is the use of PHP’s integral functions such as func get args, func get arg, and func num args functions. These functions are able to calculate arithmetic means of any values that are placed onto them and an output is derived. An example:

mean(35, 43, 3);

The output is then:

Mean: 27

A programming function is usually best when it returns some value or information. Functions do calculations, indeed, but it is also useful in indicating any errors that are encountered any function. To return an information from functions, you can use return () statement on the specified function.

An example of script for PHP is the following:



The result is:

The result of 2+4+6 is 12.


Take note that {} statement ended the course of the function. If multiple variables are to be returned, a group of variables should be returned, not a single variable: An example:

function maths ($input1, $input2) {
$total = ($input1 + $input2);
$difference = ($input1 - $input2);
$ret = array("tot"=>$total, "diff"=>$difference);
return $ret;
}

There are also ways of accessing functions without having to type a function name or {} syntax. This can be done in two ways: the call_user_func or the call_user_func_array. One complex example is the following :

$one = "One";
$two = "Two";
$three = "Three";
$callback_func = "my_function";
$result = call_user_func_array($callback_func,array($one,$two,$three));
echo $result;

These equations may show as a bunch of gibberish letters and numbers but these symbols actually account to make a certain task easier. And that, for us, is the most important thing.
…Read more >>

Saturday, January 10, 2009

Learn Programming

Learn Programming - Where to Find Online Magazines for Computer Programming

Computer programming is a field that lives on trends. This makes it important that programmers, computer enthusiasts and other experts in the field continuously update their skills and knowledge to remain competitive and relevant. Online magazines, for one, are an excellent source of new information about the discipline. There are several of these magazines that are very useful, particularly to students and professionals of computer programming. Below is a list of online magazines that you might want to check out:

C++ Source

C++ Source is an excellent online magazine for users of this language. The mag is filled with very informative feature articles, news and updates about C++ and its practitioners. There is also a section that offers tutorials for those who are still unfamiliar with C++, which makes this a very useful resource for students and professionals alike. To access the mag, go to www.artima.com and click on the link to cppsource.

Doctor Dobb's Journal

Dr. Dobb's Journal is one of the top online magazines that are currently active today. The mag features articles, tips, advice, book and software reviews, source codes and other resources that computer programming practitioners will find very useful.

Developer.*

DeveloperDotStar.com is an independent online magazine that offers plenty of information for professionals in the fields of computer programming and software development. So whether you're an enthusiast or a full-fledged programmer, a software engineer or a database designer, this online magazine holds a good variety of topics for you.

You can also subscribe to their online newsletter or peruse the website for articles and blogs. The site (www.developerdotstar.com) also has an FAQ section that you might want to check out. This is quite useful if you have a question about a particular issue.

Methods & Tools

This free online magazine is available either as a PDF file or a text issue. It offers some very practical advice and information about software engineering and development that professionals in this field will find very valuable. Past articles and issues may be downloaded from the archives – earliest issues date back to 1999. The site also has links to news, facts and information about software development tools that you might find useful.

Byte

Byte is not exactly an online magazine but it's too useful to pass up. The most sought-after features in this site are its articles, many of which were written by computer programming experts. The archive section which contains the columns and articles go back to 1994. To keep updated about the discipline, you can check out the site regularly for some very practical articles written by those who know computer programming best.

Leading-Edge Java

Leading-Edge Java is another online publication from Artima.com but it caters to users and developers of Java. So if you are a professional devoted to the language, you'll find this mag quite useful. Here, everything you'll need to pursue and refine your knowledge and skills in Java technology are yours for the clicking – news, write-ups, interviews with other professionals, tools, tutorials and APIs.

Visual Systems Journal

VSJ (www.vsj.co.uk) is an online magazine for computer programming that offers a huge variety of information for users of different computer languages. This is the perfect resource if you're using multiple languages or would like to learn more. It mostly offers technical information which beginner and more experienced programmers will like. It includes technologies and languages such as Java, XML, Visual Basic, database programming, .NET and web services, among others.
…Read more >>

Monday, December 15, 2008

Introduction Programming

Introduction Programming - A Basic Introduction to Computer Programming Topics

Computer programming is one of the fields under computer science. While computer science refers to the study of computer applications, computer programming deals with the basics of a computer program – how it works, how it is designed, how it is fixed and why. If you're planning to learn programming soon, here is an introduction to computer programming topics you're likely to encounter:

The basics of computer programming

Like most disciplines, you will begin by learning the fundamentals of computer programming. Depending on your instructor or curriculum, you will probably be introduced to the history of programming and its languages and find out about what has occurred over the years through a timeline.

You will also be introduced to the basic concepts and theories of programming and how they have evolved over the years. You'll be able to see how fast programming has progressed over the centuries and learn the significant developments in this field. You will also encounter topics such as computer hardware, software, systems and language. You will have to learn these basics in order to understand how your field of specialization can contribute. This may seem too troublesome but really, you need to have a good background in the progress of programming to help give you a good grasp of its fundamentals.

Computer software
The result of all your hard work is actually the computer software, so expect this topic to be included in your introductory course. Some of the topics you'll find under this subject include application software, programming software and system software. During classes dealing with these subjects, you'll learn how to use programming tools, database management systems, assemblers, debuggers, text and source code editors, and the like.

Programming
Finally, you will be introduced to the topic you've been raring to learn – programming. Here you'll learn different types programming processes, styles and methods. You will learn the different types of programming including concurrent, functional, declarative (event-driven), imperative, object-oriented and Parsing.

Probably the next topics you'll learn are the basic components of every computer program, such as the source code and the API or application programming interface. You'll also learn how instruction is carried out to command a computer to execute a particular set of directions.

You'll also learn programming languages, which will introduce you to the kind of language you have chosen to specialize in. Your instructor might also present your class with a simple comparison of the different types of languages in use today and you'll also probably learn the types of languages that have lost favor or are already obsolete. You'll learn semantics, dialects and theories.

This is also where you'll begin learning how to program or write codes. Although your learning at this point will consist of lectures, a good part of your class will be spent working hands-on so you can begin practicing what the instructor has taught you. This is how your progress as a computer programmer will be evaluated.

The process of programming
One of the earliest topics you will encounter when learning computer programming is the process with which codes and computer languages are designed and produced. The process of programming includes several steps, such as:
  1. Definition of the problem.
  2. Design or plan of the solution.
  3. Design of the code to be used for the program.
  4. Testing and evaluation of the program.
  5. Documentation.
Debugging, testing and maintenance
Probably the final list of topics you'll learn as your introduction to computer programming is application. In these topics, you'll learn how to test the program you have written, spot and locate any errors and correct them.
…Read more >>