thoughts on CL project organization
Posted: Sun May 10, 2009 11:36 am
Here is how I organize my own projects. I hope maybe some of you have some comments on this.
I use packages fairly heavily, with the project spread over 9 packages currently. This is in order to encapsulate functionality, and to avoid having to load unnecessary functionality in different builds. The packages are contained within separate directories, with a main file containing the package definition.
ASDF is use to manage the system build and dependencies. I see a lot of complaining about ASDF, but it seems to works for me.
I put a test directory under each package directory, containing an additional test package. This test package separates testing dependencies and symbols from the main package, and makes it easy to load and run the tests. The ASDF definition loads the main package and the testing framework (fiveam), while the test package definition imports internal symbols from the main package as needed. Each CL code file in the main package will usually have a corresponding .test.lisp file with the associated tests.
Code files are usually centered around specific data structures (eg. CLOS classes), generic function interfaces or particular functionality. There usually some shuffling around of statements to avoid warnings at load/compile time.
package-a/package-a.asd <- builds system and loads dependencies
package-a/package-a.lisp <- defines package and possibly main package interface
package-a/blablabla.lisp <- regular lisp code compiled and loaded by ASDF
package-a/test/package-a.test.asd <- loads main system, along with test files
package-a/test/package-a.test.lisp <- test package definition along with necessary imports
package-a/test/blablabla.test.lisp <- tests associated with functionality in the blablabla.lisp file.
Well, these are just some thoughts about how I've structured my projects. I'ld be happy to hear about how the rest of you has organized your code and tests and etcetera!
-andré
I use packages fairly heavily, with the project spread over 9 packages currently. This is in order to encapsulate functionality, and to avoid having to load unnecessary functionality in different builds. The packages are contained within separate directories, with a main file containing the package definition.
ASDF is use to manage the system build and dependencies. I see a lot of complaining about ASDF, but it seems to works for me.
I put a test directory under each package directory, containing an additional test package. This test package separates testing dependencies and symbols from the main package, and makes it easy to load and run the tests. The ASDF definition loads the main package and the testing framework (fiveam), while the test package definition imports internal symbols from the main package as needed. Each CL code file in the main package will usually have a corresponding .test.lisp file with the associated tests.
Code files are usually centered around specific data structures (eg. CLOS classes), generic function interfaces or particular functionality. There usually some shuffling around of statements to avoid warnings at load/compile time.
package-a/package-a.asd <- builds system and loads dependencies
package-a/package-a.lisp <- defines package and possibly main package interface
package-a/blablabla.lisp <- regular lisp code compiled and loaded by ASDF
package-a/test/package-a.test.asd <- loads main system, along with test files
package-a/test/package-a.test.lisp <- test package definition along with necessary imports
package-a/test/blablabla.test.lisp <- tests associated with functionality in the blablabla.lisp file.
Well, these are just some thoughts about how I've structured my projects. I'ld be happy to hear about how the rest of you has organized your code and tests and etcetera!
-andré