jgs 564 00000100 Top-Down Stepwise Refinement (step 2) public static String readTextFile (String path) { File file = new File (path); BufferedReader br = new BufferedReader(new FileReader(file)); String str; while ((str = br.readLine()) != null) { text = text + str; } } public static String splitWords (String text) { // code here ... do { int eolAt = text.indexOf("\n"); if (eolAt >= 0) { // code here ... } else { // code here ... } // a lot of code here ! } while (!text.equals("")); } public static void translate (Vector tokens) { // more code ... }
jgs 564 00000100 Assignment 01 § Due Date: Thursday Sept 2, 6:00 PM (AZ time). § Submit Individually (or team of 2). Only 1 student submit BUT be sure both names are included using the JavaDoc @author label § Source Code in Java (SHOULD compile and run) § Show your skills for readability (make your code easy to read) – Clean Code § Use Javadoc (correctly) § If you are not familiar with Java Guidelines, review https://google.github.io/styleguide/javaguide.html § Input is a txt file (path is to be received as parameter to main). § Output is to be printed on screen § Do not make assumptions. If you have a question, Ask
jgs 564 00000100 Decomposing Systems into Modules (1972) On the Criteria To Be Used in Decomposing Systems into Modules April 1972 D.L. Parnas Communications of the ACM Pioneer of software engineering ACM Fellow Developed the concept of information hiding
jgs 564 00000100 • What criteria to use? • Niklaus Wirth. • Information Hiding : A data structure, its internal linking, accessing procedures and modifying procedures are part of a single module • What is a module? • What is the difference of Function vs Module? • What is the difference of Task vs Responsibility?
jgs 564 00000100 Decomposing Systems into Modules (1972) • Modularization Design decisions / independent modules • It improves flexibility and comprehensibility • What criteria to use in dividing the system into modules? Rule A: Information Hiding – data, getters, and setters in one module Rule B: A set of related tasks must live in the same module
jgs 564 00000100 Wirth + Parnas • Niklaus Wirth. • Each major step in the process a module. • Begins with a list of difficult design decisions or design decisions which are likely to change. Each module is then designed to hide such a decision from the others. • In some cases, modules will not correspond to stages in the processing.
jgs 564 00000100 Concepts • Module is a responsibility assignment rather than a subprogram. • Module specification = its inputs, its outputs its interfaces • Small enough and simple enough to be thoroughly understood • Independent development of modules • Comprehensibility: they make easy to understand parts, connections, and the whole.
jgs 564 00000100 Summary § Functions are tasks. § One function perform one task. If needed (size, complexity) split in subtasks § A module encapsulate a responsibility § Responsibility include one or more tasks § A module encapsulate data shared by a group of tasks § How many modules and Which ones? § How many functions and in Which Module?
jgs CSE 564 Software Design Javier Gonzalez-Sanchez, Ph.D. [email protected] Fall 2021 Copyright. These slides can only be used as study material for the class CSE564 at ASU. They cannot be distributed or used for another purpose.