BlueJ

Aus Stupidedia, der sinnfreien Enzyklopädie!
Wechseln zu: Navigation, Suche

BlueJ (deutsch "BlauJott") ist ein extrem sinnvolles Programm zum Erlernen des objektorientierten Programmierens mit Hilfe der Programmiersprache Java. Das Programm wird sinnvollerweise häufig an deutschen Gymnasien verwendet, um zu vermeiden, einen Informatiklehrer für die Oberstufe ausbilden zu müssen. Der Name "BlueJ" hat seinen Ursprung in der Bezeichnug Bluescreen, einer Fehlermeldung, die bei schweren Systemfehlern vorliegt.

Ein einfache BlueJ Source Code

// This example is from the book _Java in a Nutshell_ by David Flanagan. // Written by David Flanagan. Copyright (c) 1996 O'Reilly & Associates. // You may study, use, modify, and distribute this example for any purpose. // This example is provided WITHOUT WARRANTY either expressed or implied.

import java.awt.*;

public class AllComponents extends Frame {

   MenuBar menubar;                // the menubar
   Menu file, help;                // menu panes
   Button okay, cancel;            // buttons
   List list;                      // A list of choices
   Choice choice;                  // A menu of choices
   CheckboxGroup checkbox_group;   // A group of button choices
   Checkbox[] checkboxes;          // the buttons to choose from
   TextField textfield;            // One line of text input
   TextArea  textarea;             // A text window
   ScrollableScribble scribble;    // An area to draw in.
   FileDialog file_dialog;
   
   Panel panel1, panel2 ;    // Sub-containers for all this stuff.
   Panel buttonpanel; 
   // The layout manager for each of the containers.
   GridBagLayout gridbag = new GridBagLayout();
   
   public AllComponents(String title) {
       super(title);
       
       // Create the menubar.  Tell the frame about it.
       menubar = new MenuBar();
       this.setMenuBar(menubar);
       // Create the file menu.  Add two items to it.  Add to menubar.
       file = new Menu("File");
       file.add(new MenuItem("Open"));
       file.add(new MenuItem("Quit"));
       menubar.add(file);
       // Create Help menu; add an item; add to menubar
       help = new Menu("Help");
       help.add(new MenuItem("About"));
       menubar.add(help);
       // Display the help menu in a special reserved place.
       menubar.setHelpMenu(help);
       
       // Create pushbuttons
       okay = new Button("Okay");
       cancel = new Button("Cancel");
       
       // Create a menu of choices
       choice = new Choice();
       choice.addItem("red");
       choice.addItem("green");
       choice.addItem("blue");
       
       // Create checkboxes, and group them.
       checkbox_group = new CheckboxGroup();
       checkboxes = new Checkbox[3];
       checkboxes[0] = new Checkbox("vanilla", checkbox_group, false);
       checkboxes[1] = new Checkbox("chocolate", checkbox_group, true);
       checkboxes[2] = new Checkbox("strawberry", checkbox_group, false);
       
       // Create a list of choices.
       list = new List(4, true);
       list.addItem("Java"); list.addItem("C"); list.addItem("C++");
       list.addItem("Smalltalk"); list.addItem("Lisp");
       list.addItem("Modula-3"); list.addItem("Forth");
       
       // Create a one-line text field, and multi-line text area.
       textfield = new TextField(15);
       textarea = new TextArea(6, 40);
       textarea.setEditable(false);
       
       // Create a scrolling canvas to scribble in. 
       scribble = new ScrollableScribble();
       
       // Create a file selection dialog box
       file_dialog = new FileDialog(this, "Open File", FileDialog.LOAD);
       
       // Create a Panel to contain all the components along the
       // left hand side of the window.  Use a GridBagLayout for it.
       panel1 = new Panel();
       panel1.setLayout(gridbag);
       
       // Use several versions of the constrain() convenience method
       // to add components to the panel and to specify their 
       // GridBagConstraints values.
       constrain(panel1, new Label("Name:"), 0, 0, 1, 1);
       constrain(panel1, textfield, 0, 1, 1, 1);
       constrain(panel1, new Label("Favorite color:"), 0, 2, 1, 1, 
             10, 0, 0, 0);
       constrain(panel1, choice, 0, 3, 1, 1);
       constrain(panel1, new Label("Favorite flavor:"), 0, 4, 1, 1, 
             10, 0, 0, 0);
       constrain(panel1, checkboxes[0], 0, 5, 1, 1);
       constrain(panel1, checkboxes[1], 0, 6, 1, 1);
       constrain(panel1, checkboxes[2], 0, 7, 1, 1);
       constrain(panel1, new Label("Favorite languages:"), 0, 8, 1, 1,
             10, 0, 0, 0);
       constrain(panel1, list, 0, 9, 1, 3, GridBagConstraints.VERTICAL,
             GridBagConstraints.NORTHWEST, 0.0, 1.0, 0, 0, 0, 0);
       
       // Create a panel for the items along the right side.
       // Use a GridBagLayout, and arrange items with constrain(), as above.
       panel2 = new Panel();
       panel2.setLayout(gridbag);
       
       constrain(panel2, new Label("Messages"), 0, 0, 1, 1);
       constrain(panel2, textarea, 0, 1, 1, 3, GridBagConstraints.HORIZONTAL,
             GridBagConstraints.NORTH, 1.0, 0.0, 0, 0, 0, 0);
       constrain(panel2, new Label("Diagram"), 0, 4, 1, 1, 10, 0, 0, 0);
       constrain(panel2, scribble, 0, 5, 1, 5, GridBagConstraints.BOTH,
             GridBagConstraints.CENTER, 1.0, 1.0, 0, 0, 0, 0);
       
       // Do the same for the buttons along the bottom.
       buttonpanel = new Panel();
       buttonpanel.setLayout(gridbag);
       constrain(buttonpanel, okay, 0, 0, 1, 1, GridBagConstraints.NONE,
             GridBagConstraints.CENTER, 0.3, 0.0, 0, 0, 0, 0);
       constrain(buttonpanel, cancel, 1, 0, 1, 1, GridBagConstraints.NONE,
             GridBagConstraints.CENTER, 0.3, 0.0, 0, 0, 0, 0);
       
       // Finally, use a GridBagLayout to arrange the panels themselves
       this.setLayout(gridbag);
       // And add the panels to the toplevel window
       constrain(this, panel1, 0, 0, 1, 1, GridBagConstraints.VERTICAL, 
             GridBagConstraints.NORTHWEST, 0.0, 1.0, 10, 10, 5, 5);
       constrain(this, panel2, 1, 0, 1, 1, GridBagConstraints.BOTH,
             GridBagConstraints.CENTER, 1.0, 1.0, 10, 10, 5, 10);
       constrain(this, buttonpanel, 0, 1, 2, 1, GridBagConstraints.HORIZONTAL,
             GridBagConstraints.CENTER, 1.0, 0.0, 5, 0, 0, 0);
   }
   
   public void constrain(Container container, Component component, 
                 int grid_x, int grid_y, int grid_width, int grid_height,
                 int fill, int anchor, double weight_x, double weight_y,
                 int top, int left, int bottom, int right)
   {
       GridBagConstraints c = new GridBagConstraints();
       c.gridx = grid_x; c.gridy = grid_y;
       c.gridwidth = grid_width; c.gridheight = grid_height;
       c.fill = fill; c.anchor = anchor;
       c.weightx = weight_x; c.weighty = weight_y;
       if (top+bottom+left+right > 0)
           c.insets = new Insets(top, left, bottom, right);
       
       ((GridBagLayout)container.getLayout()).setConstraints(component, c);
       container.add(component);
   }
   
   public void constrain(Container container, Component component, 
                 int grid_x, int grid_y, int grid_width, int grid_height) {
       constrain(container, component, grid_x, grid_y, 
             grid_width, grid_height, GridBagConstraints.NONE, 
             GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 0, 0, 0);
   }
   
   public void constrain(Container container, Component component, 
                 int grid_x, int grid_y, int grid_width, int grid_height,
                 int top, int left, int bottom, int right) {
       constrain(container, component, grid_x, grid_y, 
             grid_width, grid_height, GridBagConstraints.NONE, 
             GridBagConstraints.NORTHWEST, 
             0.0, 0.0, top, left, bottom, right);
   }
   
   public static void main(String[] args) {
       Frame f = new AllComponents("AWT Demo");
       // We should call f.pack() here.  But its buggy.
       f.resize(450, 475);
       f.show();
   }

}

Mit diese Code erreicht man diese Ausgabe: "Socketfehler 10061, Fehler 0x800ccc0e-??FU*k_U_MOTHER-1/19/2010 Time: 10:14:53 Event Id: 608 Policy Id: 2071-Critical Type: Chassis Component: Server 2 User Name: System_Affected Memory Bank: DIMM_C1. " Diese Fehlermeldung versteht aber jedermann, also diese Fehler ist leicht zu vermeiden.

Sinn des Programms

Sinn von BlueJ ist es, dass Schüler eine Datei mit dem Namen BlueJ.BAT in den Klassenordner stellen, die dann, von Mitschülern oder Lehrern geöffnet, Befehle wie shutdown /l /c /y /t:60 "PROBLEM_EXISTS_BETWEEN_KEYBOARD_AND_CHAIR", net send * Schwerer Ausnahmefehler FF00:647F auf 0x027AE0CFF. Das Programm musste beendet werden, %0|%0 und/oder sonstige sinnvolle DOS-Befehle ausführt und mit Windoof-Abstürzen für Unterhaltung in der langweiligen Informatikstunde sorgt.

Lernhilfen

Um den Schülern den Einstieg in die OOP so schwierig wie möglich zu gestalten, wurden einige hilfarme Features eingebaut.

Debugger

Ein funktionierender Debugger (deutsch "Hundehaufenbeseitigungsbagger") wurde bewusst weggelassen, um dem Lehrer die Möglichkeit zu geben, seine eigene Inkompetenz mit der Unfähigkeit BlueJ's zu begründen. Entgegen der allgemeinen Meinung ist dieses Nicht-Funktionieren gewollt und lässt sich nicht auf die fehlende Qualifikation der Entwickler zurückführen.

Installation/Programmstart

Die Installation wurde so gestaltet, dass der Schüler schon hierbei enorme Kenntnisse über Computertechnik erlangt. Um das Programm und seinen PC auf die Installation vorzubereiten, muss der Schüler z.B. neue Hardwaretreiber (z.B. für den Bildschirm) programmieren. Ist das Programm ersteinmal installiert, geht alles fast schon wie von selbst. Es muss nur noch schnell der Prozessor übertaktet werden (hohe Ressourcenanforderungen (siehe Debugger)), eine neue Partition auf der Festplatte erstellt werden - und schon kann es losgehen mit tiefer gehenden Aufgaben wie das Programmieren eines Kaugummiautomatens.

Darstellung der Klassen in UML

Damit sich die Opfer BlueJ's langsamer in die objektorientierte Programmierung (OOP) einarbeiten und den Lehrer somit nicht in seinem beschränkten Wissen übertreffen, wurde eine extrem ununverwirrende graphische Darstellung der einzelnen Klassen eingebaut. Dieses Feature glänzt durch wunderschöne bunte Farben und Pfeile, deren Bedeutung vernachlässigbar ist. Möchte der Proband nun ein Programm (z.B. Autowaschanlage) ausführen, bzw. kompilieren, muss er nur noch ein neues Objekt erzeugen und schon kann es losgehen - mit z.B. "den Computer einen Apfel essen lassen".

Exeptiongenerator

Da Java über eine große Vielfalt an s.g. Exceptions (werden ausgegeben, wenn ein Fehler in der Programmstruktur vorliegt) verfügt, ist es schwierig, alle kennen zu lernen. Die Entwickler von BlueJ haben dagegen ein Mittel entwickelt, den sog. Exceptiongenerator. Diese Funktion gibt bei jedem zweiten Ausführen eine zufallsgenerierte Exception aus und zeigt so den Benutzern die Bandbreite an Fehlermeldungen auf (von Nullpointer (es gibt eigentlich keine Pointer) bis BlueJFail (wird immer dann ausgegeben wenn wirklich ein Fehler vorliegt)).

Siehe auch

if (codingLanguageList.Contains(this.title)) {

wikiPage[] articleList = { A, Assembler, BASIC, Brainfuck, C, C++, C-Sharp, COBOL, D, Delphi, Eick#, Eiffel, Gehirnassembler, Haskell, HTML, Java, JavaScript, Logo, NXC, Pascal, Perl, PHP, Python, Robot Karol, SQL, Tcl, UML, Visual Basic, ZLORFIK };

} else if(article.Exists()) {

wikiPage[] articleList = { Programmer-Lang, Was deine Programmiersprache über dich verrät, Rekursive Programmierung};

} else {

EditTemplateCodingLanguage();

}


Linktipps: Faditiva und 3DPresso