Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Borland Delphi > Lesson 8, Struc...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 3691 of 3850
Post > Topic >>

Lesson 8, Structures, Unions, Fields, Pointers to Structures, Enums (Don't worry, Be happy: VS IDE 2008: WORSE CRAP than D2007 IDE :))

by "TheDevil" <TheDevil@[EMAIL PROTECTED] > Apr 16, 2008 at 01:33 AM

Hello,

See comments, or see website for details.

http://members.home.nl/hbthouppermans/VS2008Analysis/Index.htm

// *** Begin of Main.cpp ***

#include <stdio.h>

typedef char int8;
typedef short int int16;
typedef int int32;
typedef long long int64;

typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;

/*

15 april 2008

Lesson 8, Structures, Unions, Fields, Pointers to Structures, Enums, 
Switches,

Mission:

Test Structures, Unions, Fields, Pointers to Structures.

(
Windows.h/winbase.h seems to use:

typedef struct { fields } name for structure;

So I will use that as well, since it seems to work ok since windows exists

long by now.
)

Ok, actually not ok, I have learned a lot from this simple test and I
shall 
give points accordingly:

Tests:

Test 1, Basic structure, OK, +1 point
Test 2, Basic pointer to structure, OK, +1 point
Test 3, Dynamic structure, OK, +1 point, +1 point for easy new allocation 
syntax.
Test 4, Pointer access (->) to structure, OK, +1 point
Test 5, Alternative pointer access to structure *, BAD, doesn't work -1 
point.
Test 6, Alternative pointer access to structure (*), OK, ugly syntax -1 
point.
Test 7, Union/layout/layover structures possible, OK, +1 point.
Test 8, Enumerations possible, OK, +1 point.
Test 9, Integer typecast in combination with assignment failed (?!), BAD,
-1 
point.
Test 10, Out of range enumeration assignment/typecast possible, OK, +1 
point.
Test 11, Switch statement works ok, but it's not "pure" see test 12, OK,
+1 
point
Test 12, Breaks needed, unnecessary overhead, -1 point.
Test 13, Cases needed, unnecessary overhead, -1 point.
Test 14, Default is what exactly ? could be better: Default Case, but then

again overheadish, zero points.
Test 15, Simple if statements, unneccessary parenthesis overhead -1 point.
Test 16, Assignments possible in if statements, very stupid, -1 point.
Test 16, Simple if statement, ugly equal comparision as result of that, -1

point.

Visual Studio IDE:
Test 17, Unable to handle small tests/texts like this, IDE becomes very 
laggy, VERY BAD SIGN, -10 points.
Test 18, Had to set breakpoint twice because of laggyness, -1 point.
Test 19, No detection of garbage access or deleted memory access (just a 
stupid beep), -1 point. (Though it wasn't cleared to nil but still)
Test 20, Laggyness forces code-lazzyness, Programmer will not want to edit

code and make it more beautifull/readable/idented properly because of 
slowness !
         VERY BAD, -100 points. ABSOLUTELY A SHOWSTOPPER. PERIOD.
Test 21, Not even, recently opened projects is working decently. LOL.
Always 
latest project missing ?! It's not even on the list... at least it could
be 
on the list when multiple IDE's open ?!, -1 point.

Final Score: -112 out of 10.

Advice: Visual Studio 2008 Professional is one of the biggest pieces of 
HORSE**** I HAVE EVER SEEN.

The language C/C++ could be better... it's not bad... but the IDE is just
to 
laggy to do any big serious work, without completely ****ing up your
code.

AND PLEASE REMIND YOURSELF OF THE FOLLOWING FACTS:

This was just a short range of simple tests !

I have great fears that for larger projects this IDE will simply EXPLODE.

Exploding laptops... what's next... exploding IDE's ?! Too crazy to be
true 
?

Well it might just become true... with Visual Studio 2008 IDE !

Have yourself a nice little EXPLOSION OVER THERE :)

And remember this test was done on a 5000 EURO costing PC from 2006...
(AMD 
X2 3800+, 4 GB RAM) highly optimized PC working OK.

Not some infected piece of crap.

BIG SHAME ON MICROSOFT for developing such a TURD of an IDE.

I just can't believe how bad it really is ?!

SURPRISING ! :)

The compiler might work ok.

But what use is it.... with such a bad IDE ?!?!?!?!?!

Come on... really ?

IDE LAND IS IN TROUBLE.

Delphi 2007 IDE = CRAP
Visual Studio 2008 IDE = WORSE CRAP

WHAT THE **** IS GOING ON ?!?!?!?!

*/

// first a simple basic test, Test1
typedef struct
{
    int a;
    int b;
} TMyStructure, *PMyStructure; // Test2

// now for a slightly more difficult test. UNIONS. very very very very
very 
im****tant sometimes to access the same memory in different
// ways/layouts caaaaaaaannnnn certainly come in handy... a skill that
must 
be mastered ! ;) ====DDDDDDDDDDD :O:O:O:):(:(:(:(:D:D:D:D:D:D=DDDD

// TEST 8
enum TPacketType{ pt_unknown, pt_connection, pt_data_transfer };

// TEST 7

// higher level protocols
typedef struct
{
    uint8 mSomeConnectionData;
    uint32 mSomeMoreConnectionData;
} TConnectionPacket;

// high level protocols
typedef struct
{
    uint64 mSomeTransferData;
    uint8 mPayload[1000];
} TDataTransferPacket;

// low level wrapper/packet/protocol
typedef struct
{
    uint8 mProtocolVersion;
    TPacketType mPacketType;

    union
    {
        TConnectionPacket mConnection;
        TDataTransferPacket mDataTransfer;
    };

} TPacket, *PPacket; // one bonus point for easy pointer additions !

int main()
{
    printf("Program Started \n");

    // TEST 1, BASIC STRUCTURE HANDLING, OK

    // declare structure
    TMyStructure vMyStructure;

    // initialize structure/access fields
    vMyStructure.a = 12345;
    vMyStructure.b = 555;

    // access fields again and display for checkup.
    printf("Test1:\n");
    printf("a: %d \n", vMyStructure.a );
    printf("b: %d \n", vMyStructure.b );

    // TEST 2, POINTER TO STRUCTURE HANDLING

    // declare pointer variable to structure on heap
    PMyStructure vDynamicMyStructure;

    // TEST 3
    // allocate new structure and assign it to pointer
    vDynamicMyStructure = new TMyStructure; // wow it compiles, that's
handy 
and nice, but does it work ?, let's find out.

    // show to kinds of access methods to structure, first one uses the 
lame -> arrow... which requires holding ****ft key... cost FINGERENERGY
LOL.
    // you laughing now but wait till you have to type it 10000 times hmmm

then you not laughing anymore ! :P ;) :)

    // first initialize the fffffields.
    // TEST 4
    vDynamicMyStructure->a = 112233;
    vDynamicMyStructure->b = 555666;

    // display them.
    printf("Test2:\n");
    printf("a: %d \n", vDynamicMyStructure->a );
    printf("b: %d \n", vDynamicMyStructure->b );

    // TEST 5
    // now access them differently to show the 
world-wide-known-asterixxxxxxxx THE DREADED AND FILTHY STAR LOL
    // HAHA IT'S NOT EVEN WORKING ! NEGATIVE POINT EARNED ! :P*
//    printf("a: %d \n", *vDynamicMyStructure.a ); // WATCH OUT EVERYBODY 
IT'S THE FILTHY DREADED STAR THAT PROBABLY DROVE MANY PROGRAMMERS CRAZY
//    printf("b: %d \n", *vDynamicMyStructure.b ); // WATCH OUT EVERYBODY 
IT'S THE FILTHY DREADED STAR THAT PROBABLY DROVE MANY PROGRAMMERS CRAZY

    // TEST 6
    // OH MY GOD HOW LAME, EXTRA ( ) parenthesis needed just to make it
work 
! NEGATIVE POINT EARNED !
    // maybe they do it to force programmer to use the arrow... still 
forcing programmers to do things like that is nasty !
    // I could just as well having giving bonus points but I won't because

(*bla) is still allowed !
    // ban it, or allow it... but don't **** it like that... bad...
slightly 
frustrating, so negative point is warrented ;) :)
    // well at least it's working now.
    printf("a: %d \n", (*vDynamicMyStructure).a ); // WATCH OUT EVERYBODY 
IT'S THE FILTHY DREADED STAR THAT PROBABLY DROVE MANY PROGRAMMERS CRAZY
    printf("b: %d \n", (*vDynamicMyStructure).b ); // WATCH OUT EVERYBODY 
IT'S THE FILTHY DREADED STAR THAT PROBABLY DROVE MANY PROGRAMMERS CRAZY

    // delete/free/clean it up that filty structure :)
    // nice it works too I like it, it's nice and easy... now sizeof
needed 
plus/bonus points !
    delete vDynamicMyStructure;

    // let's test the more advanced structure/union.

    // first a static test.
    TPacket vMyPacket;

    // ONE NEGATIVE POINT for code insight... it doesn't display the
fields 
in the order in which I declared them !!!
    // pretty stupid ?! Maybe it's an option in some ide menu ? oh welll
my 
find that out later. For now it's just a distraction.
    // maybe it's a structure optimization ? Well I cannot be bother with 
such futilities :D
    vMyPacket.mProtocolVersion = 1;
    vMyPacket.mPacketType = pt_connection;

    // let's test switch statement as well hehehehe multiple flies in one 
BLOW ! BAM ! you dead... *****es ! ;) =DDDDDD
    /// who the *****es ? who the *****es ?!  =D YOU KNOW WHO YOU ARE LOL.
    // nice switch statement... just one word with some parenthesis.. 
instead of stupid : case blabla of <- two words stupid
    // switch <- one word... nice ! =D SWITCH SWITCH.. like switches...
but 
it's not really A SWITCH ! YOU FRAGGERS !
    // it can FALL THROUGH... so it's not a PURE SWITCH in the most
classic 
sense of the word !
    // you a bunch of ****ing WORD ABUSERS ! =DDDDD
    // but let's go on. YES to see how much more abuse they did :(((... ;)

=D you filthy scambags !
    // let's add ENUM TOOO to see if it can work too
    // real world example people. SNIF IT UP, it's good for you ! :)
    switch (vMyPacket.mPacketType)
    {
        // must include case labels ! INSANELY LAME... what a huge
overhead 
! STUPID !
        // oh well at least it makes it just a llllllllittlle bit more 
clear.
        // fortunately... the compilers warns.. .otherwise I wouldn't even

notice and it would be a BBBBuuuuggg ?!!
        // also for some reason the editor is becoming LAGGY ?!?!?!? WEIRD

?!
        // can't it handly my nice texting ? WACKY ****ERS ! HAHAHA.
****ty 
*****es that's nasty  ! Not really to laugh about... just laugh at ! YES.
        // me should be angry... me getting angry if this will be a
problem 
in the future !
        // ****ing scam artists ! making me believe this is actually an 
editor ?!
        // while in fact it's steaming pile of horse **** ?! WOW.
        // ONE negative point for the ****ing laggyness ! Just slightly...

but it's noticeable !
        // and besides... editor not working that nice anyway with tabs
and 
such and removing spaces/tabs and such... have to hit backspace for times
        // i could use ****ft-tab but I am not used to that... that's also
a 
very difficult combination to make with your fingers !
        // backspace requires just one finger ! oh welll I will try to use

****ft-tab in the future to remove backspaces... but then again ?!
        // it's RETARDED... because I don't know what I will remove
next... 
it might be spaces... it might be tabs... it might be characters ?!
        // therefore I am forced to always use the backspace keys !
        // conclusion: VISUAL STUDIO DEVELOPERS ARE TOTALL ****TARDS, 
HORSE****.
        // Here is some really good advice for you: use backspace key...
and 
detect what it is user is trying to remove...
        // if it's a tab... then just remove it ****ing properly. THANK
YOU 
AND HAVE A NICE DAY. BUT NOT REALLY.
        // I hope your car crashes into a FLAMING BALL OF FIRE... =D
yes... 
now I feel better =D LOL.
        // EVIL calls for EVIL. LOL

        // TEST13
        case pt_connection :
        // unnecessary statement block, but I like it for clearity ! shame

on language designers for missing it ! :P*:P*:P*:P*
        // could have been used to indicate where to break as well..
switch 
should always break anyway otherwise not a switch.
        // I don't like having to code a break ****ing everywhere... so
ONE 
negative point for stupid breaks in switch statement :P*
        {
            vMyPacket.mConnection.mSomeConnectionData = 123;
            vMyPacket.mConnection.mSomeMoreConnectionData = 5555;

            printf("vMyPacket.mConnection.mSomeConnectionData: %d \n", 
vMyPacket.mConnection.mSomeConnectionData );
            printf("vMyPacket.mConnection.mSomeMoreConnectionData: %d \n",

vMyPacket.mConnection.mSomeMoreConnectionData );

            // TEST 12
            break;
        };

        case pt_data_transfer :
        {
            vMyPacket.mDataTransfer.mSomeTransferData = 12345;
            vMyPacket.mDataTransfer.mPayload[100] = 123;

            printf("vMyPacket.mDataTransfer.mSomeTransferData: %llu \n", 
vMyPacket.mDataTransfer.mSomeTransferData );
            printf("vMyPacket.mDataTransfer.mPayload[100: %u \n", 
vMyPacket.mDataTransfer.mPayload[100] );

            break;
        };

        default:
        {
            printf("you dumb ****, you forgot the ****ing packet type, may

you rott in hell forever ! :P* \n");
        }

    }

    // ok so far so good... look pretty decent. for some minor horse**** 
here and there. see above.
    // now let's test if it still works dynamically cause you never know 
with all these ****tards nowadays. LOL.

    // same ****tard code syntax goes here:

    PPacket vDynamicMyPacket;

    // special size will be calculated when packet is send... no need to
use 
minimal size here.
    // just allocate biggest possible packet is ok.
    vDynamicMyPacket = new TPacket;

    // a GREAT WEAKNESS IS SHOWN HERE IN C/C++.

    // Switching between static and dynamic code can become quite 
troublesome !
    // I must now replace all the dots at a specific location with a ->
    // or alternatively I have to **** my code up with a crappy
parenthises 
and asterix **** up.
    // since the asterix **** up is the most easy way to replace it... I 
shall use that one.

    // it works... but it definetly looks kinda ****ed up.

    // let's repeat one time.. to test the default case as well.
    int8 test; // nice that it can just declare new variables here...
safes 
me a trip back to above... one bonus point for c.... ofcourse
    // one most be carefull one didn't declare it before... good test... 
let's see what happens if it's re-declared.

//    int8 test; // redefinition it says... kinda strange... why they call

it redifinition and not redeclaration ? maybe it mean same thing... oh
well.
              // oh well little details.
              // this laggy editor is starting to wear me down... I am 
starting to not like editing my code further to make it look better..
              // because that might require too much time... so I don't 
bother with it.
              // the point being: faster working editor leads to better 
layouted code, slower editor is therefore bad.
              // this is a very big deal.. and thus very big minus points 
are warranted.


    test = 2;
    while (test>=1)// had to set this breakpoint twice ? huh ? what you
mean 
laggy IDE LOL ?! negative point acquired ! HEY I AM NOT MAKEN THIS UP...
IT 
HAPPENED !?! godknows how one could get into trouble with that ;)
    {

    // TEST 15
    // must use parenthesis... even for such a small if statement... 
negative point acquired !
    // totally unnecessary overhead for programmer.
    // assignment without conditional expression... assignments in if 
statements ?! HAHA HOW LAME CAN ONE GET ?!?! LOLOLOL too funny...
    // negative point acquired !
//    if (test = 0)

    // TEST 16
    if (test == 1) // which leads to this uuuuuuggggggggghhllly syntax... 
well DONE... what a great **** up ! my compliments !
    {
        (*vDynamicMyPacket).mProtocolVersion = 1;

        // TEST 9
//        (uint8)((*vDynamicMyPacket).mPacketType) = 123; // some strange 
warning... can't assign value to a typecasted enum ? strange

        // TEST 10
        // let's try vice versa.
        (*vDynamicMyPacket).mPacketType = TPacketType(123); // some
strange 
warning... can't assign value to a typecasted enum ? strange

    } else
    {
        (*vDynamicMyPacket).mProtocolVersion = 1;
        (*vDynamicMyPacket).mPacketType = pt_data_transfer; // let's
switch 
type.. to test it as well.
    }

    // especially the switch statement looks kinda ****ed up... with
double 
parenthesis.
    // visual studio editor is becoming VERY LAGGY on an AMD X2 3800 !
    // SHAME ON MICROSOFT... incredibly unbelievable.... which is their 
strong point.
    // nobody will believe this editor is actually lagging on such a 
powerfull processor except those people who actually tested it, like me ;)
    // Maybe I should go back to 80486 remove the power fan... install tp7

and work on a noiseless nice performing system LOL...
    // oh well at least this horse**** is working for now... but for how 
long ? I have a feeling I will run into all kinds of problems later on...
    // time will tell.
    // TEST 11
    switch ((*vDynamicMyPacket).mPacketType)
    {
        case pt_connection :
        {
            (*vDynamicMyPacket).mConnection.mSomeConnectionData = 123;
            (*vDynamicMyPacket).mConnection.mSomeMoreConnectionData =
5555;

            printf("(*vDynamicMyPacket).mConnection.mSomeConnectionData:
%d 
\n", (*vDynamicMyPacket).mConnection.mSomeConnectionData );
           
printf("(*vDynamicMyPacket).mConnection.mSomeMoreConnectionData: 
%d \n", (*vDynamicMyPacket).mConnection.mSomeMoreConnectionData );

            break;
        };

        case pt_data_transfer :
        {
            (*vDynamicMyPacket).mDataTransfer.mSomeTransferData = 12345;
            (*vDynamicMyPacket).mDataTransfer.mPayload[100] = 123;

            printf("vMyPacket.mDataTransfer.mSomeTransferData: %llu \n", 
(*vDynamicMyPacket).mDataTransfer.mSomeTransferData );
            printf("vMyPacket.mDataTransfer.mPayload[100]: %u \n", 
(*vDynamicMyPacket).mDataTransfer.mPayload[100] );

            break;
        };


        // case default would have been more consistent, but then again a 
little bit overheadish ;)
        // TEST 14
        // now it looks a little bit weird.. default for what ? ;)
        default:
        {
            printf("you dumb ****, you forgot the ****ing packet type, may

you rott in hell forever ! :P* \n");
        }

    }

    // delete vDynamicMyPacket;   // BEEP BUG was here... deleting packet 
twice...

    test=test - 1;

    }

    // I HEAR SOME KIND OF BEEEEP ? HUH ?
    // Debugger malfunction ?
    // oh apperently it was a programming bug... I was deleting the packet

twice...
    // I wanted to re-use it... apperently it doesn't even warn... when an

access violation happens or some kind of garbage acces or whatever..
    // pretty bad... some (I'm being kind) negative points for this one...
I 
will leave the bug commnented so you can see.

    // moved to here.
    delete vDynamicMyPacket;

    printf("Program Finished \n");

    return 0;
}

// *** End of Main.cpp ***

Is this the return of Skybuck ? :)

Who knows... watch the next episode of Skybuck and the IDE wars LOL.

Bye,
  The Devil.
 




 5 Posts in Topic:
Lesson 8, Structures, Unions, Fields, Pointers to Structures, En
"TheDevil" <  2008-04-16 01:33:03 
Re: Lesson 8, Structures, Unions, Fields, Pointers to Structures
=?ISO-8859-1?Q?Danny_Str=  2008-04-16 09:33:48 
Re: Lesson 8, Structures, Unions, Fields, Pointers to Structures
Old Fan <Noway@[EMAIL   2008-04-16 22:17:43 
Re: Lesson 8, Structures, Unions, Fields, Pointers to Structures
Jim P <Jim_P@[EMAIL PR  2008-04-17 15:22:53 
Re: Lesson 8, Structures, Unions, Fields, Pointers to Structures
Ian Collins <ian-news@  2008-04-18 10:51:12 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 23 21:27:47 CDT 2008.