Help, teaching 12-13 year olds to code

Started by
29 comments, last by albert666 11 years, 7 months ago
I tried to teach my students OOP in the beginning but I am not sure how good of an idea it is without proper context. It may be a case of the cart leading the horse...

I tend to think OOP is overused and not fully understood by many software engineers/developers. That is not to say OOP is a bad concept or that it does not have good applications, but it is not a panacea.

I think given limited time my main priorities are to instil the concepts of variables (and the relation to algebra, which I consider important), program flow control (if statements, for loops, etc), rudimentary data structures (arrays, vectors, dictionaries/hash tables, ect), and file i/o. For 2D game programming I tend to stress mouse/keyboard input, screen coordinates, and vectors in 2D (I even try to work in some basic trig/Pythagorean theorem/use the Pythagorean theorem to derive the distance formula).

For me Game Maker worked well to teach basic OOP because every thing "was" an object. They were using OOP without having to really get into the full details of what it was.

I think it might be worth keeping in mind that the sheer amount of material you could cover is much larger than the amount of material you can cover in the time period. Also that such concepts are instilled typically in four years of schooling and if you have to build up the math, your looking at more like eight... If you are trying to condense that into a camp you must pick your battles!

I like the idea of Warcraft 3, but that involves money to buy enough copies of the game. Some parents might object to their kids playing such a game (you would be surprised), and it may get their hopes up a bit in terms of wanting to do 3D for everything. Why go to 2D when they were "just" using 3D? It may be a good idea to work in such things at the end of a course, but I am a bit dubious as to putting it at the beginning. Also in my experience the less you have to install on a school computer system the better. I can tell you right now that the school WILL object to putting a "game" on the computers, and good luck trying to get the kids to STOP playing it and do the more "boring" stuff. Also the computers I dealt with had the hardware acceleration disabled (or... they never had it to begin with), so I have a large amount of doubt that warcraft 3 would even run..

If I was going to do anything 3D, I might chose to incorporate Alice (or Storytelling Alice) because it would add some balance to the course. There have been groups using it with good results for motivating middle school girls to learn computer science. I do have to hesitate because I do not want to say certain things are for "boys" and others are for "girls" (which is generally a dangerous notion and one that should be avoided), but even so adding such concepts may appeal to students who prefer storytelling.
Advertisement

-


Maybe I'm stating the obvious but if I was teaching kids my first priority would be to get them to understand the concept of OOP (mainly inheritance).

That is a terriible terrible idea, and probably the reason why so many beginners tend to create complex class hierarchies even in the most trivial situations, and even though it doesn't buy them anything. Inheritance should be used about as often as function pointers are used in C programming, and for about the same purpose (multiple dispatch).
[/quote]
Did you even bother to read the rest of what I wrote? If you are going to quote me, quote the whole thought not just the section that you want to harp on. What I was suggesting was to let them write code without OOP until it becomes unmanageable for them. Then give them the extra tools as a solution.

Are you saying that there are no other benefits? Like code that documents itself? Or avoiding copy-pasting to implement similar but subtle differences in logic? How about code that can actually be tested in bits and pieces (components) rather than the whole damn thing at the same time?
Take care! OOP is dangerous since it is actually a concept for lazy programmers without a future oriented view. It is not realistic. In most cases reusability, the most important criteria in software development, is messed up. So after a somehow logical design, the code is misused often to suit to reusability, which brakes the OOP paradigms. Interfaces are important, OOP not. I programmed C++ and C a long time ago. Now Java. I never use inheritance in big commercial projects, and had success with this. After several years of programming and 5 years of studies, I realized that some people introduced OOP and nobody really asked, if this makes sense. The answer is, it is not reasonable!
The problem of Object Oriented Programming:Everybody tells you how to use his classes, but nobody how not to do it !

[quote name='alvaro' timestamp='1346725535' post='4976278']
Maybe I'm stating the obvious but if I was teaching kids my first priority would be to get them to understand the concept of OOP (mainly inheritance).

That is a terriible terrible idea, and probably the reason why so many beginners tend to create complex class hierarchies even in the most trivial situations, and even though it doesn't buy them anything. Inheritance should be used about as often as function pointers are used in C programming, and for about the same purpose (multiple dispatch).
[/quote]
Did you even bother to read the rest of what I wrote? If you are going to quote me, quote the whole thought not just the section that you want to harp on. What I was suggesting was to let them write code without OOP until it becomes unmanageable for them. Then give them the extra tools as a solution.[/quote]

I did read all that. It's a good plan, but the emphasis on inheritance is misguided, in my opinion. I was only arguing about that part, so I only quoted that part. I think it's easier to follow the argument when following that style of quoting.


Are you saying that there are no other benefits?[/quote]

Yeah, pretty much.


Like code that documents itself?[/quote]

Code that documents itself is a good thing, but unrelated to inheritance. You can write clean self-documenting code without inheritance. I do it all the time.


Or avoiding copy-pasting to implement similar but subtle differences in logic?[/quote]

I am unaware of how inheritance helps with that. Extracting common functionality into its own function, particularly when you can give that function a good name, is extremely useful and should be emphasized to beginners. In the case of member data, more often than not the correct relationship is "HAS A", not "IS A", and you should simply have a member of the type that implements the common functionality, not inherit from it. Using inheritance as the default is a problem.


How about code that can actually be tested in bits and pieces (components) rather than the whole damn thing at the same time?[/quote]

I saw a Google tech talk once that advocated using polymorphism instead of using `if' statements in most cases, with enormous emphasis on testability. It sounds like an interesting concept, but I have never seen it put to practice.

If that's what you had in mind, you have a point. But this is not the way most people use inheritance, and it's unclear to me if this style of coding is appropriate for beginners.

There are many other things that are more important to learn. I would put the emphasis on defining clean interfaces between parts of the code and giving things good names. Beginners tend to think of code as something that a machine will read, but I think they should think about it also as something that a human will read, and they should make the human's life as easy as possible.
and then moving on to gdi+ game development


This is a hideous idea... GDI/GDI+ isn't designed for that kind of use. It's really designed for use with Win32 within a paint message not to be used at the kind of rate you'd expect to be drawing a game at.

If you're using C# and running XNA on a PC is out of the question can you not find a cheap Xbox and run their games on that?

On an unrelated note the best programming book I've ever read is actually "The C Programming Language" written by Ritchie and Kernighan. ANSI C is a very, very small language and the book covers them in a brilliant way. Particularly the language's enforcement of having variables declared at the top of the scope. If what alvaro says is true about the kids being able to handle the abstract thinking I see now problem with teaching them the more basic constructs at them before teaching OOP.


Maybe I'm stating the obvious but if I was teaching kids my first priority would be to get them to understand the concept of OOP (mainly inheritance).

That is a terriible terrible idea,
[/quote]

I have to second this.
As a kid I got started with BASIC.
The cool thing about basic is that you don't even need functions.

Your average 12 year old does not understand:
1. If statements
2. Functions
3. Loops
4. Variable Typing
4a. Variable declaration
5. Splitting code into different modules etc...
...

BASIC did not require any of these concepts to generate a cool result.
As a kid, easy success is a great motivator.

Since basic does not really exist anymore (Visual basic is more like C# / Java),
I am thinking one might think of toying around with java-script as a first language.
It does not require any of the above (you can even use undeclared variables in global scope).
It might actually be useful for the kids later.

Little by little you can add the more complicated concepts listed above.

The downside is And there are no easy input functions such as getch() or scanf(), and the javascript canvas is as complicated as any GDI library.


But I don't know any language with a graphics library as simple as basic:
SCREEN 13
COLOR RED
DRAW "r5 d5 l5 u5"

Regarding OOP specifically:
It is not a "Holy" concept.
As someone who learnt to program before good C++ compilers were available for home development, you can do a-lot without OOP,
Teaching it as the only way of programming is major mistake universities make today.
It causes programmers to believe that over-designing is a goal in itself.

My Oculus Rift Game: RaiderV

My Android VR games: Time-Rider& Dozer Driver

My browser game: Vitrage - A game of stained glass

My android games : Enemies of the Crown & Killer Bees


[quote name='alvaro' timestamp='1346774276' post='4976454']

Maybe I'm stating the obvious but if I was teaching kids my first priority would be to get them to understand the concept of OOP (mainly inheritance).

That is a terriible terrible idea,
[/quote]

I have to second this.
As a kid I got started with BASIC.
The cool thing about basic is that you don't even need functions.

Your average 12 year old does not understand:
1. If statements
2. Functions
3. Loops
4. Variable Typing
4a. Variable declaration
5. Splitting code into different modules etc...
...

BASIC did not require any of these concepts to generate a cool result.
As a kid, easy success is a great motivator.

Since basic does not really exist anymore (Visual basic is more like C# / Java),
I am thinking one might think of toying around with java-script as a first language.
It does not require any of the above (you can even use undeclared variables in global scope).
It might actually be useful for the kids later.

Little by little you can add the more complicated concepts listed above.

The downside is And there are no easy input functions such as getch() or scanf(), and the javascript canvas is as complicated as any GDI library.


But I don't know any language with a graphics library as simple as basic:
SCREEN 13
COLOR RED
DRAW "r5 d5 l5 u5"

Regarding OOP specifically:
It is not a "Holy" concept.
As someone who learnt to program before good C++ compilers were available for home development, you can do a-lot without OOP,
Teaching it as the only way of programming is major mistake universities make today.
It causes programmers to believe that over-designing is a goal in itself.
[/quote]
A lot of what you just said makes me cringe...though I have already tried to make my point and I will move on.

However...BASIC is not quite dead. Blitz3D uses a bastardized form of BASIC. Unfortunately the license costs $60 and it requires DirectX (version 7 I think). I did not mention it before since the person who was starting the thread does not have the resources (money and decent video cards) to leverage it. I bought a license a few years back and developed a simple game on it. It is great for learning the fundamentals of working in 3d graphics and some people have made some really cool stuff with it. I stopped using it because the code became very difficult to extend and maintain. If you want to try it or any of their other products, see here:

http://www.blitzbasic.com/
Basic is useless, that is bad choice :-(
You could always use FreeBasic, as it has its own gas backend (mingw suite), and gcc backend (gcc)
it's very easy to get started, has all the "BASIC" commands, all the C commands, CRT, and whatever else you may wish for (such as threading)
but, i would not teach my kid basic.. it's too far from the "accepted" standard of C
if i were to start over, i'd choose C in a heartbeat.. or hybrid C/C++

frankly, i would vote for the guy who suggested python / pygame

This topic is closed to new replies.

Advertisement