IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New You misunderstand interfaces and factories ...
You stated the following:
"But the programmer has to know what object is being returned and write code apropriately. Unless every method in every class exists in every other class. If any of the possible child classes has a public function that doesn't exist in the others the programmer has to know not to call it."

In a statically typed language like Java what you wrote is simply not true. A factory should always return an interface. Therefore any Object that you get back from the factory by definition implements all of the methods in the interface. Therefore the only, methods that you can call are the interface methods. The programmer doesn't have to know anything more then the interface. From his perspective the only methods that exist are those that the interface declares and any object that he gets backs is guaranteed to implements them therefore there are no decisions.

In a dynamically typed like language like Smalltalk what you said is theoretically possible but from experience almost never happens. Factories return classes that implicitly implement some interface and those are the methods that are used.

In fact, in a dynamically typed language you never whether an Object implements a method, it is only checked at runtime. In reality, that is not an issue. You know what type of Object you are supposed to be getting.
Expand Edited by bluke Sept. 23, 2004, 10:50:40 AM EDT
Expand Edited by bluke Sept. 23, 2004, 11:20:06 AM EDT
New Drew is right.
Some person or bit of code at some time must decide whether to instantiate an object of class B or one of class C. Find out where and when that happens in your language of choice and you can stop talking past each other.
New My point was
thatin OO code you make that decision once and then polymorphism works for you. In procedural code that decision is scattered all over the place.
     Lines of code in a Java method ... - (bluke) - (73)
         I don't know of studies of this with OO languages - (ben_tilly) - (64)
             I remember that when I read Code Complete ... - (bluke) - (60)
                 Hence my speculation about how and why to change that for OO -NT - (ben_tilly) - (59)
                     In OO code many of the decision points ... - (bluke) - (58)
                         Quibble - (ben_tilly) - (57)
                             Okay, thought it was just me - (drewk) - (46)
                                 Not really missing anything. - (FuManChu) - (1)
                                     VMT in C++ - (Arkadiy)
                                 The superclass decides nothing - (ben_tilly) - (43)
                                     Once again, it's the terminology - (drewk) - (40)
                                         That's not multiple inheritance - (ben_tilly)
                                         Ramble ramble ramble - (FuManChu)
                                         Yes and No - (bluke) - (37)
                                             I mis-read Ben - (drewk) - (36)
                                                 You misunderstand interfaces and factories ... - (bluke) - (2)
                                                     Drew is right. - (FuManChu) - (1)
                                                         My point was - (bluke)
                                                 I'm actually on the fence - (ben_tilly) - (32)
                                                     That is with implementation inheritance - (bluke) - (2)
                                                         That is both with interface and implementation inheritance - (ben_tilly) - (1)
                                                             With interfaces it is less of a concern - (bluke)
                                                     Hadn't heard of LSP - (drewk) - (28)
                                                         Huh? - (tuberculosis) - (27)
                                                             Don't get all religious on me - (drewk) - (26)
                                                                 Going to disagreed on this point - (JimWeirich) - (1)
                                                                     agreed - (deSitter)
                                                                 Re: Don't get all religious on me - (JimWeirich) - (23)
                                                                     And that's the key point - (ben_tilly) - (22)
                                                                         Someday I've got to take a class - (drewk) - (21)
                                                                             ..when I get my inheritance -NT - (deSitter)
                                                                             Yup. No generic substitute for that. -NT - (FuManChu)
                                                                             Good idea in this instance. - (admin) - (14)
                                                                                 I object; it's part of a general pattern -NT - (FuManChu) - (13)
                                                                                     Ah, but I have a cunning strategy... - (admin) - (12)
                                                                                         Bah. Overridden. - (FuManChu) - (1)
                                                                                             Overloaded your capacity for understanding, eh? - (admin)
                                                                                         Ashton, is that you? - (Another Scott) - (7)
                                                                                             Better than the treasurer... - (admin) - (6)
                                                                                                 He'll have to wait - I'm collecting garbage - (ben_tilly) - (5)
                                                                                                     Coincidentally, there's a fellow around here named Mark... - (admin) - (4)
                                                                                                         I'm sorry but that pointer is dangling - (ben_tilly) - (3)
                                                                                                             Some people have too much time on their hands... - (static) - (2)
                                                                                                                 You're a real LALRf riot. - (admin) - (1)
                                                                                                                     So you sed. Personally, I think it's a Perl in the Blinker. -NT - (Another Scott)
                                                                                         Uuuuuhh... - (jb4)
                                                                                         The cun.. er, clever linguist suffers Code 715 - (Ashton)
                                                                             Or an interface - (tuberculosis) - (2)
                                                                                 Yes, and that's what we do - (drewk) - (1)
                                                                                     Language doesn't need to support abstract class - (tuberculosis)
                                                                             That was not what I meant - (bluke)
                                     It's a decision, but it's abstracted out - (Arkadiy) - (1)
                                         Yes, but I don't care how it works - (bluke)
                             DP's are compressed in OO - (tuberculosis) - (6)
                                 Polymorphism relies on a lie - (tablizer) - (5)
                                     Re: Polymorphism relies on a lie - (admin) - (2)
                                         Mostly, it is - (tablizer) - (1)
                                             To the naive programmer, perhaps. - (admin)
                                     Something tells me you'd like prototype OO as a midground -NT - (FuManChu) - (1)
                                         *No-one* can eat that much crow -NT - (pwhysall)
                             We had a big fight over case-vs-poly a few years ago -NT - (tablizer) - (2)
                                 Charley Rock Tree - (ChrisR) - (1)
                                     Ha! :-) -NT - (Another Scott)
             Re: I don't know of studies of this with OO languages - (deSitter)
             Interesting comment by Ron Jeffries - (bluke) - (1)
                 Re: Interesting comment by Ron Jeffries - (deSitter)
         to minimize the damage that these kind of developers wreak - (Arkadiy) - (1)
             Unfortunately I can't - (bluke)
         4. -NT - (FuManChu) - (2)
             In smalltalk that might be realistic - (bluke) - (1)
                 That was my point. Glad someone got the joke :) -NT - (FuManChu)
         1/2 page - (tuberculosis)
         Re: Lines of code in a Java method ... - (dshellman) - (1)
             Agree - (bluke)

Powered by the Casimir effect!
196 ms