Home > Java > javaTutorial > body text

How to introduce programming to a novice programmer?

伊谢尔伦
Release: 2016-11-26 10:50:44
Original
1049 people have browsed it

Learning Java, they all say it’s easy.

As a college student who just graduated from the Computer Science Department of the University of Wisconsin-Madison, I have met many friends who use Java through some programming courses. Many schools are now switching from other programming languages ​​(mostly C++) to teaching Java. A study conducted in July 2014 showed that as of the time of the survey, 22 of the 39 top American CS programs already used Java. As an introductory course.

So, what exactly makes Java stand out from many teaching languages? Looking at all aspects, we found some clues:

The syntax is relatively simple (compared to C language and C++), and there are fewer difficulties (compared to C language and C++). The simpler the syntax means the fewer rules that novices need to master, which is definitely a boon for novices.

Compared with some traditional teaching options, such as C and C++, Java is less error-prone because many operations are automatically checked. If the array you want to access exceeds its bounds or an exception is generated using a null object, the program will tell you what went wrong and where it went wrong with a nice stack trace (narrowing it down directly to the source of the problem) file). In contrast, in C language and C++, if a null pointer is accessed, the program will explode like a bomb without warning, leaving you without any useful prompt information (unless you are running in a debugger, so we Must learn to use a debugger, just in case). And if the arrays in C language and C++ cross the boundary, it will be even more tragic, because in many cases, the values ​​of array elements in memory may even be inexplicably overwritten. Then you're left stunned and completely helpless to deal with this crashing program. This is definitely a rhythm that drives a programmer crazy every minute!

Having a garbage collector means that you don’t need to manage memory yourself. After an object is created with the new keyword, it will remain in memory forever (as long as it is referenced anywhere). And after using this object, the garbage collector will clean up this object for you.

Java is widely used in industry, so, in theory, what we learn in school can be directly translated into real jobs. The TIOBE programming index ranks it as the second most commonly used programming language. Whether you agree with TIOBE's accurate analysis or not, you have to agree with the current situation that Java is widely used.

Java is object-oriented. You create objects that contain data, and then write methods to describe behaviors that act on that data.

The above sounds so beautiful! But it's not complete.

Detour Strategy

The first program almost any programmer writes in any language is "Hello World". All it does is display some message (traditionally "Hello World" is selected) and then exit, very simple. The following is a Hello World program written in Java:

public class Hello {
public static void main(String[] args) {
System.out.println("hello, world");
}
}
Copy after login

Some people who are completely new to programming will have doubts, and then if you are a teacher, hehe, trouble will come. Trying to explain everything to students at once can be the straw that breaks the camel's back, so it's better to take a more circuitous approach.
"Excuse me, what does public mean?" - There is no need to think about this now, we will explore it in depth later.
"What is class?" - There is no need to think about this now, we will discuss it in depth later.
"What does static mean?" - There is no need to think about this now, we will explore it in depth later.
…Wait, you can say that.

But it is worth mentioning that no matter what content is taught, we should break it down into components that are easy to digest and understand. Important knowledge such as encapsulation (public keyword), object-oriented programming (class and static), arrays (String[]), and command line parameters (args) should be explained to students in a timely manner. Of course, for those freshmen who are still in the enlightenment stage of programming, it is too far-fetched to think that they can become a big fat man in one bite. I know many friends who are definitely leaders in other fields, but when they encounter these programming concept problems, they are immediately overwhelmed. It's like having this suddenly introduced in algebra:

How to introduce programming to a novice programmer?

Once we know what these symbols mean, it doesn't seem that difficult to understand. But for those freshmen who are just getting involved in this field, this is nothing less than a wordless bible. Furthermore, although the detour strategy encourages students and prevents them from becoming discouraged immediately, from another perspective, it only superficially demonstrates some "magical" results without analyzing and explaining its principles. But I would say that if you want to grow as a real teacher, this approach should be completely contrary to your philosophy. For example, Hello World,

Java is strictly object-oriented and requires every function (or "method", in Java parlance) to be placed in a class. If you haven’t read the excellent article Execution in the Kingdom of Nouns, I highly recommend you do so. Its main content can be summarized as, "Advocating object-oriented programming is like tailoring clothes for guests." Explaining object-oriented design principles to freshmen who are still confused by concepts like if statements and for loops is a bad call. We should focus on breaking down the work into small pieces that can be written as functions, and then we will come back to what OOP is.

Java stipulates that all objects are allocated in the form of heap, so all object variables are pointers. Now what you need to explain is the difference between values ​​and references, like why ints, booleans, and floats behave differently from strings during assignment and comparison. Derived questions like these together form a consistent mental model that explains how things work - a must for programmers - but the process is extremely arduous.

Java may be a really great programming language for developing programs (regardless of size), but it is definitely not friendly to beginners.

So what language should we teach?

In this case, some people may ask, shouldn’t it be enough if I first learn some simple concepts and then learn Java in depth based on these? ! But I'm sorry, Java said that I can't do it!

So what should we do? The following two reasonable ways to start programming may give you a sense of enlightenment:

Start at a low level, and then increase the difficulty step by step. Teach you how to use a computer so that you can write some simple programs directly in C language. Then on this basis, a higher-level computer science structural system is constructed.

Start at a high level and then lower the difficulty step by step. Start by teaching computer science theory and a programming language that is very easy to implement without having to worry about the details of the underlying machine. Python, for example, is a good choice here because it does not require front-loading Java. Influence. Then break down how computers implement these theories step by step.

Now, the second method is becoming more and more popular, which can be seen from the research mentioned at the beginning of this article - the fact that Python has surpassed Java to become the most widely used introductory programming language.

No matter which method you choose, the key is to keep students interested. If you choose a low-level starting point approach, use an Arduino or robotics kit so students can see the code they write in the physical world. In other words, as soon as I started writing code in C language for a robotics team, I was deeply fascinated by this fantasy world: watching the 120-pound steel pipe and rotating motor move because of the code I wrote. , that feeling is really magical and incredible. If you choose a high-level starting point approach, you might want to use the resources in the library to create a video game or other graphics program.

How to introduce programming to a novice programmer?

Programming is incredible. Nothing can limit you except your imagination and ability to express yourself. Find the entry point of students' interests, teach them through fun, from easy to difficult, step by step, teach them how to use tools, teach them to fish rather than teach them to fish, and let them grow freely and crazily in the world of programming.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!