Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Polyphorism

Options
  • 01-02-2005 1:24pm
    #1
    Registered Users Posts: 1,455 ✭✭✭


    Ok so I've got an interview for a graduate development job tomorrow and no matter how books I read I can't get a good definition for good ole polyphorism.

    I've got an understanding of this in my head but trying to put that into words that an interviewer might understand is where I always fumble.

    Anyone got any good 5 or 6 line description.

    Any response before half 5 would be great.

    Regards,
    Tim


Comments

  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    Maybe cause your searching for the wrong thing, try polyMORphism.

    Incidentally, when I was learning Java it was a Spanish guy teaching us, he came in at the start of the lesson and wrote it up on the board, every time he needed to say "polymorphism" he'd say "that word on the board" :)


  • Closed Accounts Posts: 2 misterfoo


    Well, having an understanding in your head is better than having a definition to parrot. If the interviewer wants a literal definition rather than a demonstration that you understand the concept, then the only right answer is the one from the OO programming book the interviewer has on their shelf. You can demonstrate an understanding by citing examples and sketching out what they have in common. You can especially demonstrate an understanding if you can point out a use of polymorphism in material that the interviewer has brought up and that you've never seen before.

    Polymorphism is something like:
    standard global messages + custom local message handling
    or
    standard public method signatures (in abstract classes & interfaces) + custom local method implementations (in subclasses)
    Polymorphism is good in less than 25 words because: standard global messages => loose coupling, stable architecture, reuse of infrastructure, etc; custom local message handling => flexibility, customisability, modifiability, etc.

    An example of polymorphism: if you click on Open or Print in the rightclick menu of a file in Windows, you're sending a standard message that's responded to in different ways by the different types of file.

    (I think that's polymorphism anyway, unless I'm mixing it up with some other Good Thing).


  • Registered Users Posts: 174 ✭✭padlad


    "Polymorphism (means the ability to take more than one form) is the ability of different functions to be invoked with the same name.

    There are two forms.
    Static polymorphism is the common case of overriding a function by providing additional definitions with different numbers or types of parameters. The compiler matches the parameter list to the appropriate function.

    Dynamic polymorphism is different and relies on parent classes to define virtual functions which child classes may redefine. When this virtual member function is called for an object of the parent class, the execution dynamically chooses the appropriate function to call - the parent function if the object really is the parent type, or the child function if the object really is the child type. "

    clear?


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Anyone got any good 5 or 6 line description.

    Any response before half 5 would be great.
    Would you like one of us to sit the interview for you? Maybe make you breakfast too..?


  • Closed Accounts Posts: 9,314 ✭✭✭Talliesin


    I've only ever seen static polymorphism defined as the use of templates to determine functionality at compile time, not over-loading.

    The term on its own tends to mean dynamic polymorphism.


  • Advertisement
  • Closed Accounts Posts: 2 misterfoo


    I've never found the word itself much use. Nobody says "we need to throw in a little polymorphism over there", they say "can we get rid of that dependency", or they say "can we modify that behaviour in the subclass". I've never found it very useful to think of it as the ability to take on many forms - that just reminds me of Superman.

    'Polyphorism' probably means the ability to carry many things.


  • Closed Accounts Posts: 324 ✭✭madramor


    you should be able to give a real world description of polymorphism
    if you have vehicles
    car and boat and jet
    to move vehicle you go vehicle.move()
    car.move() turn the wheels
    boat.move() rotate the propeller
    jet.move() blow air out jets

    and also a coded example, best if, from where you have used it.
    best examlpe is the action classes from MVC architecture
    http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/web-tier/web-tier5.html#1080752
    section 4.4.2.1.2 Invoking Model Methods
    I've got an understanding of this in my head but trying to put that into words that an interviewer might understand is where I always fumble.
    if you cannot communicate it to another person, it means you don't
    understand it properly.


    ps i'm interviewing grads this week for junior developer roles


Advertisement