When writing Object-Oriented software these days, few developers doubt the benefits of TDD. The Software Craftsmanship movement even goes one step further, and says that it is just plain irresponsible to write software without this tool.
More and more projects are using Functional programming languages, though, and TDD is not so common in this side of the software development world. Maybe TDD doesn’t make sense outside Object-Oriented software?
After experimenting with the TDD mindset and Functional languages in real-world projects, my experience is that those also benefit a lot from using tests as design aid. In this talk, let’s investigate what is generally accepted as good practices in Functional Programming and how to use TDD to take us there, with examples in Clojure.
7. Better Functional Design
Through Test-Driven
Development
Phil Calçado - SoundCloud
@pcalcado
http://philcalcado.com
Thursday, March 8, 12
8. better? what’s good
functional design,
to begin with?
Better Functional Design
Through Test-Driven
Development
Phil Calçado - SoundCloud
@pcalcado
http://philcalcado.com
Thursday, March 8, 12
22. Gzs%ef.
.
. . . . .
, . . .
. . . .
. . . . . .
. . . .
. . .
. . ,
. . . .
. . . . . .
. .
. .
. . . .
. . . .
. . . . . .
Permission to copy without fee all or part of this materinl is
granted prowded that the topics are not mada or distributed for
direct commcrciol advantage, the ACM copyright notice ond tho
lillc of the publication and its dare appear. and notice is given
that copying is by permission of the Association for Computing
Machinery. To copy othcrwisc, or to republish. requires B fee
and/or specific pornlission.
HOPL-11/4/93/MA,USA
o 1993 ACM 0-89791.571.2/93/0004/0069...$1.50
2
:LJ 2
.x E
.m 8
al
:5 a
.6
Thursday, March 8, 12
23. Programming R. Morris
Techniques Editor
On the Criteria To Be
o 1993 ACM 0-89791.571.2/93/0004/0069...$1.50
and/or specific
that copying
HOPL-11/4/93/MA,USA
Machinery.
lillc of the publication
direct commcrciol
granted
Permission
Gzs%ef.
.
.
.
.
.
.
.
.
,
. . . . .
Used in Decomposing
.
.
.
.
.
.
.
.
.
.
.
.
prowded
.
.
.
.
.
.
.
.
.
.
Systems into Modules
.
.
.
.
,
.
.
.
.
.
to copy without
To copy othcrwisc,
is by permission
.
.
.
.
.
.
.
pornlission.
.
.
.
.
.
that the topics
advantage,
D.L. Parnas
Carnegie-Mellon University
and its dare appear.
fee all or part of this materinl
the ACM copyright
of the Association
are not mada or distributed
or to republish.
This paper discusses modularization as a mechanism Introduction
and notice is given
for improving the flexibility and comprehensibility of a
for Computing
notice ond tho
A lucid statement o f the philosophy o f m o d u l a r
requires
system while allowing the shortening of its development
time. The effectiveness of a "modularization" is p r o g r a m m i n g can be f o u n d in a 1970 t e x t b o o k on the
dependent upon the criteria used in dividing the system design o f system p r o g r a m s by G o u t h i e r and P o n t [1,
B fee
into modules. A system design problem is presented and ¶I0.23], which we quote below: 1
for
is
both a conventional and unconventional decomposition A well-defined segmentation of the project effort ensures
are described. It is shown that the unconventional system modularity. Each task forms a separate, distinct program
decompositions have distinct advantages for the goals module. At implementation time each module and its inputs and
outputs are well-defined, there is no confusion in the intended
outlined. The criteria used in arriving at the decom- interface with other system modules. At checkout time the in-
positions are discussed. The unconventional decomposi- tegrity of the module is tested independently; there are few sche-
tion, if implemented with the conventional assumption duling problems in synchronizing the completion of several tasks
before checkout can begin. Finally, the system is maintained in
that a module consists of one or more subroutines, will modular fashion; system errors and deficiencies can be traced to
be less efficient in most cases. An alternative approach specific system modules, thus limiting the scope of detailed error
.6
:5
:LJ
.m
.x
al
to implementation which does not have this effect is searching.
sketched. Usually nothing is said a b o u t the criteria to be used
Key Words and Phrases: software, modules, in dividing the system into modules. This paper will
a
2
8
E
2
modularity, software engineering, KWIC index, discuss that issue and, by means o f examples, suggest
software design some criteria which can be used in d e c o m p o s i n g a
CR Categories: 4.0 system into modules.
A Brief Status Report
The m a j o r a d v a n c e m e n t in the area o f m o d u l a r
p r o g r a m m i n g has been the development o f coding
techniques and assemblers which (l) allow one module
to be written with little knowledge o f the code in
a n o t h e r module, and (2) allow modules to be reas-
Copyright @ 1972, Association for Computing Machinery, Inc. sembled and replaced without reassembly o f the whole
General permission to republish, but not for profit, all or part
of this material is granted, provided that reference is made to this system. This facility is extremely valuable for the
publication, to its date of issue, and to the fact that reprinting production o f large pieces o f code, but the systems m o s t
privileges were granted by permission of the Association for Com- often used as examples o f p r o b l e m systems are highly-
puting Machinery.
Author's address: Department of Computer Science, Carnegie- modularized p r o g r a m s and make use o f the techniques
Mellon University, Pittsburgh, PA 15213. mentioned above.
1 Reprinted by permission of Prentice-Hall, Englewood
Cliffs, N.J.
1053 Communications December 1972
of Volume 15
the ACM Number 12
Thursday, March 8, 12