Bidvertiser Advertisement

Kamis, 30 September 2010

What Is Programming

“Developing software”, that is a simple definition of programming. But although it has a simple definition, it is also really difficult to do it. In simple way, we have to connect between computer’s user and computer hardware itself. Computer’s language and human’s language is 180 degree different. If we want to communicate with computer, we have to translate their language into our language. Of course the result of language translation is not dynamic, but static. That’s why, if we want to do a good programming, we have to study many years. When we make program, we have to make a decision how to make a user interface that the computer user can understand easily, or we can call it “User Friendly”. We also have to understand how all computer’s hardware work. The order and the priority of hardware when they do something, that’s what we have to really understand. If we make a good programming code, so the software will run perfectly, but if we make a wrong programming code, so there will be a crash between hardware and software that we were made.
Based on what orientation the programs were made, we can make it on 3 groups: Operating System Programming, Application Programming, and Web Programming. Operating System Programming is the basic programming, but it has the most complexity from all kind of programming. Why? Operating System is the basic software that communicates hardware and computer’s user. So when people want to make an operating system, they have to make sure that all of the program’s tools that they make support what computer’s user need. The example of operating system programming is: Windows Operating System, Apple Operating System, Linux Operating System, and many others. From the entire example, Windows Operating System is the most familiar Operating System for us. How operating system works? When operating system wants to communicate with the machine, they have to connect ALU (Arithmetic and Logic Unit). May be some of us know about it. ALU is the most difficult language, because it just contain of 2 words: 0 and 1. So, we can also say that Operating System change machine language into the combination of 0 and 1. It is really difficult isn’t it?
Application is part of operating system. That’s why application programming has to communicate to operating system first before it communicates with the machine. Application programming is less complex than operating system programming. The language to make is still difficult, but if we want to learn, we can understand it. Usually the language is used by us in daily such as: “if”, “when”, “until”, “begin”, “end”, and many others. That’s why if we want to find an application programmer that will be easier than find an operating system programmer. In Application programming, a programmer can choose a lot of framework. Framework is kind of language communicate between application and the compiler. Compiler is a translator of application language and operating system language. Compiler is global. All computers know compiler language. But the application language has many kinds. For example: Visual Basic, Java, C++, C, Delphi, and many others. Usually a programmer has a special application language. Some people only really understand Visual Basic Language, but they don’t really understand about Java Language. That’s why there are Java Programmer, Visual Basic Programmer, C++ Programmer and many others.
When we want to connect internationally, web programming is the answer. This kind of programming can communicate all computers’ user in the whole world by “http://” protocol. This kind of protocol is an international standard. So, all computer and operating system will understand about it. Web programming is kind of programming that can only work in browser application, such us Internet Explorer, Mozilla Firefox, Opera, and many others. If we are internet users, we must be know about it. The purpose of web programming is to make a good interface in Browser Application, so the readers of a site interested and can make a responds to site administrator. Recently, web programming is the most popular programming, because all of the company wants all people in around the world know about their company, or we can call it to advertise their company around the world. This is a really effective advertisement. If we want to do a web programming, we have to understand some language, such as: html, asp.net, javascript, php, asp and many others.
If we talk about the method that a programmers were used to make a program, we can make it on 2 groups: Procedural Programming and Object Oriented Programming. Procedural Programming is the easiest programming method for a programmer. Why? Because procedural programming just contain of some “modul” that make operation, procedure, combination of programming become only one part. This kind of method programming was not effective if the software that was made is large software. Why? Because, if there is some problem on the software, we have to look on the programming code one by one to solve the problem. Therefore, this kind of programming is not popular in software developing. Procedural programming is good for a beginner that wants to learn about programming algorithm and programming basic language. Algorithm is kind of the way we have to do when we will do an operation in programming. If you are a new student in IT Faculty, you will get some lesson about procedural programming.
To solve procedural programming weakness, there is Object Oriented Programming. This kind of programming is more complex than procedural programming. Each operation, procedure, and combination of programming was separated in some part of programming that called “Object”. It means that in one object, handles special operation, method, procedure, and combination. An object can also contain another object. This kind of object is used to collect all of objects that have similar operation. That’s why object oriented programming is easier when we want to make correction on programming code. We just go to the part of operation (object) that have problems and change the programming code. But, object oriented programming is really difficult to understand. We have to really understand how to make an effective operation, procedure, and combination, so the objects that were made can solve all the software need. It will be more effective if one object can solve more than 1 operations. Less objects in the program, it is better for the program (software). By Viktor Mononimbar (Script Maniac) .

Kamis, 16 September 2010

A Simple Thread Example

The simple example shown in full on the first page of this lesson defines two classes: SimpleThread and TwoThreadsTest. Let's begin our exploration of the application with the SimpleThread class--a subclass of the Thread class, which is provided by the java.lang package:
class SimpleThread extends Thread {
    public SimpleThread(String str) {
        super(str);
    }
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(i + " " + getName());
            try {
                sleep((int)(Math.random() * 1000));
            } catch (InterruptedException e) {}
        }
        System.out.println("DONE! " + getName());
    }
}
The first method in the SimpleThread class is a constructor that takes a String as its only argument. This constructor is implemented by calling a superclass constructor and is interesting to us only because it sets the Thread's name, which is used later in the program.
The next method in the SimpleThread class is the run() method. The run() method is the heart of any Thread and where the action of the Thread takes place. The run() method of the SimpleThread class contains a for loop that iterates ten times. In each iteration the method displays the iteration number and the name of the Thread, then sleeps for a random interval of up to 1 second. After the loop has finished, the run() method prints "DONE!" along with the name of the thread. That's it for the SimpleThread class.
The TwoThreadsTest class provides a main() method that creates two SimpleThread threads: one is named "Jamaica" and the other is named "Fiji". (If you can't decide on where to go for vacation you can use this program to help you decide--go to the island whose thread prints "DONE!" first.)
class TwoThreadsTest {
    public static void main (String[] args) {
        new SimpleThread("Jamaica").start();
        new SimpleThread("Fiji").start();
    }
}
The main() method also starts each thread immediately following its construction by calling the start() method. To save you from typing in this program, click here for the source code to the SimpleThread class and here for the source code to the TwoThreadsTest program. Compile and run the program and watch your vacation fate unfold. You should see output similar to the following:
0 Jamaica
0 Fiji
1 Fiji
1 Jamaica
2 Jamaica
2 Fiji
3 Fiji
3 Jamaica
4 Jamaica
4 Fiji
5 Jamaica
5 Fiji
6 Fiji
6 Jamaica
7 Jamaica
7 Fiji
8 Fiji
9 Fiji
8 Jamaica
DONE! Fiji
9 Jamaica
DONE! Jamaica
(Looks like I'm going to Fiji!!) Notice how the output from each thread is intermingled with the output from the other. This is because both SimpleThread threads are running concurrently. Thus, both run() methods are running at the same time and each thread is displaying its output at the same time as the other.
Try This: Change the main program so that it creates a third thread with the name "Bora Bora". Compile and run the program again. Does this change the island of choice for your vacation? Here's the code for the new main program, which is now named ThreeThreadsTest.

I got This Source Code From : karlin.mff.cuni.cz
I hope you enjoy it on original site. Keep coding, and make some program. Viktor Mononimbar, Source Code Maniac.