Encapsulate
- From: "Mike" <acout@xxxxxxx>
- Date: 18 Jan 2007 18:11:25 -0800
Hi
Allow me to repost the following as a question, as I encounter some
problem about this:
+++++++++++++++++++++++++++++++++++++++++++++++++
Following are the reply by Paulv at the post "Many small programs vs.
one large program?"
http://groups.google.com/group/comp.lang.fortran/browse_frm/thread/05c4987c2016688d/f54a9fd206da75e9?hl=en#f54a9fd206da75e9
Two things I've always tried to do (with the usual caveat about
generalisations):
1) Create procedures that do one thing, just one thing, but do
that one thing very well.
2) Test as you go.
#2 above has many different labels nowadays (unit testing, test-driven
development, etc)
but the concept is pretty simple: write tests for all your procedures.
It can be onerous
at first, but once you get into the groove it becomes (almost) second
nature. The tests
can even precede the actual code writing.
I guess there should be a #3 and that would be to encapsulate "things"
as much as
possible. When you subsequently discover a bug in one of your
already-tested components,
fixing it doesn't cause any (or, at least, too many) downstream
changes. (And don't forget
to add the test that revealed the bug to your test suite.)
cheers,
paulv
--
Paul van Delst Ride lots.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
My question is as following:
module modA
contains
subroutine SetAlgorithmParameters()
subroutine Run_SetAlgorithmParameters()
subroutine Show_Results_of_Run_SetAlgorithmParameters()
end module modA
As Pualv said " 1) Create procedures that do one thing, just one thing,
but do
that one thing very well. "
"#3 and that would be to encapsulate "things" as much as
possible."
Does the subroutine Show_Results_of_Run_SetAlgorithmParameters() need
to combine
the previous two subroutines into a big subroutine or just show the
results only?
A big one is good for encapuslation. Just input all of the arguments
including all of the three subroutines and show the results. However,
it's not flexible. Very often, I am wondering which one is better?
thank you in advance.
Mike
.
- Follow-Ups:
- Re: Encapsulate
- From: Mike
- Re: Encapsulate
- Prev by Date: Re: Many small programs vs. one large program?
- Next by Date: pop-up dialog box showing module sub/fun or derived type contents
- Previous by thread: run-time error M6101 : MATH
- Next by thread: Re: Encapsulate
- Index(es):
Relevant Pages
|
|