Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!

John M Morrison

Greenhorn
+ Follow
since Jul 25, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
2
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by John M Morrison

The second edition was a real go-to book.  My students will often hear, "In the Bible accorging to Bloch....." when I discuss matters of programming technique or style in my classes.  I look forward to his commentary on Java's new features.
1 year ago
This has chat rooms but a whole lot more, http://www.stackoverflow.com It caters to intermediate to advanced programmers.
5 years ago
The semi on line 25 is decapitating your while loop.
5 years ago
Make sure you are running the class with the main method. If you attempt to run class Dog, you will get that error. Also, make sure you have these classes in the same directory.
5 years ago
You should declare the File before the try block. You will want to send an error message if the file fails to open, so you will want this object to be in-scope for the catch block.
6 years ago
Do not get the impression I have a language bias. I am a language agnostic. The reason I like python for beginners is that, in a fairly short period of time, the students can see that computing can help them to accomplish real work and enable them to do significant tasks. It seems to be that this language is in the "Goldilocks sweet spot;" i.e. that the level of abstraction is "just right." Python is an effective tool for engaging the students' enthusiasm and interest. At this early stage of the ballgame, this is very important. If you frustrate your students with excessive abstraction or with operating at a very low level at an early stage, they don't go on and they don't develop, and they choose other fields.

It is a deliberate decision of our program for students to be exposed to more than one language. Our introductory course teaches procedural programming using Python. This is the first third of the year. The other two thirds focus on event-driven application development and on object-oriented data structures. We like for our students in each class to write a nontrivial application that applies the concepts they learned in the class. The switch from Python to Java shows the students early-on that different languages have different architectures, but that they do many of the same things. We place a strong emphasis on our students being able to read documentation and on being able to apply it to solve some problems they are working on. We are not producing "API Monkeys," but resourceful people who know how to scrabble out the solution to a problem. We develop the attitude of "use wheels, don't reinvent them." However, it is sometimes necessary to invent a new technique to solve a problem; our students learn to be resourceful and handle those situations as well. As we all know, there is no neat connection between existing code-bases and the new things we wish to accomplish.

In our second-year classes, we often program in C. By the time the students are to this level, this experience is meaningful and not frustrating. Our approach has bene successful. We have a program that is growing and we sending an increasing number of students off to the university who major in computer science, computer engineering, and related fields. Many of our students do co-op experiences at local companies, and their experience has been good. The are clever enough to be doing real work pretty quickly.
6 years ago

I have taught Java, C++ and Python to beginners. My preference is Python. Here are some of my reasons.




  • Python syntax is straightforward. Hello World is short and sweet. I don't have to explain "plumbing."

  • Python supports OO, procedural and functional programming.

  • It is easy and free to get Python running on all platforms.

  • Python is <em>not</em> a free-format language. Students who first learn Python have nice formatting habits.
    They understand that good formatting is your firend.

  • Python's interactive shell is a great teaching tool.

  • Python pads C's sharp corners. When I teach C, we re-examine Python and learn what happens underneath. Then the
    whole shebang is plausible and natural.



I also expose my students to programming at the UNIX command line. This course has been quite successful.



7 years ago
Thank you! This is an important question and the answer is excellent.

JMM
10 years ago
Head First Java does an excellent job of explaining listeners and events.
10 years ago
You can make your class executable by adding a main method as follows



You should capitalize your class name (frame -> Frame); this is a universal convention of Java programmers. You can then see your empty frame displayed on the screen. As you add stuff to the content pane, you can run your program and watch it appear.

JMM
10 years ago
State variables of classes should always be declared private, unless they are constants.

This is the way of saying "NO USER-SERVICEABLE PARTS INSIDE"

You can protect your state variables from such things as illegal initializations. Imagine this class

class Date
{
public int month;
public int day;
public int year;
.
.
.
(other entrails)
}

class Foo
{
d = new Date();
d.month = -5;
d.day = 433343;
d.year = 1900;
.
.
.
//more inept client code.
}

Can you imagine anything uglier?


By allowing access to state variables, you break encapsulation and you destroy the integrity ofyour class. You also foreclose the possibility of EVER changing the implementation of the class.

Keep your state variables PRIVATE!
11 years ago
Abstract classes provide an intermediate facility between regular (concrete) classes and (totally abstract) interfaces.

If you are creating a related family of classes, you can avoid maintaining duplicate code by pushing implmentations as far up the class tree as you can to their common origins. You can leave methods abstract for which you want polymorphism but for which you do not yet have enough specificity for a meaningful implementation. An abstract class is a "partially implemented" interface.

Take note that any class with an abstract method MUST be abstract, but you may declare a class abstract even if none of its methods is abstract.

In no case, may you instantiate an abstract class.
11 years ago
When you inherit, you inherit the public interface. You don't want to override private methods of the base class. Presumably, they exist to serve the public interface.

I am not a big believer in protected methods and state variables.
[ August 06, 2008: Message edited by: John M Morrison ]
We have been using Python as a first language at the North Carolina School of Science and Mathematics for five years. Anyone else out there doing that?
11 years ago
You should initialize instance variables in the constructor(s) or the static block if they are static. This is better and cleaner style. I strongly discourage my students from doing stuff like this



Yuck. Create proper a proper static block (if needed) and proper constructors. This makes your intent as a class designer explicit.

JMM
11 years ago