JAVA kicking and screaming - Page 2


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21

Thread: JAVA kicking and screaming

  1. #16
    Join Date
    Nov 2002
    Posts
    138

    Smile

    it is OOPL! not a pure OOPL though, but still... uh, heck, whatever...!!! ya, it's hard to believe some things he said. but let's give this guy the benefit of the doubt. who knows....???

  2. #17
    Join Date
    Jun 2003
    Posts
    3
    So sorry to disappoint a few but I did teach middle school kids the very basic concepts of procedural programming, which was about all I really knew! We managed to handle the primative data types, learned about loops and conditional statements.. mostly just staying safely inside the main function. Then we "branched" out to use functions - with formal and actual parameters. But still no OOP stuff. At least we had a language that allowed structure and had an input statement!
    So, I did teach them andthey did well but now I want to move to Java and I have no frame of reference for classes and objects. Guess I was just barely scratching the surface of programming but I never got far enough to make classes in C++ , heck we didn't even get to multi-dimensiion arrays.
    I picked up several Java books and they almost all are written by professional programmers who have never taught someone lower the advanced college students.
    If someone received only a C in a science course, would you never offer them other science courses? How about the C student in Math, or English? So why does it seem that Computer Programming is geared only for the engineering types. Couldn't - shouldn't - everyone benefit from learning some programming concepts? Then way not make programming something more attainable for the masses but making it easier to learn? Trouble is - we all don't have the same background. I came from the Social Studies field and tried my hand at programming computers. Sure I didn't get far but I'm still trying.
    " The object is the fundamental entity in a Java program. The object is define by a class, which can be thought of as the data type of the object. Classes can be created from other classes using inheritance. " -- and this is just stuff from chapter 2 !
    Trying teaching these concepts to Middle School kids with no programming and little math background and see how far you get before you are deep into creating other examples to get the idea across. What is your pay depended upon getting these concepts across? Would you still give those definitions and assume that they were self-evident?
    I'm still struggling and still looking at books and on-site tutorials- awaiting that ahh haa moment.
    Maybe my C++ procedural background has ruined me for OOP. But I'll keep looking ! Thanks anyways
    Try to avoid becoming roadkill on the information superhighway!

  3. #18
    Join Date
    Feb 2004
    Posts
    541
    I don't see why it would have ruined it. When I started learning programming in java classes weren't even mentioned specifically until half way through the course. I'd been making classes without even realising it, but they weren't used to their full potential until object oriented concepts were brought into the equation half way through the term.

    Basically (as has been mentioned, and I think you're beginning to understand), a class describes an abstract structure. I'll try and give a few examples using real world concepts.

    THink of an abstract concept like vehicle. This is abstract because it doesn't fully describe something that is real. If I say vehicle you can't visualise one object that you can be sure i'm talking about. You can however think of some things you know a vehicle will have. A vehicle will be able to move, it will be able to stop and it will be able to carry passengers.

    Now let's try and make the concept less abstract. Imagine a car. This is still abstract because there are many different types of car, but it isn't quite as abstract as simply saying vehicle. Since it is a vehicle you know it can do all the same things a vehicle can, ie move, stop and carry passengers. You also know that a car has doors, a chasis, an engine, a boot (trunk if you're american), wheels etc...

    Now make it totally concrete. Think of a specific car *insert make of car here here*. This specific car is totally concrete, and has a very specific definition that makes it different to all other cars. Somewhere the manufacturer of this car will have a blueprint that fully defines the car, and this will be used to make many copies of the car in the factory.

    The above example is a great analogy to classes in OOP. The class contains definitions that all objects of the class have to adhere to. If the class is abstract it can't have any objects made from it (just like you can't make a "vehicle" object from my example above because it is too vague). But the abstract class can be used to set down some general guidelines.

    You can then extend this general class and make it more concrete and specific. The extended class will inherit all the information that the abstract class had, and it will define some knew information of its own. Eventually a class will be defined which is concrete enough to make an object from (just like the specific make of car was concrete enough to go out and buy from my example above). This class will have all the information necessary to make a specific object.

    Just like each car the manufacturer makes is unique even though it is the same make, so are the objects you make from a class unique. The cars will be different colours, have different number of miles on the clock, be owned by different people etc. This is the same with objects in java. The variables they hold will have different values, they will all be doing seperate things etc.

    Obviously i've run over a lot of concepts there rather quickly, but hopefully I made it easy enough to understand. I didn't mention any syntax specific things either, which is another thing that needs to be learned. OOP isn't actually all that complicated because it aims to represent real world things as much as possible.

  4. #19
    Join Date
    Feb 2004
    Posts
    808
    erm.. mike.. I know he'll appreciate the post, etc, and to ArchAngel too, but this is america, and not sure what age range a mid-school student is, i took a quick look.
    http://www.scholastic.com/schoolage/middleschool/ gave me a pretty bit hint:

    17 Ways to Keep Your Middle-Schooler Turning the Pages
    Try these tips for keeping your preteen's interest and skills on track.

    pre-teen? you want to discuss concepts like abstraction, concretion and OO programming with a 12 year old? *%&@ that! these kids barely have enough algebra to figure out x+y where x=5 and y=10

    fastfinger: sack off the merest idea of teaching them OO.. their logic just isnt advanced enough; it's barely graspable by the average university student

    just give them this:
    Code:
    public class MyProgram{
      public static void print(String s){
        System.out.println(s);
      }
      public static String read(){
        try{
          return new java.io.BufferedReader(System.in).readLine();
        }catch(Exception e){
          return "<<Problem reading from keyboard>>";
        }
      }
      public static String ask(String s){
        System.out.print(s);
        return read();
      }
    
      public static void main(String[] argv){
      
        //WRITE YOUR CODE HERE
      }
    }
    and remember, that when comparing strings, use:

    string1.equals(string2)

    not string1 == string2


    -

    now is not the time to be teaching OO to kids.. ask them (the kids) how many would be comfortable to write a recipe for something their mother cooks.. if they can do that, they can write a program.. at 12, most kids want to do this (BASIC) :

    10 print "simon is a nerd"
    20 goto 10
    run
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

  5. #20
    Join Date
    Feb 2004
    Posts
    541
    well I wasn't answering the question so that he could repeat what I said to the kids (i didn't notice that he was teaching kids so young by the way). I was answering it so that he personally could understand the concepts. Most people who teach kids (even pre teen kids) need to learn way more than they're teaching the kids. I was just giving a very brief introduction to the concepts leaving out any syntax issues. Sorry if it was beyond what you need.

  6. #21
    Join Date
    Jul 2004
    Posts
    40
    Hi fastfinger, sounds like you have quite a bit on your shoulders. I just thought I would maybe put in my ideas.
    Firstly I also started with C and then C++ and then moved onto Java and the procedural C programming was a good introduction and the C++ was a slight step towards OOP. I think C and C++ are quite important to bring across the simple things like if-clauses, while-loops etc. If you have programmed in C++ then you may have used STRUCTS, these are basically the equivalent to classes in Java.
    Many question to classes can be explained by the "is a" and "has a" relationship.
    You may have a class Car which describes all the characteristics an automabile has. Now this Car Object "is a" Vehicle and "has a" model number, color etc.
    A vehicle could be a boat or something so a Car must differ from the class Vehicle but has all the characteristics of a vehicle.
    Code:
    public class Vehicle
    {
       String color;
       String modelNum;
    
      public Vehicle (String inColor, String inModel)
      {
          color = inColor;
          modelNum = inModel;
      }
    }
    
    public class Car extends Vehicle
    {
      int noWheels;
    
      public Car (String inColor, String inModel, int inWheels)
      {
          // call Constructor from superclass (here Vehicle)
          super (inColor, inModel);
          noWheels = inWheels
      }
    }
    The class Car will now inherit all the properties and methods from Vehicle and add on more.
    Now you have a class which will represent an Object when it is instantiated for example in your main method:
    Code:
    Car myCar = new Car ("red", "325i", 4);
    // this Object can now be accessed using myCar. like:
    System.out.println("The color of my car is:"+myCar.color);
    // or reset the values like:
    myCar.color = "yellow";
    System.out.println("The color of my car is:"+myCar.color);
    // Now it will print that your car is yellow.
    Java is similar to C++ in the fact that one needs to make Constructors for a class, just like a STRUCT in C++ but never destructors as Java handels memory-allocation. As far as I can remember, C++ also has access modifiers like: private, protected etc. for more on that look here: http://java.sun.com/docs/books/tutor...sscontrol.html
    Hope this helps you a little.
    I think, therefore I am....... I think.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center