In: Computer Science
b. Consider the DataSource class in Case Study 2. Explain how inheritance is intended to be used with this class. Does this represent a good use of inheritance? Explain your answer.
a)Identify common reuse practices that are employed in the requirements, design and implementation activities of a project. Explain under what circumstances each practice is / can be employed.
Reuse practices that are employed in following activities is explained below:
1.Reuse for Requirements: There are some requirements which can be reused. For the company, a list of those common requirements can be made. Whenever a new project gets started, have a look at that list of requirements. This process is called as creating the Standard Requirement Asset for the company.
Because there are some requirements which are necessary to implement for each project like security of the system, reliability of the system. So, by making a prior list, it helps in doing faster work.
Each time a new project is received, the prebuild list gives us a set of requirements and attention is paid to only other requirements which are specific to this project. It saves lots of time and labour.
Types of Reuse:
>Reuse by copy
>Reuse by linking
>Reuse by inheritance
Here a standard library is made. From this library requirements can be reused in any project. It is important to note that when the standard library is going to update then all the subsequent project should reflect the updated library of requirements.
See the attached image from diagram:
2.Reuse for Design
Reuse of design and components i.e. patterns. In this at outer level following is done:
>Application Framework is reused. Here structure of classes at the system level is copied.
>Legacy system overlapping is done in order to make an interface to older system.
>Service oriented system: If there is a use of third-party software as a component of the project, then it is copied from there. It is called as service-oriented system.
In this at inner level following is done:
>Design Patterns are reused. Design Pattern gives us a solution to common problem. So, whenever the same problem arises. the design pattern is reused among several software development.
>Models used in the project can be reused.
>Component based development employee the reuse concept.
>Object oriented design is reused.
3.Reuse for Implementation
Reuse of classes and methods i.e. code. Here following is reused:
>Program Libraries and API are reused in several project development. Library store standard methods or function, which are meant to be reused.
>Code generator helps in making code faster by reuse concept. There is several IDE's which reuse code. These IDE automatically generate code for the common application. Programmer has to write only specific code related to the project going to be made.
>Open close principal employ reuse because it ensures that software is open for extension but close for modification.
>Dependency Module should not have dependency on one another.
>Interface segregation should be present there.
>Single Responsibility One class do one task.
>Object oriented programming for reuse. Class, encapsulation, interfaces, component, modules, packages, inheritance, all these concept support reuse of code. It avoids duplicity in code.
==============================================================================================================================================================================
b. Consider the Data Source class in Case Study 2. Explain how inheritance is intended to be used with this class. Does this represent a good use of inheritance? Explain your answer.
Point to be Noted Here Data source class is not provided by you in the question in Case Study 2. Question is incomplete. I will explain in general.
Use of Inheritance:
Inheritance is used in the case when we want to create a class which require some methods of a predefined class. Then don’t write the whole code again. There is a concept inheritance, in this, all the previous code is directly inherited in the new class. And new methods of the new class are defined in the new class.
Previous class is called as base class and new class is called as derived class.
Inheritance is used in two cases;
1. When we want to reuse base class.
2. When we want to add some more functionality in the base class.
Point to be noted: Now check in case study 2, whether there is a concept of reuse or new functionality/method is added to the base class.
Good use of Inheritance:
If one of the cases of inheritance is present in case study 2 then it is the good example of inheritance. Means
derived class has some new method in it.
For Example:
class Base { void method() { } } class Derived extends Base { void method1() { } } public class main { Derived d = new derived(); s.method(); s.method1(); }
Explanation:
In this extend keyword is used for inheritance. Here derived class is using method of base class.So, it is good example of inheritance.
So, check these point in your question. It is very easy to find out.
==============================================================================================================================================================================