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 ... }
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
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
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?
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
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.
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.
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?