Interfaces only declares signatures. Wich means they state what kind of messages an object should answer to. The recommended practice...
PersonInterface person1 = Person(); ...means that you should only state what kind of messages person1 will answer to. By doing so you can change the implementation without touching the code... lets say you make a more efficient person... PersonInterface person1 = EnhancedPerson(); ...your code is upgraded by just doing that ... the example is kind of simplistic ... in a more complex scenario you can't even think of just dropping the old class or review every line of code to adjust it to the new class... ... as for "what interface to use" question, the thing is that you need to think what do you need to do with that p1 object and declare it with the right interface, if you need more than just a person you wil have to declare as an "employee" instead ... its only a "recommended practice" though, it isn't like you have to do it that way allways, with practice you'll learn where it makes sense to do so... Diego On 21 oct, 18:00, Mike Conley <[email protected]> wrote: > No comments back yet. > I interpret the issue as mainly a matter of programming style. For now, ased > on my overall experience with object oriented design, I am using the "Person > pc = new Person();" style until someone with more Java experience explains > why the other is better. > > -- > Mike Conley > > On Wed, Oct 21, 2009 at 3:02 PM, Rashaad A Wells > <[email protected]>wrote: > > > > > Did you ever get an answer for this question? If so, would you forward it > > to me? > > > Rashaad Wells- Ocultar texto de la cita - > > - Mostrar texto de la cita - --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en -~----------~----~----~----~------~----~------~--~---
