Thread: member functions not working properly

  1. #16
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Quote Originally Posted by medievalelks View Post
    In good OO design, classes encapsulate behavior. Just providing getters and setters of state is not a lot different than passing structs around.
    That was not the point frankly. While I would agree that getters and setters can break encapsulation it depends on what the object is supposed to do, and even then, messaging is still a fundamental OOP concept.

    From wikipedia:
    Message passing

    "The process by which an object sends data to another object or asks the other object to invoke a method.” [1] Also known to some programming languages as interfacing. E.g. the object called Breeder may tell the Lassie object to sit by passing a 'sit' message which invokes Lassie's 'sit' method.

  2. #17
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Quote Originally Posted by citizen View Post
    That was not the point frankly. While I would agree that getters and setters can break encapsulation it depends on what the object is supposed to do, and even then, messaging is still a fundamental OOP concept.

    From wikipedia:

    Yes, "sit" is a behavior of dog. Calling member functions to set the position of the dog's legs, hind quarters, tail, etc. to place it in a sitting position is what I'm arguing against. Inside the dog class, it perhaps has-a Mesh, on which operations like this might make sense.

  3. #18
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    But then again, the outside should probably not be able to control the dog directly. Either you make the object public, or make a get function or just wrapper functions. The latest would provide more encapsulation.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #19
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Quote Originally Posted by Elysia View Post
    But then again, the outside should probably not be able to control the dog directly. Either you make the object public, or make a get function or just wrapper functions. The latest would provide more encapsulation.

    Well, at some point, *something* is going to use the dog's public interface. I was focussing on the granularity of that interface.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 04-19-2008, 12:06 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Static functions.... why?
    By patricio2626 in forum C++ Programming
    Replies: 4
    Last Post: 04-02-2007, 08:06 PM
  4. member functions can't see private data members
    By ichijoji in forum C++ Programming
    Replies: 2
    Last Post: 11-22-2006, 02:36 PM
  5. Templated member functions
    By Highland Laddie in forum C++ Programming
    Replies: 5
    Last Post: 05-15-2006, 05:25 PM