Results 1 to 2 of 2
Thread: program structure
- 12-30-2009, 02:17 AM #1
program structure
Good evening everyone,
Please review logic below and state, how, in your opinion, it can be further improved to ALLOW FOR FUTURE GROWTH
I am facing a rapid increase of use of my program (cool!) and am receiving many requests for new features (still very cool). It is mainly because of this, i had to revisit the original structure and to my horror recornize (oh noes!) that it is not as clear as i hoped it would be.
What you see below is an approach i hope will not only structure existing code, but also will allow for further plug and play improvements.
PS: On a completely separate thought, i think i wil start my next application with tis exact excersize. If i had thought of a simple 30 lines like this, prior to diving into actual code, end product would have been clearer at least.
Thank you everyone!
1500+ lines of code summarized in 30 below:
Java Code:public static void main(String[] args) { validateAndProcessParameters (args) if (whatAreWeDoing = files): processFiles(files) writeResults createHTML(ok status) if (whatAreWeDoing = database): validate user input connect to database write Results createHTML (Ok status) Submit a statistical entry to db showing what we just did Send an email to user with quick update } validateAndProcessParameters (args) { checkIfFilesExists(files) checkForDuplicates(some specific args) return whatAreWeDoing } checkIfFilesExists(files) { if all is ok, return ok else createHTML(error status) and exit } createHTML (status) { if status is Ok, create valid HTML, else create "fail" HTML }
- 12-30-2009, 11:59 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
OK, this is way I followed in coding.
First of all I'm collecting complete requirement. Actually this is quite difficult to do at the beginning. I don't think anyone can do 100% completely at the beginning. And also this is the point messup our design all the time.
Anyway with the collected data move into design, define that from logic to coding design. Since we are using OO concepts we can have as many as methods basically. Normally my practice is the content of the method, or lines of the method, keep to size of the screen. Normally it's 10-15 lines. Sometimes I feel that it's too much. At the same time, I trying to place all the methods in execution order, then easy to go through the code in later developments.
More time spend on design pace than coding.
Added only very critical comments on the code as well. Use code/class header as well, which maintain with all the improvements done to the code with the version number.
Similar Threads
-
HTMLDocument Structure
By Gudradain in forum AWT / SwingReplies: 0Last Post: 01-05-2009, 11:05 AM -
while Loop (Repetition) structure.
By gapeach97 in forum New To JavaReplies: 9Last Post: 12-03-2008, 11:52 PM -
Queue data structure
By Java Tip in forum java.langReplies: 0Last Post: 04-14-2008, 08:35 PM -
Use if then else structure, help
By paul in forum New To JavaReplies: 1Last Post: 08-07-2007, 05:00 AM -
Help with Structure
By Albert in forum New To JavaReplies: 1Last Post: 07-13-2007, 03:27 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks