[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Writing and maintaining a medium-sized code base
- From: "Pierre Chapuis" <catwell@...>
- Date: Mon, 29 Aug 2016 09:20:41 +0000
My solution to that is typically:
- Use luacheck [1]. Not passing luacheck should be the same as failing
the test suite. You can write a custom .luacheckrc with exceptions
for your project, but never use globals in modules.
- Do write unit tests. If you are wondering about which test harness to
use, use Busted [2]. C.I. is not mandatory if you support a single
platform but it is very useful if you support several (especially if you
support several Lua language versions).
- There is no easy solution to the "I depend on the framework evvironment"
issue. My personal solution is the I and D in SOLID [3], i.e.: use many
small interfaces and make your business logic depend on them, not the
other way around. If you have not seen it you may want to watch
"Architecture, the lost years" which is a talk about Ruby on Rails
but explains this principle well [4]. You may also look at Go code bases,
because Go encourages this style. This doesn't prevent you from mocking,
but at least it lets you do it easily.
- Even though I like some Object-Oriented principles, I am not an
advocate for Object-Oriented code. Basically I create instances
for objects that need state and I use simple functions in modules
for things that don't; I never use inheritance. But I guess this is
more of a personal choice than anything.
- At my current company we use ldoc [5] for documentation. Sometimes I
prefer just plain human-edited Markdown files. In any case make sure
to keep documentation up to date.
[1] https://github.com/mpeterv/luacheck
[2] https://github.com/Olivine-Labs/busted
[3] https://en.wikipedia.org/wiki/SOLID_(object-oriented_design)
[4] https://www.youtube.com/watch?v=WpkDN78P884
[5] https://github.com/stevedonovan/LDoc