Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I default the environment for someone using my library?

I have been having this debate with a friend where i have a library (its python but I didn't include that as a tag as the question is applicable to any language) that has a few dependencies. The debate is whether to provide a default environment in the initialization or force the user of the code to explicitly set one.

My opinion is to force the user as its explicit and will avoid confusion and make it clear what they are pointing to.

My friend this is safer and more convenient to default to an environment and let the user override if he wants to.

Thoughts ? Are there any good references or examples / patterns in popular libraries that support either of our arguments? also, any popular blogs or articles that discuss this API design point?

like image 887
leora Avatar asked Mar 05 '12 01:03

leora


People also ask

Can you share virtual environment Python?

If you want to share your virtualenv with a lab partner, you just need to allow read-execute access to the Envs directory and any files below that. All that's stored in there is the software you installed (e.g., with pip ), so it's OK to open up this directory for others to access.

Should I use VENV or virtualenv?

These are almost completely interchangeable, the difference being that virtualenv supports older python versions and has a few more minor unique features, while venv is in the standard library.

Why do I need a Python virtual environment?

virtualenv is used to manage Python packages for different projects. Using virtualenv allows you to avoid installing Python packages globally which could break system tools or other projects. You can install virtualenv using pip.

What does a virtual environment do?

A virtual environment is simply a tool that separates the dependencies of different projects by creating a separate isolated environment for each project. These are simply the directories so that unlimited virtual environments can be created. This is one of the popular tools used by most of the Python developers.


1 Answers

I don't have any references, but here are my thoughts as a potential user of said library.

I think it's good to have a default configuration available to allow developers to quickly evaluate the library. I don't want to have to go through a bunch of configuration just to see if the library will do what I need. Once I'm happy that the library will do what i need it to do, then I'm happy to configure it the way I want.

A good example is Microsoft's ASP.Net MVC framework. When you create a new MVC project it hooks in a default authentication and membership provider, which allows the developer to very quickly get a functioning application up and running. It is also easy to configure different providers to be used if the default one's don't meet the requirements of the application in question.

As a slightly different example, Atlassian Confluence is wiki software which supports many different back-end databases. Atlassian could have chosen to have no default DB configuration, but instead Confluence ships with a default, simple, file-based database to allow users to evaluate the software. For production installations you can then hook up to Oracle, SQL Server, mySQL or whatever else you like.

There may be instances where a default configuratino for a library doesn't really make sense, but I think that would be a special case, rather than a general rule.

like image 143
Andrew Cooper Avatar answered Sep 28 '22 06:09

Andrew Cooper