Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CS304 Object Oriented Programming GDB Solution Spring Semester July 2013
#1
[B]



CS304 Object Oriented Programming GDB Solution Spring Semester July 2013


Suppose you are working as a software developer in a company. You have been given a task to develop a software system design for some real world scenario. One of the basic activities of any software system design is to establish relationships between classes. Suppose at the stage of creating relationships for some classes, you have to choose either inheritance or composition as these are two fundamental ways to relate classes by achieving feature of code re-usability. Being a developer, for what reasons, would you prefer one technique to the other keeping in mind the reusability factor? Support your answer with solid reasons.

[B]Solution:


Inheritance is not well suited for code reuse. Inheriting for code reuse usually leads to:

Classes with inherited methods that must not be called on them (violating the Liskov substitution principle), which confuses programmers and leads to bugs.
Deep hierarchies where it takes inordinate amount of time to find the method you need when it can be declared anywhere in dozen or more classes.
Generally the inheritance tree should not get more than two or three levels deep and usually you should only inherit interfaces and abstract base classes.

Substitution
Coil Spring
Local Jobs
Linux operating system
Government Jobs

There is however no point in rewriting existing code just for sake of it. However when you need to modify, try to switch to composition where possible. That will usually allow you to modify the code in smaller pieces, since there will be less coupling between the classes.[/B][/B]

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply
#2
[SIZE="4"]Solution: [/SIZE]

Inheritance is not well suited for code reuse. Inheriting for code reuse usually leads to:

Classes with inherited methods that must not be called on them (violating the Liskov substitution principle), which confuses programmers and leads to bugs.
Deep hierarchies where it takes inordinate amount of time to find the method you need when it can be declared anywhere in dozen or more classes.
Generally the inheritance tree should not get more than two or three levels deep and usually you should only inherit interfaces and abstract base classes.

Substitution
Coil Spring
Local Jobs
Linux operating system
Government Jobs

There is however no point in rewriting existing code just for sake of it. However when you need to modify, try to switch to composition where possible.
That will usually allow you to modify the code in smaller pieces, since there will be less coupling between the classes.

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  HRM628 VU Current GDB No. 1 Spring April 2012 Solution required Vuhelper 1 3,669 07-22-2020, 08:06 PM
Last Post: Johnnieaunders
  MGT501 Human Resource Management GDB No. 2 Solution 23rd January 2016 Vuhelper 0 1,813 01-23-2016, 06:07 PM
Last Post: Vuhelper
  MTH302 Business Mathematics & Statistics GDB Solution 23rd January 2016 Vuhelper 0 1,676 01-23-2016, 03:39 PM
Last Post: Vuhelper
  STA630 Research Method GDB 2 solution 23rd January 2016 Vuhelper 0 1,983 01-23-2016, 03:15 PM
Last Post: Vuhelper
  MGT211 Introduction To Business GDB No 1 Solution Ideas Fall 2014 Vuhelper 0 1,664 12-04-2014, 03:20 PM
Last Post: Vuhelper
  MGT101 Financial Accounting GDB Solution and Discussion December 2014 Vuhelper 0 2,858 12-03-2014, 09:05 PM
Last Post: Vuhelper
  MGT201 Financial Management GDB No. 01 Solution Fall 2014 Last date is 4th Dec 2014 Vuhelper 0 2,471 12-03-2014, 03:58 PM
Last Post: Vuhelper
  MGT520 International Business GDB No. 01 Solution and Discussion Fall 2014 viki 0 2,583 12-03-2014, 03:03 PM
Last Post: viki
  GDB No 1 MGT301 Principles of Marketing Solution and Discussion December Fall 2014 viki 0 2,503 12-03-2014, 02:45 PM
Last Post: viki
  MGT602 Entrepreneurship GDB No 1 Discussion and Solution Fall 2014 Vuhelper 0 2,474 12-02-2014, 10:36 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)