Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

IS-A , HAS-A

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your chief Software designer has shown you a sketch of the new Computer parts system she is about to create. At the top of the hierarchy is a Class called Computer and under this are two child classes. One is called LinuxPC and one is called WindowsPC. The main difference between the two is that one runs the Linux operating System and the other runs the Windows System (of course another difference is that one needs constant re-booting and the other runs reliably). Under the WindowsPC are two Sub classes one called Server and one Called Workstation. How might you appraise your designers work?

Answer:Ask for a re-design of the hierarchy with changing the Operating System to a field rather than Class type.

I didn't get why..
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where did the question come from?
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
probably because both a linux and a windows pc can be a workstation and a server and branching the design on the operating system would then introduce redundancy. Also while we might look at a PC as being a Linux or Windows pc in reality either one is just the same old PC and while one has-a Windows installation the other has-a Linux installation on it. Also, at a later date someone might take a PC with Windows on it, reformat and install Linux. If operating system was a field it would be facilitated by change a variable value. If it's an object there's no easy way to do it.
[ July 22, 2005: Message edited by: Sergei Iakhnin ]
 
Marcos Vilela
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The question is from Marcus Green mock exam..
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sergei Iakhnin:
...while one has-a Windows installation the other has-a Linux installation...


I like that answer. An operating system is not a computer -- it is an attribute of a computer.

(On the other hand, the degree to which this makes sense really depends on the problem you're trying to solve. The model does not always need to parallel the real world.)
[ July 22, 2005: Message edited by: marc weber ]
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi..ALL

Is this type of questions also asked in REAL exam...


Then i need to brush up on OS and related this..

Please clear me...
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ramakrishna Nalla:
.. Is this type of questions also asked in REAL exam...


Yes, this "type" of question might be asked on the exam, although I would expect it to be more straight forward than this particular example.

The main ideas to be clear about are "is a" (in which a class extends another class or implements an interface), and "has a" (in which a class or interface defines a member).
 
Does this tiny ad smell okay to you?
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic