2

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.

1
  • 1
    I have doubts that class diagrams are a good instrument to document the overall design structure of a program, even when you use an OO language, because they are on a too low level of abstraction. I use to think in components, not classes, and dataflow between those components. Look, for example, here geekswithblogs.net/theArchitectsNapkin/archive/2011/03/19/…, for a possible notation. This approach is mostly language independent.
    – Doc Brown
    Commented Sep 13, 2013 at 19:44

2 Answers 2

3

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 of class.

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.

2

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 ?

Often, an architectural design will be independent of language, to the extent possible. If any technology decisions have been made in advance, they may be included in the system architecture. Detail designs to tend to consider the development language so that the notations used are relevant to the people building and/or maintaining the system. If you're creating a detail design and you know the application will be written in C, use the terminology and constructs from C.

Is there any standard way to document C projects ?

There are many ways to document C projects. Some constructs from UML can be used, keeping in mind that some of the object-oriented terms don't apply and therefore shouldn't be used. Class diagrams, activity diagrams, component diagrams, and sequence diagrams can be used, to varying extents, often using a subset of the complete UML language. Alternatively, data flow diagrams, data structure diagrams, or JSP diagrams can be used. Textual representations (including creating pseudocode before implementing algorithms) are also valid.


Something to keep in mind is the purpose of the design documentation. All design documents should indicate how the system is going to fulfill the requirements. The rest depends on the audience. If you're going to be designing and implementing the system, then the documentation can serve as a guide for future developers and testers. IF you are just designing the system, you need to be far more explicit in inputs and outputs so that, given only the models and descriptions of the system, someone can build something that meets your needs.

1
  • +1, especially for giving pointers to the UML alternatives.
    – Doc Brown
    Commented Sep 13, 2013 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.