2

I'm extending an open source library written in Java released under the BSD License. That library has a class, let's call it Utils, that exposes a lot of static methods. The common use case is to import all the exposed methods in a static import, i.e.

import static org.acme.Utils.*;

Now, I'm creating new functions in my brand new open source library to extend the one from company acme. I'm wondering if is lecit to do

package org.myself;

import org.acme.Utils;

public class MyUtils extends Utils{
   ...
}

such that I can then use a single import

import static org.myself.MyUtils.*;

instead of

import static org.acme.Utils.*;
import static org.myself.MyUtils.*;
| improve this question | | | | |
  • You need to explain in what context you want to know whether you can do this. – curiousdannii Dec 16 '15 at 0:32
3

As far as the copyright/license is concerned, there is no difference in what namespace you put things, so this is fine.

Whether it is a good idea for your re-users to do this is more of a question for Programmers.se, and mainly comes down to whether it is more simple for your users to understand what's going on or to write one import fewer.

| improve this answer | | | | |
  • As a single data point, I hate libraries that do this. The amount of time it costs me to find the source of function y stands in no relation to the amount of time it costs me to type an additional import. – Martijn Dec 15 '15 at 11:53
  • I don't see why you should find the original class that implemented the function. Anyway, finding the class/interface that first implemented/defined a method is a straightworward task for all the modern IDEs – JeanValjean Dec 15 '15 at 12:27
  • @JeanValjean usually to read the source (part of the reason open source exists in the first place) when I'm not 100% sure of what the function does from the doc, or when I want to do something similar, and want to know how they did it. Different people have different opinions on this, which is fine. – Martijn Dec 15 '15 at 12:32
  • I guess that inheritance was meant to be used for inherithing functionalities to avoid code duplication. Flat-programming and code parcellization may lead to much higher confusion. – JeanValjean Dec 15 '15 at 13:43
2

The licence states that

Redistribution and use in source and binary forms are permitted provided [etc...]

It does not specify how you can and cannot use a specific class, function or library. All uses in "binary form" are the same to it. So yes, you could use a class from a BSD-licensed library like that, provided you comply with all of the license's terms.

| improve this answer | | | | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.