Kurs:Wirtschaftsinformatik WS08 09 PROGRAMMIERUNG/Teil 2

Aus Wikiversity

|

Stop Artikelbearbeitung

X-treme Programming[Bearbeiten]

Write the prep code and describe what the program should do - not how to do it. Then write the test code BEFORE you program the task - the prepared precode will help you. Finally write the JAVA code.

Rules

  • Make small but frequent releases
  • Develop in iteration cycles
  • Don't put anything that's not in the spec
  • Write the test code first
  • No killer schedules, work regular hours
  • Refactor (improve the code) whenever and whereever you notice the opportunity
  • Don't release anything until it passes all the test
  • Set realistic schedules, based around small releases
  • Keep it simple
  • Program in pairs, and more people around so that everybody knows pretty much everything about the code

EXAMPLE: Precode[Bearbeiten]

public static void main (String [] args)

DECLARE an int variable to hold the number of user guesses, named numOfGuesses. set it to 0.
MAKE a new SimpleDotCom instance
COMPUTE a random number between 0 and 4 that will be the starting location cell position
MAKE an int array with 3 ints using the randomly-generated number, that number incremented :by 1, and that number incremented by 2
INVOKE the setLocationCells() method on the SimpleDotCom instance
DECLARE a boolean variable representing the state of the game, named isAlive. SET it to true

WHILE the dot com is still alive (isAlive == true):

GET user input from the command line
// CHECK the user guess
INVOKE the checkYourself() method on the SimpleDotCom instance
INCREMENT numOfGuesses variable
// CHECK for dot com death
IF result is "killl"
SET isAlive to false (which means we won't enter the loop again)
PRINT the number of user guesses
END IF

END WHILE

END METHOD