Results 1 to 1 of 1

Thread: Builder pattern

  1. #1
    31vl is offline Member
    Join Date
    Jan 2010
    Rep Power

    Default Builder pattern


    I am new to design patterns, but willing to learn. So I came here for an advice, as this would be my first attempt in implementing the builder pattern.
    The project: Create a java application that will generate and send via email 6 exports (Excel files) of different types, having their data filled from a database. The names of the exports, as well as other filters, will be read from an XML file passed as an argument in the command line.
    My solution was to use the builder pattern, as it follows:


    Java Code:
    public abstract class BuilderExport {
    	protected Expor export;
    	public Export getExport(){
    		return export;
    	public void createExport(){
    		export = new Export();
    	public abstract void createAntet();
    	public abstract void createTableHead();
    	public abstract void createTable();
    	public abstract void setPath();

    Java Code:
    public class BuilderExportImplementationA extends BuilderExport {
           private ExportFilters filters;
           public BuilderExportImplementationA(ExportFilters ef){
                    this.filters = ef;
           //..overrided methods
    Java Code:
    public class DirectorExport {
    	private BuilderExport builder;
    	public DirectorExport (BuilderExport b){
    		this.builder= b;
    	public Export getExport(){
    		return builder.getExport();
    	public void createExport(){

    Java Code:
    public class Export {
    	private Workbook workbook;
    	private Sheet sheet;
            private String path;
            public Export(){
        	        workbook = new HSSFWorkbook();
    	//...getters and setters


    Java Code:
            public static void main(String[] args) {
    		BuilderExport builder = null;
    		List<ExportFilters> listFilters;
    		DirectorExport director;
    		for (ExportFilters fe : listFilters) {
    			if (fe.getType().equals("A")) {
    				builder = new BuilderExportImplementationA (fe);
    			} else if (fe.getType().equals("B")) {
    			director= new DirectorExport (builder );

    Can someone please tell me if this design is well thought? Is there another design pattern better suited for this problem ?

    Another question: the methods saveExport(String path) and sendExport(..) to which object will they belong?

    I would appreciate any help you can give me.

    ps: Please excuse my grammar, as english is not my native language.
    Last edited by 31vl; 01-21-2011 at 11:19 AM.

Similar Threads

  1. strategy pattern and bridge pattern
    By jomypgeorge in forum New To Java
    Replies: 2
    Last Post: 12-13-2010, 06:13 AM
  2. Best GUI Builder
    By ergon78 in forum SWT / JFace
    Replies: 1
    Last Post: 09-14-2010, 02:02 PM
  3. Class pattern to generate following pattern:-
    By vxs in forum New To Java
    Replies: 5
    Last Post: 07-15-2010, 12:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts