Thread: Hello world

  1. #31
    Registered User
    Join Date
    Aug 2001
    Posts
    411
    I think we need to strap a 3 terrahertz cooling fan on everyones head, and mabey the electric shock it gives you from the sweat on your brow will zap all this OOP knit picking out of your head.

    Here ill give you something good to argue over.

    Ive never used a class in my codeing, I allways use structs. The logic behind this is that it dont matter if the members are public private or protected. Why make a member anything other than public anyhow?




    It only gets used where you program it to be used.

  2. #32
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    Eber Kain, have you ever coded in a team ? On anything larger than you own project ? You will see that if you don't protect your stuff, people will try the strangest things with your constructs.

    Your classes have to work perfectly, even when used by total idiots. Which means that you will have to code them in a way that will make the compiler issue errors if used incorrectly. And in Java, without a functioning const keyword, that is next to impossible.

    I wonder why. The const keyword is a compiler issue. A constant object and it's methods produce the same code as a normal one.


    Have you ever thought about who coded the string class you use ? And how many mistakes you would have made if everything were possible with it ? If you could modify every single attribute ?
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #33
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    Also, if you find a way to make you code more efficient by changing the underlying implementation, allowing direct access to all your data will probably break all the code that relies on this data. If you wrap it in classes the only thing you have to change is the private implementation details and all your other code can remain as it is.
    zen

  4. #34
    Registered User
    Join Date
    Aug 2001
    Posts
    411
    I have worked on projects over the net with other people, We have never had a problem, because i provide good documentation about how to use any code i write.

    And if the person is to bumb to use it properly i dont waste my time working with them.

    Thats still not a very strong answer in my eyes. But i might change my mind whenever i get hired somewhere.

  5. #35
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    >And if the person is to bumb to use it properly i dont waste my time working with them.


    Well... you know, if you do this professionally, you don't have the choice whom you work with. And you don't need to be dumb to make mistakes. Everyone makes mistakes, but with proper programming, finding them is much easier and costs less time. And time is money.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  6. #36
    Unregistered
    Guest
    > Why make a member anything other than public anyhow?
    Code:
    class LifeSupportSystem {
       Medicine m;
       Timer t;
    
       LifeSupportSystem( Medicine med, int seconds )
       {m = new Medicine( med ); t = new Timer( seconds ); }
       DeliverDose( ) { System.out.toIV( Medicine.m, Medicine.dose }
       Stop( ) { t.seconds = -1; }
    }
    Ok then. Tell me why all of this should be public? Assume we're writing for an embedded system that controls life support. Since everything is public, what prevents me from overriding the DeliverDose( ), or to override Medicine and change the dose?

    myLifeSupporteInstance.m.dose *= 500; //oops

    Or stopping their life support by overriding the DeliverDose()?

    DeliverDose( ) { Stop( ); }

    See, there are very very good reasons to have private members.

    Quzah.

  7. #37
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    >See, there are very very good reasons to have private
    > members.

    However, I would really really like to override the timer on the cookie for this site... I guess this site prefers "speed coding". Either that or they just like you to log in again after every post.

    Quzah.

  8. #38
    Registered User
    Join Date
    Aug 2001
    Posts
    411
    Im intrested in game programming, come up with a situation where a class member would need to be private?

    No data gets changed unless you write code to change it, so unless the person is adding code to what you do, i dont see the need?

  9. #39
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    Like I said above, it can be useful to separate the implementation from the interface, as well as facilitating code reuse. However it's not necessary, there's nothing that you can do with OOP that you can't do procedurally, so if that's what you prefer stick with it. Although if you're interested in game development you'll probably encounter OOP as currently a substantial amount of games are written using it.
    zen

  10. #40
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    .
    Last edited by Troll_King; 11-30-2001 at 11:29 AM.

  11. #41
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    > Anyone going to write a C# program?

    No. We've turned this into a Java board. Sorry.

    Quzah.

  12. #42
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    C# Program:

    If you remember the thread on the game programming board some months back, I intended to write an Empire style game in C#. I still have some plans and might publish them here, but events in my life ( involving trouble with my gf and another loved one in hospital ) got this project postponed time and again. So yes, I will. Probably around christmas, when I have three weeks vacations without a single clue what to do

    >Im intrested in game programming, come up with a situation
    >where a class member would need to be private?
    >No data gets changed unless you write code to change it, so
    >unless the person is adding code to what you do, i dont see the
    >need?

    It doesn't matter what you program. If you do it alone, in your room, it's completely your choice. You can name your variables a1, a2, a3, a4, make them all global, use gotos, whatever. It will work. As soon as you work with a larger team, you will see that there are some things that need to be done to ensure good teamwork. That's nobodies fault. It's not because the others are dumb. You can't sneak in a tennis ball in a baseball game. Sure, when you are alone, you can do whatever you like. Even play with a tennis ball. But in a team, there are rules that define the game and make playing easier and more fun.

    A public member is an error waiting to happen. Maybe nothing tragic, just an hour of debugging and it's gone. Someone wanted to set nTolerance to zero, but set nT instead, which is something unrelated. The whole program crashes. It's his fault he made a mistake. It's your fault you had to spend an hour finding it. You could have prevented it by making the members private and granting access by interfaces, in which case nT might not even habe been available for changing.

    It's like you dig a hole in the ground and leave. Someone else isnn't careful and falls in. If all this happened on public territory, it's the diggers fault. He should have closed it properly.
    In your own yard, you can do what your want. It's just that after a time, no one wants to visit you anymore.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  13. #43
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    .
    Last edited by Troll_King; 11-30-2001 at 11:29 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. The 7 New Wonders of the World
    By Mario F. in forum A Brief History of Cprogramming.com
    Replies: 36
    Last Post: 12-08-2006, 01:55 PM
  2. Obfuscated Code Contest: The Results
    By Stack Overflow in forum Contests Board
    Replies: 29
    Last Post: 02-18-2005, 05:39 PM
  3. Converting from Screen to World Coordinates
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 05-11-2004, 12:51 PM
  4. Too much to ask ?
    By deflamol in forum C Programming
    Replies: 2
    Last Post: 05-06-2004, 04:30 PM
  5. No More Technology After World War Three
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 09-20-2001, 07:02 PM