When choosing a programming language, there can be many factors that can influence your choice. For example, if a programming language uses lots of symbols and has a illogical structure and you are new to programming, more then likely you're not going to use that language.
Ease of learning
Ideally if the language is a very easy to learn, for a beginner they are more likely to learn this language other than a language that is really complex and has a . For example visual basics is easier to learn than something more complex like Java or C++. But after programming for a while, this becomes less of a factor due to learning other languages and understanding the complex structures.
Ease of understanding
Understanding a programming language can be either simple or complex. For example a procedural programming language which reads the code in steps/stages allowing you to write a logical code which will be a lot simpler to understand than a programming language that uses event driven programming language which uses lots of loops to check for active events.
Speed of development
Speed of development can be very important in choosing a programming language especially if you have a deadline. Different languages have different ways of writing the same or similar code, each one of these can vary in length, like if two different languages try making a graphical box with a input forum.
Fit for purpose
This is undoubtedly the main reason for choosing a programming language. Like, if you're wanting to make a event driven program, there is no reason to choose a program which is procedural based as this will be incompatible for what you are trying to make. If you are wanting to make a program which uses several different features like procedural, event driven and object orientated, you would use a programming language like java or C++ etc...
Compatibility
This is another important factor as depending on the platform you are wanting to program for decides what the list of languages you are able to use, if you are trying to design a program for a android device, you're not going to use a programming language like batch as it will be incompatible therefore making the code useless to the system it was designed for.
Thursday, 6 November 2014
Wednesday, 5 November 2014
PARADIGMS- Application and limits.
Procedural programming paradigm.
Procedural programming is programming that works in steps, it can be used to create a series of instructions. Its practical application is being able to solve calculations for things like scientific or engineering usage.
In this code snippet, it shows the calculation of one person's gamer score over a months period. |
Event driven programming paradigm.
Event driven programs allow you to make programs more interactive, this is very important as all modern programs which us a GUI are event driven. It allows sensors and other hardware to easily interact with the software. The disadvantages/ limits to event driven programming are things like when trying to make a simple program, the coding may become too complex and illogical. Also, these programs take up lots of processing power due to their constant active loops.
Object orientated programming paradigm
Object orientated programming is a programming language which is based/ organised around objects instead of actions and data. The applications of object orientated programming are:
- It is easier to change and modify codes.
- It encourages the programmer to place the code inside of the class so its not as directly accessible from the computer's system, instead the system needs to call the data to be able to use it.
Monday, 3 November 2014
Key features of event driven programs
Service orientated.
Service oriented driven programming only runs when it is needed or when a event occurs like for example when a file is make or a new device is installed, these services can be ran in parallel allowing multiple actions to be ran at once.
Time driven.
A time driven is a code that uses time called a "timer", this is the trigger to this event. For example the timer could be set for a server to back itself up at 6pm everyday. Or a example that everyone knows is Google docs which saves automatically, this is a time driven event
Event handlers.
A event handler is a function or a method containing program statements that are executed once a event is triggered. A event handler is a routine used to handle the event that was triggered for example in javascript:
<form action="#" method="post">
<input type="button" value="Click for a Message" onclick="window.alert('Hello!');">
</form>
Once the button is clicked the event handler creates a pop-up saying "Hello!"
<form action="#" method="post">
<input type="button" value="Click for a Message" onclick="window.alert('Hello!');">
</form>
Once the button is clicked the event handler creates a pop-up saying "Hello!"
Trigger functions.
Trigger functions are used to identify and define which event handler should be ran after the trigger has taken place.
Events (e.g. mouse, keyboard, user interface.
In computing, a event is a action that can be detected by the program like for example in java when someone clicks a button it closes the JFrame, another example is when you start your computer up, if you press F12 it opens up the boot menu, pressing F12 is the event.
Pre-defined functions.
Predefined function in java are are functions which are defined inside of the java library. These functions are things like "System.out.println("Hello world!")". This predefined function displays a message on your screen saying "Hello world!". This predefined function can also be used to display other predefined functions, for example:
"String sName=”Alex";
char cPosition=sName.charAt(0);
System.out.println(“The letter at position 0 is “ + cPosition);"
In this, the first letter of the string sName is identified and then displayed on the screen.
Local variables.
"String sName=”Alex";
char cPosition=sName.charAt(0);
System.out.println(“The letter at position 0 is “ + cPosition);"
In this, the first letter of the string sName is identified and then displayed on the screen.
Local variables.
Local variables are variables that are declared within methods and they are only visible withing the declared method. Local variables are useful for storing data but they are only available within the class it is defined in. Examples of local variables in java:
char cInitial='A';
int iAge=16;
The char method can hold one letter like in this example is "A". Whilst the int method can contain integers between -214748367 and 214748367.
char cInitial='A';
int iAge=16;
The char method can hold one letter like in this example is "A". Whilst the int method can contain integers between -214748367 and 214748367.
Global variables.
A global variable is a variable that is visible throughout the entire program (unless the variable is shadowed). The set of all of the global variables is known as the global environment or the global state. But global variables are only accessible once they have been declared. For example in C++ a global variable that can modify age:
int age;
int main(){
age = 18;
int newage = age + 5;
}
int age;
int main(){
age = 18;
int newage = age + 5;
}
Parameter passing.
Parameter passing is the mechanism/method used to pass parameters to produce a function. The most common method used is to call/ pass the value of a parameter or to pass the location of the parameter. The less used method for parameter passing is to change the value of a parameter. For example using C# this example shows both of these methods.
class Program { static void Main(string[] args) { int arg; // Passing by value. // The value of arg in Main is not changed. arg = 4; squareVal(arg); Console.WriteLine(arg); // Output: 4 // Passing by reference. // The value of arg in Main is changed. arg = 4; squareRef(ref arg); Console.WriteLine(arg); // Output: 16 } static void squareVal(int valParameter) { valParameter *= valParameter; } // Passing by reference static void squareRef(ref int refParameter) { refParameter *= refParameter; }}
Modularity.
Modularity is designing a program or a system where it is divided into sets of modules that are can be used to create a larger application allowing it to be used and created easier as you can use the modules in other programs other than the one intended. Creating modules also makes the code a lot easier to read and debug and test. Here is a example of how modularity works.
Procedures.
Procedures are a structured section of a program that . Procedures are also known as methods, routines, functions etc... During any time of the program being executed a procedure may be called for example a string may be called at any time. A procedure is like a set of basic instructions for the computer to follow.
Programming libraries.
Programming libraries allow different methods to be used like for example, the package in java to use graphical resources is written like this:
import javax.swing.*;
Using this package/ library allows you to use methods such as:
String sName= JOptionPane.showInputDialog(null,"What is your name?","Name",JOptionPane.QUESTION_MESSAGE);
This will display a box on your screen asking for your name and if nothing is input it is saved as "null" or the string will be saved as what was input.
import javax.swing.*;
Using this package/ library allows you to use methods such as:
String sName= JOptionPane.showInputDialog(null,"What is your name?","Name",JOptionPane.QUESTION_MESSAGE);
This will display a box on your screen asking for your name and if nothing is input it is saved as "null" or the string will be saved as what was input.
Event driven programming paradigm for simplicity of programming and ease of development.
Event driven programming is extremely simple and easy to used as you encounter less errors due to advanced debugging, the code may be paused and played when ever needed. When creating events in things like visual basic studios when making something like a button the code for the button is automatically generated for you needing less knowledge of programming to actually create a event driven program. Prototypes are simple and easy to build and you can add extra features when ever necessary this can aid in rapid development for applications.
Subscribe to:
Posts (Atom)