Sponsored Links


Results 1 to 2 of 2

Thread: CS304 Object Oriented Programming GDB Solution Spring Semester July 2013

  1. #1
    Administrator Vuhelper's Avatar
    Join Date
    Apr 2011
    Posts
    9,578

    18 CS304 Object Oriented Programming GDB Solution Spring Semester July 2013

    Sponsored Links1






    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.

    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

    Sponsored Links

    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.

  2. #2
    Administrator Vuhelper's Avatar
    Join Date
    Apr 2011
    Posts
    9,578
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 06-18-2013, 09:44 PM
  2. Replies: 0
    Last Post: 05-17-2013, 04:29 PM
  3. Replies: 1
    Last Post: 04-27-2013, 04:15 PM
  4. Replies: 0
    Last Post: 02-11-2013, 03:43 PM
  5. Replies: 0
    Last Post: 02-04-2013, 04:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
-: Vuhelp Disclaimer :-
None of the files shown here are hosted or transmitted by this server. The links are provided solely by this site's users. The administrator's or staff of Vuhelp.net cannot be held responsible for what its users post, or any other actions of its users. You may not use this site to distribute or download any material when you do not have the legal rights to do so. It is your own responsibility to adhere to these terms. If you have any doubts about legality of content or you have any suspicions, feel free to contact us.
Online Education | JhelumSoft