Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - Good programming practices Q.
Thanks for the rather expansive amount of posts to my question, they were quite helpful. While not new to code design, programming, or format, I don't follow any particular standard for programming (In C++ or ASM), and having searched around a lot for acceptable programming styles, I've found that my own seem to be thought poorly of. I tend to follow a style of 'whatever is easiest to code and produces an acceptable result'. Any suggestions for good sites on not only maintainable, acceptable code, but the reasons the standards are the way they are would be appreciated. (I am concerned not so much with readability as size and speed, beings that I am given that leisure/curse of working only with a few others) Finally, two particular questions: Why is it that global variables are thought so poorly of, I haven't ever received a definate answer. Is it access speed, or the possibility for the corruption of the contents, or something else? I use, currently, an array of global variables of different byte sizes for the majority of my variables, and use defines for offsets to index them, and I am wondering if there is a way to do this more efficiently but with the same style? (An example of my variable style) #define RPRS 0 // Key buffer position #define GLOBAT 1 // Address of global color #define PROGRAMSTATE 2 // State id #define TOPX 3 // Top Coordinates, X #define TOPY 4 // Top Coordinates, Y .. .. #define NOGFOLDER 280 // True if there was no global folder #define NOGFOLDERD 281 // True if there was no drive for global folder #define CDEF 282 // Number of character defines char c[5000], // Character buffer, access characters through this array *searchstring = &c[CDEF + 200], // Scratch buffer for searching (80) *filestring = &c[CDEF + 280], // Name of local data file (80) *cwdir = &c[CDEF + 360], // Current Working Directory (80) short i[2500], // Short buffer, access 2 byte integers etc. Any advice for a somewhat capable, yet not exposed, programmer, would help. Jun 14 2002
"E. Trelmar" wrote:char c[5000], // Character buffer, access characters through this array *searchstring = &c[CDEF + 200], // Scratch buffer for searching (80) *filestring = &c[CDEF + 280], // Name of local data file (80) *cwdir = &c[CDEF + 360], // Current Working Directory (80) Jun 14 2002
"E. Trelmar" <E._member pathlink.com> wrote in message news:aed45k$5rm$1 digitaldaemon.com...Why is it that global variables are thought so poorly of, I haven't ever received a definate answer. Is it access speed, or the possibility for the corruption of the contents, or something else? Jun 14 2002
|