Back to list
Views:   7.5K
Replies:  1

Optimal Design Pattern to generate a file

The process to generate a file is : 1. get header 2. get content 4. generate file 6. download file
for exmple, there are two types: 1. txt file 2. xml file
the get header function is same. txt file and xml file use same function.
the get content function is different, different type file has different content. so I must use a interface and txt file and xml file to implete the interface.
the generate file function is same. use the header and the content to build a file.
the download file function is different, because system must give different file name base on type.
Does anyone have some examples,
Oo Hml, Oct 18, 2012
Reply 1
I suggest using Builder pattern to build different parts of the file. Depending on the different types, use Strategy pattern inside for each of them.
Vivekananda P, Nov 07, 2012
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.