Monday, April 27, 2009

java, I just love it!

what should I named this post hah? it can be named with many titles, but... hmmmm.. senornya I buntu dah, otak tepu kot pasal for the past 3 weeks I have been messing myself up with java... ya java bukan banjar bukan boyan...

why java? why it was named 'java'? nnti2lah kau ada masa ake ceta, sekarang ni pasal tengah serabut aku nak post
satu benda quite interesting, kasi relax sikit itu kapla. writing ni panjang, tapi aku ambek sekerat ja.

========================
Stimulants Anonymous
Welcome to the Java programmers' roasteria. A wide variety of stimulating beverages are consumed among the whirring virtual machines.
gnat polishes Tom's apples.
You say, "been done."
jkcohen has arrived.
kristen has arrived.
kate has arrived.
j.j says, "kate! i saved a seat for you by me!"
kate plunks herself, her computer, zad, and a pile of books down next to j.j
jkcohen waves and takes a seat.
You say, "ahem."
jsam sits next to jkc and passes notes.
Tom clears his throat vigorously.
You say, "welcome to Programming 101 by Way of Java. Thanks for coming."
Tom scritches his name on the blackboard, not too excruciatingly.
You say, "we're going to begin with a few ground rules for the class."
You say, "if you are an experienced programmer, you're welcome to remain,"
You say, "but please do not hurriedly answer every question with a smug flourish."
You say, "if you do, Boris the Bailiff will light you up like a christmas tree with his phaser cannon."
You say, "it is devoutly hoped that you have the Java development kit by now, and have hopefully recompiled or at least run one or two of the demo applets that come with it."
You say, "however, we won't be doing much compiling *in* the class. I made that requirement to make sure you can all apply what you learn here."
You say, "this is an introductory programming class. If I seem pedantic, please accept my apologies, but I intend to make this approachable for everyone."
You say, "if you don't understand, and I've come to the end of a sentence,"
You say, "please, please, please interrupt with a question."
You say, "programming is the art of recipe writing."
You say, "yes, programs are often very specific and detailed recipes, but it's not really an analogy; it's more of a synonym."
You say, "there's a lot of talk about object oriented programming, and people tend to be nervous about 'grasping' the 'OO (object oriented) paradigm'."
You say, "actually, most people already interact with the world in terms of objects."
You say, "it's not news to point out that your desk might have a notepad, a coffee mug, another coffee mug, another coffee mug, and a coffee stain on it."
You say, "but there's something odd about that sentence:"
You say, "anyone care to point out an easier way of phrasing it?"
jkcohen says, "Three coffee mugs and a coffee stain?"
You say, "yes."
jkcohen says, "Plus a notebook."
You say, "heh. Yes. Accuracy tends to be important in programming."
You say, "okay. Now, the idea of 'objects' doesn't really cause most people grief..."
You say, "but the idea of 'classes', as used in programming, does tend to frighten people off at first."
You say, "fortunately classes aren't that complicated, they just aren't explained well most of the time."
You say, "when jon summarized my sentence, he made the observation that all coffee mugs have a set of common characteristics which we are all familiar with."
You say, "in everyday conversation, we would say the three objects are the same 'kind' of object."
You say, "in java programming, we refer to them as being of the same 'class.'"
You say, "programmers seek to identify the objects that play a role in a task,"
You say, "and then describe the characteristics and behavior of these objects in a lot of boring detail."
You say, "computers like boring details, but people hate them."
You say, "so programmers realized they could describe the *shared* characteristics and behavior of the objects, and called this information a 'class' of objects."
You say, "a class might have only one object in it, ever, or it might have millions."
You say, "now, I want you all to take a look at the desktop on your computer screen."
You say, "each of your applications has a position on the desktop, a size on the desktop, and so on."
You say, "within each of your applications there are many smaller components, such as scrollbars, text windows, pushbuttons and so forth..."
You say, "each of these small components also has a position, a size, and the knowledge of what larger component it is a part of."
You say, "programmers could describe the behavior of each of these components in agonizing detail, but they wouldn't want to. It would be redundant, and they would make a lot of mistakes."
You say, "worse, if the programmers decided they wanted to change how these general things worked, they would have to change it for each individual component."
You say, "instead, there is a 'class', called 'window', to which all of these components belong..."
You say, "and information that any window will contain, such as size and position and the identity of the parent window, is described by this class."
You say, "the window class also contains instructions -- recipes -- to carry out things that people often want to do to a window."
You say, "which means that a window can be asked to resize itself, or to hide itself, and so on."
You say, "by writing down the correct recipe to do these things in the 'window' class, we are able to avoid reinventing the wheel."
You say, "also, we can change the recipe in one place if we change our minds."
You say, "now, take a look at the menus that appear in the program you're using."
You say, "each of these menus is certainly a window."
You say, "so the programmer could say, 'this is a window, and it also has a label, and another window that pops up when you click on it, and that window has a list of choices on it,' and so on. If there was only one menu, that would seem reasonable."
You say, "of course, there are many menus in many applications, and they all have very similar behavior, and programmers hate to waste time."
You say, "if two or more things have similar behavior, programmers will usually create a 'class' to describe what they have in common."
You say, "a menu, then, is an instance (one of) the class 'menu'."
You say, "but it is also obviously a 'window.' There is a special relationship between these two classes..."
You say, "a 'menu' is 'just like a window,' but it also has a list of items to display on it, a label, and so on..."
You say, "programmers refer to 'menu' as a 'subclass' of 'window.'"
You say, "this is similar to a recipe that starts out with 'prepare the frosting,' knowing that you already have a recipe for that."
You say, "this might seem a bit tricky, but we do this every day. For instance, we know that all collies are dogs. We also know that all dogs are not collies. A collie is a specific variety of dog, just as a menu is a specific variety of window."
Tom takes a deep breath.
You say, "any questions so far?"
kate zzz
j.j shakes her head, "with you so far."
You say, "hee."
j.j nudges kate.
kate says, "sorry. no."
jsam says, "tom, it's a quibble but could you say why 'a menu is obviously a window' to you?"
You say, "sam: well, a button might have been a better example. Menus are actually a bit complex in that there's a window with the label on it, a window with the actual list of choices on it, etc."
gnat says, "so a window is practically any 'thing' that appears on the screen?"
gnat says, "because all the things have a place, contents, a thing they're part of, etc?"
You say, "gnat: if it has a size, a location, and a parent window (which might be 'none'), then a window might be a reasonable way to describe it."
gnat says, "woohoo, I'm on the same page as Tom."
gnat turns his book rightside up.
j.j says, "well, duh."
You say, "gnat: if you find that most of the 'recipe' for windows is not useful for what you're doing, then you might decide to 'subclass' something else (or nothing at all) as your starting point."
j.j duhs that gnat is on the same page as tom. "class showoff."
Tom takes a drink of water. All this talking, you see.
You say, "now, I'm going to move on to some actual Java stuff. Sorry for the necessary pedantry."
jsam nods. "the mac world doesn't use 'window' to describe as many things as the other windowing systems do; this is a terminology question.'
Tom nods to sam.
You say, "okay. Now, in Java, the programming language itself takes advantage of ideas like classes, subclasses and objects by name. You can apply these ideas in any language, even COBOL, but Java makes it easier."
You say, "to describe the relationship between dogs and collies in Java, we might write the following."
You say, "if you don't follow everything in detail at this step, don't worry too much. I have to throw some things around without proper explanation to work with interesting examples."


------------

1 comment:

izawani/JEEN said...

JSP ? Hehehe... kami dot net... hehehehe...