Click here to Skip to main content
16,008,010 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Use session for pass value Pin
Paul Conrad13-Mar-08 11:42
professionalPaul Conrad13-Mar-08 11:42 
GeneralRe: Use session for pass value Pin
DavidNohejl13-Mar-08 11:53
DavidNohejl13-Mar-08 11:53 
GeneralRe: Use session for pass value Pin
Paul Conrad13-Mar-08 11:59
professionalPaul Conrad13-Mar-08 11:59 
GeneralRe: Use session for pass value Pin
Vasudevan Deepak Kumar14-Mar-08 4:30
Vasudevan Deepak Kumar14-Mar-08 4:30 
GeneralRe: Use session for pass value Pin
Paul Conrad14-Mar-08 4:35
professionalPaul Conrad14-Mar-08 4:35 
GeneralRe: Use session for pass value Pin
rameez nakash m.k17-Mar-08 23:49
rameez nakash m.k17-Mar-08 23:49 
GeneralRe: Use session for pass value Pin
Krirk20-Mar-08 0:12
Krirk20-Mar-08 0:12 
GeneralReal coding horror... by me! :) Pin
leonej_dt11-Mar-08 20:23
leonej_dt11-Mar-08 20:23 
First of all, hello. I'm a newbie. Since this section is called Coding Horrors, I thought it would be funny to share this C++ header file I wrote a few days ago:

http://www.geocities.com/fruitcake59/Prototype.txt[^]

The following tokens are actually macros: name, type, state, stype, parent, ptype, base, nodeclare, notserial. The two first ones (name and type) MUST be defined before including Prototype.h. The other ones are optional.

If you see something like this...

<q style="color: black"><q style="color: blue">#ifdef</q> SOME_TOKEN<br />
SOME_TOKEN<br />
<q style="color: blue">#undef</q> SOME_TOKEN<br />
<q style="color: blue">#endif</q></q>


... then SOME_TOKEN is also an optional macro that can be defined before including Prototype.h.

Here's an example of how to use this header file:

<q style="color: black"><q style="color: green">// This belongs to Instruction.h</q><br />
<q style="color: blue">#pragma once</q><br />
<br />
<q style="color: blue">#pragma region</q> Class Names<br />
<br />
<q style="color: blue">#define</q> name CInstruction<br />
<q style="color: blue">#define</q> type INSTRUCTION<br />
<q style="color: blue">#define</q> state CInstrState<br />
<q style="color: blue">#define</q> stype INSTRSTATE<br />
<q style="color: blue">#define</q> parent mpParent<br />
<q style="color: blue">#define</q> ptype CModule<br />
<q style="color: blue">#define</q> nodeclare<br />
<br />
<q style="color: blue">#pragma endregion</q><br />
<br />
<q style="color: blue">#pragma region</q> Friendships<br />
<br />
<q style="color: blue">#define</q> CONST_FRIENDSHIPS \<br />
    <q style="color: blue">friend class</q> CModule; \<br />
    <q style="color: blue">friend struct</q> MODULE;<br />
<br />
<q style="color: blue">#pragma endregion</q><br />
<br />
<q style="color: blue">#pragma region</q> Data Structures<br />
<br />
<q style="color: blue">#define</q> VAR_ATTRIBUTES \<br />
    CStringList slParams;<br />
<br />
<q style="color: blue">#pragma endregion</q><br />
<br />
<q style="color: blue">#pragma region</q> Constructor<br />
<br />
<q style="color: blue">#define</q> CONSTRUCTOR \<br />
    CInstruction(CModule *mpParent); \<br />
    CInstruction(CModule *mpParent, CString &sName);<br />
<br />
<q style="color: blue">#pragma endregion</q><br />
<br />
<q style="color: blue">#pragma region</q> Object Operations<br />
<br />
<q style="color: green">// GET_COUNT and GET_CHILD defined at stdafx.h</q><br />
<q style="color: blue">#define</q> CONST_GETTERS \<br />
    GET_COUNT() \<br />
    GET_CHILD(GetParameter, GetParamSt, CString, )<br />
<br />
<q style="color: blue">#define</q> CONST_DOERS \<br />
    <q style="color: blue">void</q> EditParameter(INT_PTR i, LPCTSTR s);<br />
<br />
<q style="color: blue">#pragma endregion</q><br />
<br />
<q style="color: blue">#pragma region</q> State Operations<br />
<br />
<q style="color: green">// GET_CHILD_COUNT and GET_CHILD_STATE defined at stdafx.h</q><br />
<q style="color: blue">#define</q> VAR_GETTERS \<br />
    GET_CHILD_COUNT(slParams) \<br />
    GET_CHILD_STATE(GetParamSt, CString &, slParams)<br />
<br />
<q style="color: green">// ADD_CHILD_STATE, EDIT_CHILD_STATE and DELETE_CHILD_STATE defined at stdafx.h</q><br />
<q style="color: blue">#define</q> VAR_DOERS \<br />
    ADD_CHILD_STATE(AddParamSt, LPCTSTR, slParams) \<br />
    EDIT_CHILD_STATE(EditParamSt, LPCTSTR, slParams) \<br />
    DELETE_CHILD_STATE(DeleteParamSt, slParams)<br />
<br />
<q style="color: green">// COPY_LIST defined at stdafx.h</q><br />
<q style="color: blue">#define</q> COPY_STATE \<br />
    COPY_LIST(slParams)<br />
<br />
<q style="color: blue">#pragma endregion</q><br />
<br />
<q style="color: blue">#pragma region</q> Private Tools<br />
<br />
<q style="color: blue">#define</q> CONST_TOOLS \<br />
    <q style="color: blue">void</q> AfterParamUpdate();<br />
<br />
<q style="color: blue">#pragma endregion</q><br />
<br />
<q style="color: blue">#include</q> <q style="color: red">"Prototype.h"</q></q>

GeneralRe: Real coding horror... by me! :) Pin
Paul Conrad12-Mar-08 5:22
professionalPaul Conrad12-Mar-08 5:22 
JokeRe: Real coding horror... by me! :) Pin
Justin Perez12-Mar-08 5:25
Justin Perez12-Mar-08 5:25 
GeneralRe: Real coding horror... by me! :) Pin
leppie12-Mar-08 6:14
leppie12-Mar-08 6:14 
GeneralRe: Real coding horror... by me! :) Pin
Justin Perez13-Mar-08 2:50
Justin Perez13-Mar-08 2:50 
GeneralRe: Real coding horror... by me! :) Pin
sammyamma12-Mar-08 11:06
sammyamma12-Mar-08 11:06 
GeneralRe: Real coding horror... by me! :) Pin
Pete O'Hanlon12-Mar-08 12:21
mvePete O'Hanlon12-Mar-08 12:21 
GeneralRe: Real coding horror... by me! :) Pin
Justin Perez13-Mar-08 2:51
Justin Perez13-Mar-08 2:51 
GeneralRe: Real coding horror... by me! :) Pin
NormDroid13-Mar-08 0:49
professionalNormDroid13-Mar-08 0:49 
GeneralWTF @ TheDailyWTF Pin
leppie11-Mar-08 5:54
leppie11-Mar-08 5:54 
GeneralRe: WTF @ TheDailyWTF Pin
Robert Surtees11-Mar-08 9:55
Robert Surtees11-Mar-08 9:55 
GeneralRe: WTF @ TheDailyWTF Pin
Lutosław11-Mar-08 13:49
Lutosław11-Mar-08 13:49 
GeneralRe: WTF @ TheDailyWTF Pin
Paul Conrad12-Mar-08 5:23
professionalPaul Conrad12-Mar-08 5:23 
GeneralRe: WTF @ TheDailyWTF Pin
leppie12-Mar-08 6:06
leppie12-Mar-08 6:06 
GeneralRe: WTF @ TheDailyWTF Pin
jhwurmbach12-Mar-08 7:18
jhwurmbach12-Mar-08 7:18 
GeneralStudying informatics... PinPopular
Lutosław10-Mar-08 13:23
Lutosław10-Mar-08 13:23 
GeneralRe: Studying informatics... Pin
Paul Conrad10-Mar-08 16:45
professionalPaul Conrad10-Mar-08 16:45 
GeneralRe: Studying informatics... Pin
Himanshu Joshi10-Mar-08 18:40
Himanshu Joshi10-Mar-08 18:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.