Suppose I use a open source framework in my project and I would not contribute (submit changes) to that framework, and the current version is stable, should we keep the framework unchanged when possible?
for example, if I found a function in a class of framework does not fulfill my requirements:
public class Fruit{
public float calculatePrice(){
return weight*1.2;
}
}
I would wrap it to add my requirements:
public class MyFruit{
Fruit fruit;
public float calculatePrice(){
return fruit.calculatePrice()*myConstant;
}
}
instead of modify Fruit directly, and for another example, if I need to use a protected property in the class (e.g.:locale):
public class Fruit{
protected String locale;
}
I would extend it to access the locale
public class MyFruit{
public void checkLocale(){
if(locale.equals("abc")){
}
}
}
instead of changing locale into public.
I think the motivations behind it are:
The resources of the frameworks (e.g.:tutorials, behaviour ,bugs,issues) are based on the original version of the framework, when we change the framework directly, the resources may not be applicable to my modified framework anymore, or we may not be able to use the resource directly (e.g.:copy and paste online examples)
It is easier to upgrade the framework when the framework keeps the original look
If we modify codes in framework, it may introduce bugs in the framework, and debugging frameworks is more difficult than debugging my custom codes.
Keeping the frameworks in original version allows us to add other extensions for the frameworks easily because most extensions are worked based on the original version
It is more difficult to ask for help if we use a custom modified framework because you may need to post and explain the modified parts of the framework
When problem occurs, if we just use the original version, it is faster and easier for volunteers to setup the environment, then reproduce and find out the problem, because they can just download the framework directly and then add my additional codes.
is it true that we should not modify codes in frameworks directly when possible? And is this attitude correct?