Google-apps
Hoofdmenu

Post a Comment On: C0DE517E

"Code quality"

2 Comments -

1 – 2 of 2
Blogger DanielW said...

Awesome post. I would be interested in hearing more concrete ways to write self contained, throw away-able code, perhaps via an example. It's easy to write self contained code at the small scale with typical OO approaches, but it gets really difficult at larger scales with components with complex interactions.

September 6, 2009 at 10:18 PM

Blogger DEADC0DE said...

Writing modular code is not hard at any scale, per se. But at larger scales is easier to have dependencies creep in, so enforcing modularity is what you want to do.

A good start is to separate public headers from package-private ones, and have class-private declarations directly in the cpp files. Then you can enforce, possibly via a tool, a few rules on the public headers, for example that they may contain only interface classes or plain structures... Doxygen can do the trick.

That done, one of the most reasonable things is to have a programmer responsible mainly of the project structure, and lock the project makefiles from edits by anyone else.

Communication between modules can happen in different ways, I would suggest not to even assume that any module you're depending on really exist. Just import its interface and query for it, like you would do with a COM service. This way, unit testing will be easier too. Moving modules to separate DLLs will be easier too, and it's really important to kill link times and allow hot-reloading of code.

If you're starting from scratch, this is easy. But if you have a project where this is not the case... well there things become a little more complicated :D

September 7, 2009 at 8:52 PM

You can use some HTML tags, such as <b>, <i>, <a>

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.
Please prove you're not a robot