Recommendations for Libraries and Namespaces

What are the best methods for creating libraries?

I’ve been developing for almost 10 years and building my library as I work.

The way I'm currently installing it follows this pattern:

MYLIB.SomeUtility.utilFunc(); new MYLIB.SomeProject.ProjectClass(); //project specific classes //Sometimes I have classes that extends external libraries, //like JQuery, or KinteticJS objects new MYLIB.SomeExternalLibrary.ExternalLibraryClass(); 

My library has files in css / js / php / as3, but in order to avoid confusion, I divided them each into my own separate library, for example: MYLIB_JS , etc.

In the JS library, for example, there are classes WebGL, Canvas, JQuery, Regular JS (if we call them).

As you can see this is a bit of a mess, so I'm trying to find out what others are doing, so I made a list of quick questions:

HOW TO MANAGE:

  • Different languages?
  • Different platforms (is that what he called? WebGL, Canvas, JQuery, etc.)?
  • Various projects
  • External Libraries and Dependencies

As I studied, I was thinking about Google, and I asked myself how they handle their Google Maps Library, for example, they should have a common Google library with a bunch of useful features, but there are also files for Google Maps only and they have a backend maybe a php and js interface, so how is all this managed?

Thanks for your help: D

PS. I use git for version control

+7
source share
2 answers

I write this because you wanted to know what others are doing. That's what I'm doing. I would not argue that this is "best practice."

1) When the years pass, I realized that I remember my libraries through projects. Because projects were urgent tasks, not libraries.

2) We no longer program in the same language. The trend towards cloud servers and applications has to be addressed with multiple platforms in multiple languages.

3) I saw that every time I create an application, if it gets better, the platform codes begin to reflect the coding language and functional similarity (as far as possible) to the structural similarity.

4) When you look back at a project, it should be ready for re-work, or any compilation should be possible without redefining directory structures, etc. So, if you use the code of a specific platform, you must do this in accordance with the platform coding requirements, for example, it is almost absurd to force Android code to be stored in a different directory structure and then overshadow.

So how do I do this:

The main entry point is always project . Under this, I am sharing on platforms. Underneath this, I am sharing on platform tools and frameworks.

ie:

  TheGreatWebProject |------->Server | |------>Php | | |------>aScaryPhpFrameWork | | |------>myPhpLibraries | | |-----------> myPhpLib1 | | |-----------> myPhpLib2 | |------>DotNet | |------>aScaryDotNetFrameWork | |------>myDotNetLibraries | |-----------> DotNetOutputs | |-----------> myDotNetLib | |-----------> myDotNetSources | | |------->Client | |------>Html | | | |------>Css | | | |------>JavaScript | | |-----------> aScaryJsLibrary | | |-----------> myJsLib1 | | |-----------> myJsLib2 | | | |------>ActionScript3 | |-----------> aScaryAs3Library | |-----------> swfOutputs | |-----------> myClient1.fla | |-----------> myClient2.fla | |-----------> myAs3AppSrc(in package | management file structure) | | |------->Extras |------>Locales |------>Documents |------>Images |------>Audio |------>Video |------>Other 

For each subsection, the subcategories will reflect the implementation dependency, ide, and platform. Therefore there is no great cure that fits all ...


Now, finally, I have a catalog: projects, and under it I have catalogs of years, and in each year I have projects that I did this year ...

Hope this helps.

+8
source

When it comes to project structure, my advice is:

1) Alignment with your structure is more important than the exact structure you use.

2) Do not reinvent the wheel - using the structure created by the existing frame makes sense

Regarding your specific questions:

1) Different languages

I assume you mean human languages, as we are talking about javascript here. I think internationalization should be separate from the structure of your code. There are many existing libraries that can handle it, and it has been discussed in detail in this question: https://stackoverflow.com/questions/9640630/javascript-i18n-internationalization-frameworks-libraries-for-client-side-use

2) Various platforms

I like the package code vertically, not horizontally. In other words, I think that the code should be packaged by domain, and not by technical level. This is a good explanation for this in Domain Driven Development.

3) Various projects

I would suggest that this is usually handled implicitly by the fact that the code is in different source trees. However, having a root namespace probably solves this and is a good practice since it has the smallest global footprint.

4) External libraries

I would look at CommonJS - this convention for loading javascript libraries and is becoming the ubiquitous standard. http://www.commonjs.org/

+2
source

All Articles