Friday, September 20, 2013

Java Programming

PROGRAM DEVELOPMENT



The process of getting a program to run in a computer environment involves many steps.




*The program has to be written in the appropriate language. In this case it will be Java.

*Then the program has to be translated into a language that only the computer can execute. This code will be called bytecode.



Errors will occur in either step of the process of implementing your code. So let's look at these with more detail.



For example we all know that NYC is a melting pot with cultures and people from all around the world. Now imagine visiting NYC for the first time and asking someone for directions. But that person might respond in a different language that you don't understand. The person is not wrong because the directions are the same any way yo say it but you just can't understand them.



That's sort of what's happening here. Every computer has a different language it understands, Java let's us break through that barrier. With the the JVM as explained in my other .



This applies to most computer languages that can be categorized into the following four groups.



*MACHINE LANGUAGES: one of the first low-level computer programming languages are a set of procedures executed directly by the computer's CPU. The difference is that each procedure accomplishes a very specific task. For example it might take four separate machine language instructions to add two numbers together. Generally machine language it is written in binary digits and it is really hard for a normal person to comprehend it let alone write it.

*ASSEMBLY LANGUAGES: considered to be a another low-level programming language in which there is a strong congruity between the assembly language and machine language. Assembly Language is unique to each computer's CPU and was designed to simplify using Machine Language. It replaced using binary digits with mmemonics. This greatly improved the efficiency of early programmers that instead of using switches and binary code. They could use short English-like words that represented commands or data. But there was a tiny problem: Assembly Language cannot be executed directly on a computer. It must first be translated into machine language.

*HIGH-LEVEL LANGUAGES: mostly expressed in English-like phrases. Is a step higher than Machine and Assembly Languages and are very popular with programmers because of it's elementary approach. A single line of high-level language can accomplish the equivalent of many or even hundreds of machine language instructions.

*FOURTH-GENERATION LANGUAGES: an even higher programming language that is used to lessen the amount of errors in Third-Generation Languages (3GLs) aka High-Level Languages.



SYNTAX AND SEMANTICS



Every programming language that you will encounter will have its own unique syntax. Syntax is a set of rules inside languages that dictate how the vocabulary inside said language can be combined to form syntactically correct statements. These sets of rules MUST be followed in order for your program to run correctly. Else it will not compile. For example braces {} must enclose (begin and start) classes and methods. If the compiler does not find these braces your program will not run. During compilation, these syntax rules are checked and no leeway is given. When and if the compiler finds an error a message will be displayed in the console stating what the error was and where to find it. When this happens no byte code is produced. Luckily programming languages such as Java, C, and C++ have very similar syntax so it's a perk to know just one of these languages. In my experience I would recommend learning C or C++ before anything else. They are more difficult to learn and get a grip on but these languages as one of my professors put it are "Big Boy" programming languages. Java hides and babies you so much it is not even funny. No wonder even kids can program these days. Mind you Java is an amazing language to learn so don't let that discourage you from learning it. Semantics of a certain statement in a programming language defines what will happen when that certain statement is executed. In most programming languages the semantics are obvious and well defined, that means that there is only one way for each statement to be executed. So there should be no trouble there.



TYPES OF ERRORS IN PROGRAMMING



Everything is not perfect in this world not even in computer programming. There are different kinds of errors that will come up while writing code. Errors in programming may vary in both meaning and situations. One thing I've learned during various projects in computer science is that: "Computers are only as smart as we program them to be." Otherwise it's just a really expensive metal box. If something goes wrong then something must be wrong with your program and/or your data. Hence not getting the right answers we are looking for. Here are four kinds of errors that you will most likely come across.



*SYNTAX ERROR: is when the compiler checks to make sure that you are using the correct syntax for that specific programming language. If you've written statements that are invalid in that language you will get a syntax error. This is the simplest error to find and fix in Java. Usually the IDE will underline the error with a red line.

*COMPILE-TIME ERROR: is any error identified by the compiler. In this case a Syntax Error is a Compile-Time Error.

*RUN-TIME ERROR: is when a program ends abruptly. For example if we divide any number by 0 the program will crash because that operations is undefined by the system.

*LOGICAL ERROR: is by far one of the hardest and most difficult to find. Fixing it might be easy but find it is a total horror for me at least. With this error your program will run as if nothing has gone wrong, except you have incorrect results at the end. It is your job to find and fix this error. This process is called debugging. When debugging make sure you test your code thoroughly and test various scenarios that can and might happen. Even thought it might be one of the hardest errors to get while programming it is a good way to prevent that your program crashes when the user does something wrong. Because it's never the person's fault, its the programmers.



SOFTWARE QUALITY



So with the talk about errors we being the topic of software quality. The most important goal of a software developer/software engineer is the client and the product that is delivered to them. Therefore there are several things to keep in mind when going about our projects.



*Deliver a high-quality solution.

*Solve the right problem.

*Deliver a solution that is on time and within a determined budget.

*Most importantly is accomplish all these things in an ethical manner.



The building blocks of modern software development is the organization, storage and retrieval of data and in this first course of computer science these topics are greatly emphasized. The following are the aspects of software quality.



*CORRECTNESS: the level at which software adheres to its specific requirements.

*RELIABILITY: the rate an criticality of software failure

*ROBUSTNESS: the level of which erroneous situation are handled.

*USABILITY: the lack of difficulty in which users can learn and execute tasks within software

*MAINTAINABILITY: the lack of difficulty in which changes can be made to the software.

*REUSABILITY: the lack of difficulty in which software components can be reused in the development of other systems.

*PORTABILITY: the ease in which software components can be used in multiple computer environments

*EFFICIENCY: the the ease in which software fulfills its purpose without wasting resources.
Full Post

No comments:

Post a Comment