How to structure a C program effectively

后端 未结 7 1433
独厮守ぢ
独厮守ぢ 2020-12-24 12:01

Let me first say that I\'ve got a fair amount of experience in both C and C++. However, I\'m starting a new project in C and I\'ve been working in object-oriented languages

7条回答
  •  Happy的楠姐
    2020-12-24 12:22

    Hmmm... We used to just use naming conventions... Ergo: str* does stuff with what common datastructure? So maybe just take the C# syntax and s/./_/g?

    • foo_constructor
    • foo_destructor
    • foo_someMethod
    • foo_someMethod2 // ain't no overloading in ANSI C
    • foo_otherMethod

    ... and there ain't no inheritance ...

    • foo2_constructor
    • foo2_destructor
    • foo2_someMethod // and there ain't no polymorphism

    But look on the bright side... you can use pointer-to-pointer-to-pointer-to-function-returning-a-pointer-to-pointer-int! Oh the joy!

    My bestest advise is to learn the lessons of Java (and by inference C#) and structure your libraries to NOT have side-effects... more typdefs == less headaches... and if your work-out how to follow this sage advise please let me know ;-)

    Cheers. Keith.

提交回复
热议问题