For Programmers: Free Programming Magazines  


Home > Archive > Java Help > June 2007 > Design qq









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Design qq
Bluto Blutarsky

2007-06-25, 10:11 pm

.... is it better to have a program with, say, 10 methods
and then call each 10 from the mainline OR have the mainline call
the first which calls the second which calls ... the second
.... the third ... thr tenth.?

b

--
Sometimes I'm in a good mood.
Sometimes I'm in a bad mood.
When all my moods have cum to pass
i hope they bury me upside down
so the world can kiss me porcelain,
white, Irish bottom.
Hendrik Maryns

2007-06-25, 10:11 pm

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bluto Blutarsky schreef:
> ... is it better to have a program with, say, 10 methods
> and then call each 10 from the mainline OR have the mainline call
> the first which calls the second which calls ... the second
> ... the third ... thr tenth.?


This question cannot be answered. Think of it in meanings: what does
the first method do, semantically, what does the second one do? Is it
something that should be done inside the first one? Then yes, call it
from the first one. If no, why would you?

What is the sense of this question anyway?

H.

- --
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGgAdDe+7xMGD3itQRAoZRAJwPO7ujMOeo
UriGRFoPhjQbfyau/ACfVnpL
DHcrLuUREAj5w45MXqlroLA=
=17qX
-----END PGP SIGNATURE-----
kaldrenon

2007-06-25, 10:11 pm

In simplistic examples, when you know they're all going to get called
in sequence, it doesn't really matter, and depending on the size of
each method you could just put them in main(). but the more complex it
gets, the more context-sensitive, and consequently the harder the
question is to answer outright.

Malcolm Dew-Jones

2007-06-25, 10:11 pm

kaldrenon (kaldrenon@gmail.com) wrote:
: In simplistic examples, when you know they're all going to get called
: in sequence, it doesn't really matter, and depending on the size of
: each method you could just put them in main(). but the more complex it
: gets, the more context-sensitive, and consequently the harder the
: question is to answer outright.

If function 1 calls function 2, then how do you test function 1 without
testing function 2?

Answer that and you have your answer, which will vary from case to case.

Roedy Green

2007-06-25, 10:11 pm

On Mon, 25 Jun 2007 13:44:09 -0400, Bluto Blutarsky
<comprehensivecenter> wrote, quoted or indirectly quoted someone who
said :

>... is it better to have a program with, say, 10 methods
>and then call each 10 from the mainline OR have the mainline call
>the first which calls the second which calls ... the second
>... the third ... thr tenth.?


I would prefer the first sort of design. It is easier to get an
overview of what is going on.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Faton Berisha

2007-06-26, 10:10 pm

Bluto Blutarsky wrote:
> ... is it better to have a program with, say, 10 methods
> and then call each 10 from the mainline OR have the mainline call
> the first which calls the second which calls ... the second
> ... the third ... thr tenth.?
>
> b
>


The answer depends upon the simulation you are going to model.

The following are some of the issues you should consider in order to
properly answer the question.

Are the remaining 9 methods parts of the first method's algorithm? (It
might help you answer this question if you thought whether these should
be public or private methods.)

Is the reason for having 10 methods breaking the complexity of the
original problem, or is it the complexity of a sub-algorithm?

What is your design? Which are its components?

What does the word "better" in your question mean? Optimized speed? Some
other resource? Better design architecture?

Hope it helps.

Faton Berisha
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com