1 / 7

Design to Programming

Design to Programming. The translation from design to program must be more or less a mechanical process except for implementer ’ s decisions This will ensure consistency between design and program

roger
Télécharger la présentation

Design to Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Design to Programming • The translation from design to program must be more or less a mechanical process except for implementer’s decisions • This will ensure consistency between design and program • A program must include every information from its design and can add more, but nothing must be left out • Programming language-specific information can be included but must be properly documented • E.g.,use of built-in data types or classes Lecture 8

  2. Choices to the implementer • Choose an effective algorithm, if not already requested by the designer • Keep sequence of elements sorted all the time, if not already requested by the designer • Grouping or packaging of classes for programming convenience • Change of data types from design to implementation for efficiency or compatibility purposes • Must be documented properly so that maintenance would be easier • Use of appropriate system calls Lecture 8

  3. What is considered to be good program? • Adequate documentation • Include documentation for every class in its header, explaining class in its entirety • Must include author(s), date created, date modified, etc. • Include documentation for every method in its header, explaining the purpose of the method • Include documentation for every critical section of code (loops, if or case structure etc.) indicating the important decisions or branches Lecture 8

  4. What is considered to be a good program? • Use of meaningful names for classes, methods, variables etc. • E.g. in an ATM system • ‘ATM’,’Account’,’Customer’,… are meaningful class names as opposed to ‘Acct’,’Cust’,’ATMach’ • ‘Deposit’,’Withdraw’,… are meaningful method names as opposed to ‘depo’, ‘with’,… • Organizational policy may influence the naming convention in a program, but still the programmer has more freedom • E.g., ‘_Mdeposit’ for deposit Lecture 8

  5. What is considered to be a good program? • Well-structured program that is readable and understandable • Indentation makes a big difference in readability and understandability • Size of a method, number of parameters also plays a crucial role in this context • Strictly follow the programming language principles • Using a “break” statement inside a “for” loop? Lecture 8

  6. Identify what the following code does public static void something(int[] array) { int i,j=array.length-1; int tmp, max = array.length/2; for(i=0;i<j;i++,j--) { if(array[max] <array[i]){ tmp =array[max]; array[max]=array[i]; array[i]=tmp; } if(array[max] <array[j]){ tmp = array[max]; array[max] = array[j]; array[j] = tmp; } } } Lecture 8

  7. Identify what this code does public static iDontKnow(int[] array) { int i, j, tmp; for(i=1;i<array.length;i++) if(array[i]<array[i-1]) { tmp =array[i]; for(j=i-1;j>=0;j--){ array[j+1] = array[j]; if(j==0 || array[j-1]<tmp) break; } array[j]=tmp; } } Lecture 8

More Related