I have had some experience in documenting the design for project developed in OOP languages. I made classes and used class diagrams to showcase the overall design structure of the implementation when I used OOP languages.
Problem : I am about to begin a project in C language. How am I supposed to go about writing the design document now ?
Q. Shouldn't the design document be independent of language of implementation ? But I am not able to figure out, with no classes involved in my implementation, how and between what will I show relations ?
Q. Is there any standard way to document C projects ?
I am totally confused as to what exactly am I supposed to show in the design document ? Functions ? How will I related them ?
Will appreciate link to any open source C project which might have such a documentation for reference ?
P.S. : Project is minimal kernel development in C language.
Best Answer
Write the design document as normal, with classes and objects.
C still has user-defined data types: they're just declared with the
struct
keyword instead ofclass
.C still has encapsulation and data-hiding: you just don't have the
private
keyword to make the compiler enforce it for you. Group functions operating on the same data types into a module, and just don't expose the private data outside that module.C can still have abstraction, and even inheritance if you really want it (although it's a lot of work unless you're sure it's really essential).
At implementation time, you'll have to decide how to implement each of those classes and objects.
A class might be implemented as a
struct
plus a cloud of related functions for the methods. Apart from losing some syntactic sugar, it works the same unless you need polymorphism.