Encapsulate



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

.



Relevant Pages

  • Re: Encapsulate
    ... Following are the reply by Paulv at the post "Many small programs vs. ... When you subsequently discover a bug in one of your ... subroutine Run_SetAlgorithmParameters ... end module modA ...
    (comp.lang.fortran)
  • Re: Allow interspersed named and positional arguments?
    ... Beliavsky wrote: ... subroutine foo ... I have no idea as to the ease or difficulty of implementing your suggestion, but even you state "aking this change would not provide substantial new functionality". ...
    (comp.lang.fortran)
  • Re: Help with Fortran 77 in Iteration
    ... SUBROUTINE TABLE ... of the assignment? ...
    (comp.lang.fortran)
  • Re: Debugging large programs
    ... subroutine or function should also contain argument verification code so ... > There is a logical bug somewhere that is driving me nuts. ... > dominate the binary string. ... One other thing you might do is turn off compiler optimization and see ...
    (comp.lang.fortran)
  • 6 gfortran bugs
    ... I know I should submit them through bugzilla. ... I was hit by gcc bug 17298, but that ons is already in bugzilla. ... bug1.f90:4: internal compiler error: Possible frontend bug: array ... end subroutine string_comp ...
    (comp.lang.fortran)