Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. A rant

A rant

Scheduled Pinned Locked Moved The Lounge
csharpc++career
47 Posts 19 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Shog9 0

    Ah, yes. The hallmarks of a VB app. Wait 'till you run into one where all data is stored in a system of global Object arrays... arrays that are used for completely different purposes depending on context. The last time i had to do serious VB work, it put me off programming for months afterward. Bear with it, if nothing else it'll teach you exactly why some of these practices are discouraged. And heavy drinking does help to calm the flashbacks. Somewhat.

    ----

    You're right. These facts that you've laid out totally contradict the wild ramblings that I pulled off the back of cornflakes packets.

    F Offline
    F Offline
    Flynn Arrowstarr Regular Schmoe
    wrote on last edited by
    #31

    That was what I hated in Microsoft's eMbedded Visual Basic for the CE devices -- everything was a Variant. You could declare everything as string, int, etc. but behind the scenes they were all Variant types. The language was basically VBScript with forms. Sometimes I did some useful things with it though. There's no API in eVB for working with .ini files (no API in CE that I'm aware of for that matter), so I created a simple system that read the application settings into a Variant array to mimic structures. Worked pretty well. :) I would like to think I wrote some pretty decent code in VB/eVB. But I've learned so much since then, that I don't like working in it as much. Flynn

    1 Reply Last reply
    0
    • D Dan Neely

      It doesn't matter what language you're working in, hell is other peoples code. While it's definitely easier to create a mostly working horror in VB than C/++, the latter languages have far greater scope to create a true codethulu.

      Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots. -- Robert Royall

      V Offline
      V Offline
      Vikram A Punathambekar
      wrote on last edited by
      #32

      dan neely wrote:

      hell is other peoples code

      Awesome. Mind if I make that my sig?

      Cheers, Vıkram.


      "if abusing me makes you a credible then i better give u the chance which didnt get in real" - Adnan Siddiqi.

      1 Reply Last reply
      0
      • E El Corazon

        leonej_dt wrote:

        But I need 6 months of job experience to graduate.

        Well, I would say hold out 6 months if that is all it takes. I know it is suffering. My first job was RPG-II and COBOL, I spent 4 years in it with accounting before I jumped ship. Trust me, if I can survive 4 years of RPG-II, you can survive 1/2 year of VB. Don't let your C/C++ slide, do something now and then to keep it fresh such that when you escape VB you can still program C/C++ as well as when you started doing VB work. :) and if you are completely insane like me, you will end up developing a spreadsheet program , a 4G language to language x converter, and a 4D chess game in the language you hate. There are just days I needed to do something other than accounting or I would have gone [more] completely mad! ;P

        _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb) John Andrew Holmes "It is well to remember that the entire universe, with one trifling exception, is composed of others."

        L Offline
        L Offline
        leonej_dt
        wrote on last edited by
        #33

        The program I'm maintaining doesn't do anything interesting. It just manages sales, buys, inventory and accounting... *yawn* I miss the computer graphics course I took last semester. Anyways...

        To those who understand, I extend my hand. To the doubtful I demand: Take me as I am. Not under your command, I know where I stand. I won't change to fit yout plan. Take me as I am.

        1 Reply Last reply
        0
        • E El Corazon

          leonej_dt wrote:

          But I need 6 months of job experience to graduate.

          Well, I would say hold out 6 months if that is all it takes. I know it is suffering. My first job was RPG-II and COBOL, I spent 4 years in it with accounting before I jumped ship. Trust me, if I can survive 4 years of RPG-II, you can survive 1/2 year of VB. Don't let your C/C++ slide, do something now and then to keep it fresh such that when you escape VB you can still program C/C++ as well as when you started doing VB work. :) and if you are completely insane like me, you will end up developing a spreadsheet program , a 4G language to language x converter, and a 4D chess game in the language you hate. There are just days I needed to do something other than accounting or I would have gone [more] completely mad! ;P

          _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb) John Andrew Holmes "It is well to remember that the entire universe, with one trifling exception, is composed of others."

          L Offline
          L Offline
          leonej_dt
          wrote on last edited by
          #34

          By the way, last year, a friend of mine and I worked in a three dimensional Go project. We first thought of how a Calabi-Yau Go would look like, but then I realized that my math sucks.

          To those who understand, I extend my hand. To the doubtful I demand: Take me as I am. Not under your command, I know where I stand. I won't change to fit yout plan. Take me as I am.

          1 Reply Last reply
          0
          • P Paul Conrad

            Le Centriste wrote:

            gave the impression that would be a bad thing, the goal of my reply is the exact opposite

            No worries, my bad if I misread your post:-O

            Le Centriste wrote:

            Exactly the point I wanted to make.

            Cool dude, we're on the same page :-D I do get alot of students who wonder about the idea of the purpose of writeonly, and that is one example I give. It is one of those things that can be sort of fuzzy. Not as strange as trying to explain what a Friend access modifier is.

            "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

            L Offline
            L Offline
            leonej_dt
            wrote on last edited by
            #35

            There is nothing that a WriteOnly property can do that a method can't. And I'm too used to write code like... // start and end are both pointers start = end = NULL; ... that the idea of a variable that I can write but can't read is TOTALLY weird. Besides, WriteOnly properties were only called ONCE for each object, strangely enough, always before doing the first useful thing with it. Code looked like this... ' GAAAH... VB.NET Dim JustQuiteLongVariableName As New UndocumentedClass JustQuiteLongVariableName.Parameter1 = A JustQuiteLongVariableName.Parameter2 = B + "C" JustQuiteLongVariableName.Parameter3 = "D" JustQuiteLongVariableName.DoSomethingUseful() JustQuiteLongVariableName.DoSomethingElsePerhapsItWillBeUseful() JustQuiteLongVariableName.Dispose() ... when it could have been... With New UndocumentedClass(A, B + "C", "D") .DoSomethingUseful() If .EnsureNextThingIsUseful() Then .DoNextThing() .Dispose() End With

            To those who understand, I extend my hand. To the doubtful I demand: Take me as I am. Not under your command, I know where I stand. I won't change to fit yout plan. Take me as I am.

            P 1 Reply Last reply
            0
            • P Paul Conrad

              Le Centriste wrote:

              gave the impression that would be a bad thing, the goal of my reply is the exact opposite

              No worries, my bad if I misread your post:-O

              Le Centriste wrote:

              Exactly the point I wanted to make.

              Cool dude, we're on the same page :-D I do get alot of students who wonder about the idea of the purpose of writeonly, and that is one example I give. It is one of those things that can be sort of fuzzy. Not as strange as trying to explain what a Friend access modifier is.

              "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

              L Offline
              L Offline
              leonej_dt
              wrote on last edited by
              #36

              And, by the way, I do understand friend modifiers. But it makes more sense to use friends the C++ way, not the .NET way.

              To those who understand, I extend my hand. To the doubtful I demand: Take me as I am. Not under your command, I know where I stand. I won't change to fit yout plan. Take me as I am.

              1 Reply Last reply
              0
              • L leonej_dt

                In my current job, I have to maintain a VB.NET app written by someone else. Here is my list of complaints: 0. There is no documentation and comments are written in really bad Spanish. 1. Dim this_is_a_very_long_variable_name_damn_it... The previous programmer also didn't know that the NamingConvention of variables in .NET. 2. Since he also didn't know the As clause or the DirectCast instruction existed in VB.NET, now I have to figure out whether a particular Object is a String, a DataRowView or an UndocumentedClass. 3. Some classes were plagues with WriteOnly propeties. WriteOnly properties don't ******* make sense! The only thing WriteOnly properties can do is sending parameters to an object before you call one of its methods. But that is what method parameters are for! 4. I once found this comment: ' NO SE EXACTAMENTE COMO FUNCIONA ESTO, REVISALO BIEN (translation to English: I don't know how this works exactly, check it out). Dang! Let's be more concise: PreviousProgrammer.Code.MakeBleed(Eduardo.Eyes) ' yes, really Coming from a C and C++ background, where you have to be really precise unless you like messy results, I find this situation too difficult to bear with. But I need 6 months of job experience to graduate. I hate VB (either the real VB or VB.NET). I hate people who program in VB.

                To those who understand, I extend my hand. To the doubtful I demand: Take me as I am. Not under your command, I know where I stand. I won't change to fit yout plan. Take me as I am.

                P Offline
                P Offline
                Pawel Krakowiak
                wrote on last edited by
                #37

                I wonder... Most of the same problems could be created by a C# programmer as well. var this_is_a_very_long_variable_name_damn_it; OK, casting may be a little different. ;) public string SecretPassword { private get; set; } // NO SE EXACTAMENTE COMO FUNCIONA ESTO, REVISALO BIEN :D It often seems to me that CPians are bashing VB developers just because it's VB. It's the same kind of hatred that many people have towards Microsoft, because it's, well... Microsoft.

                L 1 Reply Last reply
                0
                • P Pawel Krakowiak

                  I wonder... Most of the same problems could be created by a C# programmer as well. var this_is_a_very_long_variable_name_damn_it; OK, casting may be a little different. ;) public string SecretPassword { private get; set; } // NO SE EXACTAMENTE COMO FUNCIONA ESTO, REVISALO BIEN :D It often seems to me that CPians are bashing VB developers just because it's VB. It's the same kind of hatred that many people have towards Microsoft, because it's, well... Microsoft.

                  L Offline
                  L Offline
                  leonej_dt
                  wrote on last edited by
                  #38

                  Pawel Krakowiak wrote:

                  Most of the same problems could be created by a C# programmer as well.

                  Yes, that's true. However, the average C# programmer will create less problems than the average VB.NET programmer. And, geeeh, I'm not even saying anything about real VB (versions 1 to 6) developers.

                  Pawel Krakowiak wrote:

                  var this_is_a_very_long_variable_name_damn_it;

                  That is not C#, but JavaScript. I hate all scripting languages... well, almost all, I actually like Python (but not as much as I do like C++).

                  Pawel Krakowiak wrote:

                  It often seems to me that CPians are bashing VB developers just because it's VB.

                  No. What I hate is late binding. If I didn't have to type Option Strict to enforce DirectCasts, I would actually like VB.NET. And if it had an Unsafe directive, I would like it even more. By the way, are you Polish? I'm trying to learn Polish, but I don't find any sources to learn from.

                  To those who understand, I extend my hand. To the doubtful I demand: Take me as I am. Not under your command, I know where I stand. I won't change to fit yout plan. Take me as I am.

                  P 1 Reply Last reply
                  0
                  • P Paul Conrad

                    What's so bad about writeonly properties? They do have some use.

                    "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

                    S Offline
                    S Offline
                    Simon P Stevens
                    wrote on last edited by
                    #39

                    If you want to provide a class with some data, you pass that data in through a constructor or method parameter. By using a write only property you fuzzy the usage of the class. Assuming you want to provide a nice clean api for your class, you would keep it so that data was passed into the class as it is required. By allowing that data to be passed in whenever the caller feels like it, you reduce the strictness of the classes contract. It's not so much that a write only property is itself bad, it's just that there is no sensible reason to use a write only property instead of a method parameter. Regarding the example with the password - Remember that 'private' is only a construct of the language, it is not a feature of the CLR, or a security measure. a write only property will not stop a malicious user from reading the property out of the class with reflection, so this is not a good example of a use for write only properties Maybe I'm wrong, maybe there is a sensible and good use for a write only property. I'm happy to consider any suggestions you have. I just I can't think of any, and my instinctive reaction is that it's use will only cause disjointed code. [Edit: I suppose, like any construct (e.g. Goto) even if it's considered bad in 99% of cases, there probably are one or two situations where it makes for cleaner code]

                    Simon

                    modified on Friday, September 19, 2008 3:59 AM

                    L 1 Reply Last reply
                    0
                    • L leonej_dt

                      Pawel Krakowiak wrote:

                      Most of the same problems could be created by a C# programmer as well.

                      Yes, that's true. However, the average C# programmer will create less problems than the average VB.NET programmer. And, geeeh, I'm not even saying anything about real VB (versions 1 to 6) developers.

                      Pawel Krakowiak wrote:

                      var this_is_a_very_long_variable_name_damn_it;

                      That is not C#, but JavaScript. I hate all scripting languages... well, almost all, I actually like Python (but not as much as I do like C++).

                      Pawel Krakowiak wrote:

                      It often seems to me that CPians are bashing VB developers just because it's VB.

                      No. What I hate is late binding. If I didn't have to type Option Strict to enforce DirectCasts, I would actually like VB.NET. And if it had an Unsafe directive, I would like it even more. By the way, are you Polish? I'm trying to learn Polish, but I don't find any sources to learn from.

                      To those who understand, I extend my hand. To the doubtful I demand: Take me as I am. Not under your command, I know where I stand. I won't change to fit yout plan. Take me as I am.

                      P Offline
                      P Offline
                      Pawel Krakowiak
                      wrote on last edited by
                      #40

                      leonej_dt wrote:

                      That is not C#, but JavaScript.

                      It is C#[^]. Though in C# it's still a strongly typed variable, but from the code readability perspective it looks much like Visual Basic's Dim. I use implicitly typed variables with LINQ.

                      leonej_dt wrote:

                      By the way, are you Polish?

                      Yes.

                      leonej_dt wrote:

                      I'm trying to learn Polish, but I don't find any sources to learn from

                      I doubt I could be of much help, I was taught by parents / people around and at school. :P

                      L 1 Reply Last reply
                      0
                      • P Pawel Krakowiak

                        leonej_dt wrote:

                        That is not C#, but JavaScript.

                        It is C#[^]. Though in C# it's still a strongly typed variable, but from the code readability perspective it looks much like Visual Basic's Dim. I use implicitly typed variables with LINQ.

                        leonej_dt wrote:

                        By the way, are you Polish?

                        Yes.

                        leonej_dt wrote:

                        I'm trying to learn Polish, but I don't find any sources to learn from

                        I doubt I could be of much help, I was taught by parents / people around and at school. :P

                        L Offline
                        L Offline
                        leonej_dt
                        wrote on last edited by
                        #41

                        Pawel Krakowiak wrote:

                        It is C#[^].

                        Sorry, excuse me for my ignorance. I have VS2k5 at home.

                        Pawel Krakowiak wrote:

                        Though in C# it's still a strongly typed variable

                        Then why not state explicitly its type? What do language designers have in their minds?

                        Pawel Krakowiak wrote:

                        but from the code readability perspective it looks much like Visual Basic's Dim.

                        To me, code readability means being as semantically expressive as possible.

                        Pawel Krakowiak wrote:

                        I use implicitly typed variables with LINQ.

                        I will stick to TableAdapters.

                        Pawel Krakowiak wrote:

                        I doubt I could be of much help, I was taught by parents / people around and at school. :P

                        Nevermind. Thanks, anyways.

                        To those who understand, I extend my hand. To the doubtful I demand: Take me as I am. Not under your command, I know where I stand. I won't change to fit yout plan. Take me as I am.

                        P P 2 Replies Last reply
                        0
                        • L leonej_dt

                          Pawel Krakowiak wrote:

                          It is C#[^].

                          Sorry, excuse me for my ignorance. I have VS2k5 at home.

                          Pawel Krakowiak wrote:

                          Though in C# it's still a strongly typed variable

                          Then why not state explicitly its type? What do language designers have in their minds?

                          Pawel Krakowiak wrote:

                          but from the code readability perspective it looks much like Visual Basic's Dim.

                          To me, code readability means being as semantically expressive as possible.

                          Pawel Krakowiak wrote:

                          I use implicitly typed variables with LINQ.

                          I will stick to TableAdapters.

                          Pawel Krakowiak wrote:

                          I doubt I could be of much help, I was taught by parents / people around and at school. :P

                          Nevermind. Thanks, anyways.

                          To those who understand, I extend my hand. To the doubtful I demand: Take me as I am. Not under your command, I know where I stand. I won't change to fit yout plan. Take me as I am.

                          P Offline
                          P Offline
                          Pawel Krakowiak
                          wrote on last edited by
                          #42

                          leonej_dt wrote:

                          I will stick to TableAdapters.

                          I despise DataSets and everything related, I just rewrote whole data access code in one of my projects from DataSets/TableAdapters to LINQ to SQL this week. :P Now I have less lines of code, easier maintenance of the schema, got rid of several stored procedures but still don't have SQL spaghetti in my code, can change connection strings on the fly (this was very very annoying with typed DataSets). In overall I think that C# 3.0 is a major improvement and it rocks. I try to upgrade all projects whenever I get a chance to benefit from lambda expressions and extension methods. I love the language. :rolleyes: By the way - where does your interest in the Polish language come from?

                          1 Reply Last reply
                          0
                          • L leonej_dt

                            Pawel Krakowiak wrote:

                            It is C#[^].

                            Sorry, excuse me for my ignorance. I have VS2k5 at home.

                            Pawel Krakowiak wrote:

                            Though in C# it's still a strongly typed variable

                            Then why not state explicitly its type? What do language designers have in their minds?

                            Pawel Krakowiak wrote:

                            but from the code readability perspective it looks much like Visual Basic's Dim.

                            To me, code readability means being as semantically expressive as possible.

                            Pawel Krakowiak wrote:

                            I use implicitly typed variables with LINQ.

                            I will stick to TableAdapters.

                            Pawel Krakowiak wrote:

                            I doubt I could be of much help, I was taught by parents / people around and at school. :P

                            Nevermind. Thanks, anyways.

                            To those who understand, I extend my hand. To the doubtful I demand: Take me as I am. Not under your command, I know where I stand. I won't change to fit yout plan. Take me as I am.

                            P Offline
                            P Offline
                            Pete OHanlon
                            wrote on last edited by
                            #43

                            leonej_dt wrote:

                            Though in C# it's still a strongly typed variable Then why not state explicitly its type? What do language designers have in their minds?

                            It's a .NET3.5 thing. It allows you to create anonymous types in things like Linq. For instance:

                            var f = from c in MyDataContext.Items
                            where c.DateCreated > inputDate and c.DateCreated < terminationDate
                            select new { UserID = c.UserId, Created = c.DateCreated, TotalPosts = c.PostCount };

                            foreach (var p in f)
                            {
                            Console.WriteLine("{0} {1} {2}", p.UserID, p.Created. p.TotalPosts);
                            }

                            (Apologies for the badly named variables, but this is an example only). :-D

                            Deja View - the feeling that you've seen this post before.

                            My blog | My articles | MoXAML PowerToys

                            L 1 Reply Last reply
                            0
                            • P Pete OHanlon

                              leonej_dt wrote:

                              Though in C# it's still a strongly typed variable Then why not state explicitly its type? What do language designers have in their minds?

                              It's a .NET3.5 thing. It allows you to create anonymous types in things like Linq. For instance:

                              var f = from c in MyDataContext.Items
                              where c.DateCreated > inputDate and c.DateCreated < terminationDate
                              select new { UserID = c.UserId, Created = c.DateCreated, TotalPosts = c.PostCount };

                              foreach (var p in f)
                              {
                              Console.WriteLine("{0} {1} {2}", p.UserID, p.Created. p.TotalPosts);
                              }

                              (Apologies for the badly named variables, but this is an example only). :-D

                              Deja View - the feeling that you've seen this post before.

                              My blog | My articles | MoXAML PowerToys

                              L Offline
                              L Offline
                              leonej_dt
                              wrote on last edited by
                              #44

                              If the designers had good taste, anonymous types would only be legal when using LINQ. But, according to the documentation, this is also valid C#: var i = 100; // implicit int

                              To those who understand, I extend my hand. To the doubtful I demand: Take me as I am. Not under your command, I know where I stand. I won't change to fit yout plan. Take me as I am.

                              1 Reply Last reply
                              0
                              • L leonej_dt

                                There is nothing that a WriteOnly property can do that a method can't. And I'm too used to write code like... // start and end are both pointers start = end = NULL; ... that the idea of a variable that I can write but can't read is TOTALLY weird. Besides, WriteOnly properties were only called ONCE for each object, strangely enough, always before doing the first useful thing with it. Code looked like this... ' GAAAH... VB.NET Dim JustQuiteLongVariableName As New UndocumentedClass JustQuiteLongVariableName.Parameter1 = A JustQuiteLongVariableName.Parameter2 = B + "C" JustQuiteLongVariableName.Parameter3 = "D" JustQuiteLongVariableName.DoSomethingUseful() JustQuiteLongVariableName.DoSomethingElsePerhapsItWillBeUseful() JustQuiteLongVariableName.Dispose() ... when it could have been... With New UndocumentedClass(A, B + "C", "D") .DoSomethingUseful() If .EnsureNextThingIsUseful() Then .DoNextThing() .Dispose() End With

                                To those who understand, I extend my hand. To the doubtful I demand: Take me as I am. Not under your command, I know where I stand. I won't change to fit yout plan. Take me as I am.

                                P Offline
                                P Offline
                                Paul Conrad
                                wrote on last edited by
                                #45

                                leonej_dt wrote:

                                ... that the idea of a variable that I can write but can't read is TOTALLY weird.

                                It is weird. Only thing I can think of for a purpose is just for assigning values to a variable used internally by a class, but even that, some method could do for you, as well.

                                "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

                                S 1 Reply Last reply
                                0
                                • S Simon P Stevens

                                  If you want to provide a class with some data, you pass that data in through a constructor or method parameter. By using a write only property you fuzzy the usage of the class. Assuming you want to provide a nice clean api for your class, you would keep it so that data was passed into the class as it is required. By allowing that data to be passed in whenever the caller feels like it, you reduce the strictness of the classes contract. It's not so much that a write only property is itself bad, it's just that there is no sensible reason to use a write only property instead of a method parameter. Regarding the example with the password - Remember that 'private' is only a construct of the language, it is not a feature of the CLR, or a security measure. a write only property will not stop a malicious user from reading the property out of the class with reflection, so this is not a good example of a use for write only properties Maybe I'm wrong, maybe there is a sensible and good use for a write only property. I'm happy to consider any suggestions you have. I just I can't think of any, and my instinctive reaction is that it's use will only cause disjointed code. [Edit: I suppose, like any construct (e.g. Goto) even if it's considered bad in 99% of cases, there probably are one or two situations where it makes for cleaner code]

                                  Simon

                                  modified on Friday, September 19, 2008 3:59 AM

                                  L Offline
                                  L Offline
                                  leonej_dt
                                  wrote on last edited by
                                  #46

                                  Simon Stevens wrote:

                                  I suppose, like any construct (e.g. Goto) even if it's considered bad in 99% of cases, there probably are one or two situations where it makes for cleaner code

                                  Even goto has its uses. An elegant implementation of an in-order traversal of a tree can be implemented using goto. (The only way that can be achieved without gotos has some redundant code.) Here's the code: // BST: binary search tree struct NODE; typedef NODE *LPNODE; struct NODE { /*...*/ LPNODE left, right; }; typedef void(*action)(node); void iterate_bst(LPNODE cur, const action &a) {   if (!node) return;   CStack<LPNODE> stack; // defined somewhere else   stack.push(NULL); // very important push_parents:   // Go to last left descendant and save its ancestors in a stack.   while (cur.left)   {     stack.push(cur);     cur = cur.left;   }   do   {     // Do something to the current node.     (*a)(cur);          // If there is a right child, process it before     // return to the current node's parent.     if (cur.right)     {       cur = cur.right;       goto push_parents;     }     else       cur = stack.pop();   }   while (cur); } :-D But WriteOnly properties do not serve ANY purpose.

                                  To those who understand, I extend my hand. To the doubtful I demand: Take me as I am. Not under your command, I know where I stand. I won't change to fit yout plan. Take me as I am.

                                  modified on Friday, September 19, 2008 11:44 AM

                                  1 Reply Last reply
                                  0
                                  • P Paul Conrad

                                    leonej_dt wrote:

                                    ... that the idea of a variable that I can write but can't read is TOTALLY weird.

                                    It is weird. Only thing I can think of for a purpose is just for assigning values to a variable used internally by a class, but even that, some method could do for you, as well.

                                    "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

                                    S Offline
                                    S Offline
                                    Scott Barbour
                                    wrote on last edited by
                                    #47

                                    Yes, a method could do that for you (you could also use a method to read a variable, so why have properties at all?) I'm sure there are a number of situations where there is a property that you want to write to, but not read from. It comes down to a matter of how elegant you want the code to be. For example, which of the following two appears to be more elegant (some variables not declared for simplicity)?

                                    Dim sTemp as String
                                    Dim oFoo as New Foo

                                    sTemp = StringReturningFunction(x,y,z)
                                    oFoo.SetValue(sTemp)

                                    or

                                    Dim oFoo as New Foo

                                    oFoo.WriteOnlyProperty = StringReturningFunction(x,y,z)

                                    1 Reply Last reply
                                    0
                                    Reply
                                    • Reply as topic
                                    Log in to reply
                                    • Oldest to Newest
                                    • Newest to Oldest
                                    • Most Votes


                                    • Login

                                    • Don't have an account? Register

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular
                                    • World
                                    • Users
                                    • Groups