简体   繁体   English

库、存储库、包和文件夹之间有什么区别?

[英]What is the difference between a library, respository, package and folder?

I was wondering whether there is any real technical difference between these things, or whether the difference is only semantic?我想知道这些东西之间是否存在真正的技术差异,或者差异是否只是语义? It seems to me that they are all just places for storing other files.在我看来,它们都只是存储其他文件的地方。

Background: I am learning Java背景:我正在学习Java

Best wishes,最好的祝愿,

Patrick帕特里克

On the differences between a library, repository, package and folder:关于库、存储库、包和文件夹之间的差异:

A library is a set of functionality that is packaged together for easy consumption.库是一组打包在一起以便于使用的功能。 There is no big difference between a library and a framework or an engine, they all fulfill similar functionalities and the differences are subtle semantics.库和框架或引擎之间没有太大区别,它们都实现了相似的功能,区别在于细微的语义。

Libraries are usually packaged -- either as JAR or as a Maven artifact, so that they can be easily used by another end user.库通常被打包——作为 JAR 或作为 Maven 工件,以便其他最终用户可以轻松使用它们。

A package in Java in another name for namespace .package在Java中的另一个名字namespace Packages fulfill the role of disambiguating classes and organizing them.包起到了消除类歧义和组织它们的作用。 Yes, when you program in your IDE they are mapped 1:1 to folders in the file system - but that is just an implementation detail.是的,当您在 IDE 中编程时,它们会 1:1 映射到文件系统中的文件夹 - 但这只是一个实现细节。 In C# for example, namespaces do not map 1:1 to folders.例如,在 C# 中,命名空间不会 1:1 映射到文件夹。

Repositories again are ambiguous.存储库再次模棱两可。 A repository is a location where something is stored.存储库是存储某些内容的位置。 In terms of source code, this is often usually a version controlled repository like a git repo, mercurial repo or svn repo.就源代码而言,这通常是一个版本控制的存储库,如 git repo、mercurial repo 或 svn repo。

But other types of repositories exist.但是存在其他类型的存储库。 A Maven repository for example hosts machen artifacts - which can be used as a dependency in your POM.例如,Maven 存储库托管 machen 工件 - 它可以用作 POM 中的依赖项。

Overall, you'll find the word repository in many places.总的来说,您会在很多地方找到词库。 Its the generic term for a place where something is stored.它是存放东西的地方的通用术语。 This can be a UserRepository in your own code, for example.例如,这可以是您自己代码中的UserRepository Its not uncommon to see XXXRepository as class name.XXXRepository视为类名的情况并不少见。

Folders on file systems are just a means to an end, just like Key-Value stores and SQL databases.文件系统上的文件夹只是达到目的的一种手段,就像键值存储和 SQL 数据库一样。 They aren't the organizational units Java devs usually are concerned with, except when actually doing file I/O.它们不是 Java 开发人员通常关心的组织单位,除非在实际进行文件 I/O 时。

What is often referred to as a library is generally a set of functionalities that you can import into your software with an import statement, like so:通常所说的library通常是一组功能,您可以使用导入语句将其导入到您的软件中,如下所示:

import coolLibrary

You do this in order to not have to implement that functionality yourself.您这样做是为了不必自己实现该功能。 There are different terms in use for this in different contexts/programming languages, by the way.顺便说一下,在不同的上下文/编程语言中使用不同的术语。

A repository is a place where code and related resources are stored. repository是存储代码和相关资源的地方。 This can be on your local file system or online.这可以在您的本地文件系统上或在线。 What separates this from a folder is that repositories, functionality for which is provided by tools like git , usually come with some archiving and version control tools.将它与文件夹分开的是存储库,其功能由git工具提供,通常带有一些存档和版本控制工具。

A package is simply a group of related classes in Java. package只是 Java 中一组相关的类。 They're used to organize projects.它们用于组织项目。 The IDE of your choice will allow you to make use of this.您选择的 IDE 将允许您使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM