Appendix H Procedural Code in Java Appendix D is primarily concerned with the mappings from the elements of a class diagram to Java classes. They were simply concerned with the major constructs including interfaces, classes, relations, class attributes and methods. In this appendix we examine the procedural code of class methods. In addition, we outline the pseudo-code that we use to describe program logic. H.1 Procedural code Java s procedural code is used to implement a method body. This code can also appear in initialization blocks as described in chapter 7. Procedural code is assembled from the three control structures of sequence, selection and iteration (repetition). These three control structures are prepared in any combination to describe the logic required. In Java the if and switch statements represent the language s two selection statements. The while, do and for are the repetition statements. Combining these structures in any manner means that an if statement can be nested within another if statement, or a while statement can be used in an if statement, and so on. As we form complex control logic then it too will benefit from the application of some design. This we achieve by developing pseudo-code to describe the intended logic before converting it into actual Java statements. Pseudo-code, as its name suggests, is not Java code but bears some passing resemblance to it. Pseudo-code aims to describe the intention of some logic by using code-like constructs. Pseudo-code is sometimes also known as a Program Design Language (PDL) or by the term Structured English, in which some restricted form of natural language is used to describe our intent. The language used with pseudo-code is a mix of fixed constructs and paraphrased statements. The idea of fixed constructions is evident from the name Structured English. Some parts of the language used are constrained to some fixed structures. The remainder of the pseudo-code is composed of short phrases that describe the intent. We distinguish the latter by using italic font. The fixed structures are presented as emboldened text. A simple illustration of pseudo-code with no structured elements is given below. It simply identifies that we need to obtain a date from the user and that we prompt the user when it is required. It represents an example of sequential code. prompt the user for a date read the date from the user 393
If you looking for unlimited one inclusive web hosting plan please check cheap web hosting website.
This entry was posted
on Tuesday, January 6th, 2009 at 9:17 am and is filed under java jsp tomcat.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.