Relocatable hierarchical software design
Wednesday, November 2, 2016
Upload XML data to MySQL or NoSQL
Labels:
multi-platform design,
NoSQL,
SQL,
upload XML data
Friday, April 11, 2014
Thursday, December 5, 2013
Hierarchical software design example
public class CustomersTask { private CustomersTaskContext customersTaskContext; private PrintCustomersContext printCustomersContext; private ReadCustomers readCustomers; private PrintCustomers printCustomers; public CustomersTask(CustomersTaskContext customersTaskContext) { this.customersTaskContext = customersTaskContext; customersTaskInit(); } public final void customersTaskInit() { printCustomersContext = new PrintCustomersContext(getCustomersTaskContext()); readCustomers = new ReadCustomers(getCustomersTaskContext()); printCustomers = new PrintCustomers(getPrintCustomersContext()); } public final void printCustomersTask() throws IOException { readCustomers(); printCustomers(); } public static void main(String args[]) { try { String filename = args[0]; CustomersTaskContext ctc = new CustomersTaskContext(); ctc.init(filename); CustomersTask ct = new CustomersTask(ctc); ct.printCustomersTask(); } catch (Exception e) { e.printStackTrace(); } } private CustomersTaskContext getCustomersTaskContext() { return customersTaskContext; } private PrintCustomersContext getPrintCustomersContext() { return printCustomersContext; } private PrintCustomers getPrintCustomers() { return printCustomers; } private void printCustomers() { getPrintCustomers().printCustomers(); } private ReadCustomers getReadCustomers() { return readCustomers; } private void readCustomers() throws IOException { getReadCustomers().readCustomers(); } }
public class PrintCustomers { private PrintCustomersContext printCustomersContext; private PrintCustomer printCustomer; public PrintCustomers(PrintCustomersContext printCustomersContext) { this.printCustomersContext = printCustomersContext; printCustomersInit(); } public final void printCustomersInit() { printCustomer = new PrintCustomer(getPrintCustomersContext()); } public final void printCustomers() { for (Customer customer : getCustomerList()) { printCustomer(customer); } } private PrintCustomersContext getPrintCustomersContext() { return printCustomersContext; } private PrintCustomer getPrintCustomer() { return printCustomer; } private CustomersTaskContext getCustomersTaskContext() { return getPrintCustomersContext().getCustomersTaskContext(); } private void printCustomer(Customer customer) { getPrintCustomer().printCustomer(customer); } private CustomerData getCustomerData() { return getCustomersTaskContext().getCustomerData(); } private LinkedListgetCustomerList() { return getCustomerData().getCustomerList(); } }
© Ravindra Mahajan
public class CustomersTaskContext { private String filename; private CustomerData customerData; public CustomersTaskContext() { } public void init(String filename) { this.filename = filename; this.customerData = new CustomerData(); } public final String getFilename() { return filename; } public final CustomerData getCustomerData() { return customerData; } }
public class ReadCustomers { private CustomersTaskContext customersTaskContext; public ReadCustomers(CustomersTaskContext customersTaskContext) { this.customersTaskContext = customersTaskContext; } public final void readCustomers() throws IOException { FileReader fr = new FileReader(getFilename()); BufferedReader br = new BufferedReader(fr); String name = br.readLine(); while (name != null) { Customer customer = new Customer(name); addCustomer(customer); name = br.readLine(); } br.close(); } private CustomersTaskContext getCustomersTaskContext() { return customersTaskContext; } private String getFilename() { return getCustomersTaskContext().getFilename(); } private CustomerData getCustomerData() { return getCustomersTaskContext().getCustomerData(); } private boolean addCustomer(Customer customer) { return getCustomerData().addCustomer(customer); } }
public class PrintCustomersContext { private CustomersTaskContext customersTaskContext; public PrintCustomersContext(CustomersTaskContext ctc) { this.customersTaskContext = ctc; } public final CustomersTaskContext getCustomersTaskContext() { return customersTaskContext; } }
public class PrintCustomer { private PrintCustomersContext printCustomersContext; public PrintCustomer(PrintCustomersContext pcc) { this.printCustomersContext = pcc; } public final void printCustomer(Customer customer) { System.out.println(customer.getName()); } }
public class CustomerData { private LinkedListcustomerList; public CustomerData() { customerList = new LinkedList (); } public boolean addCustomer(Customer c) { return getCustomerList().add(c); } public LinkedList getCustomerList() { return customerList; } }
public class Customer { private String name; public Customer(String name) { this.name = name; } public String getName() { return name; } }
Labels:
agile software design,
hierarchical software,
object oriented design,
relocatable hierarchical software design
Subscribe to:
Posts (Atom)