Structuring Interface files and naming them
I am working on a JavaScript project and I need an interface support. I have it already implemented and it helps a lot. However, I am not sure where I would put开发者_如何学Python my Interface objects. My file structure looks like:
App\SomeComponent.js
App\widget\SomeWidget.js
App\thing\SomeThing.js
I am wondering where I should put my interface files and how to name them. For example, I could make a ISomeWidget.js
and put it under widget
folder. I could also put a global interface for all widgets such as IWidget.js
under widget
folder. But do you think that naming and structuring makes sense? I personally don't like the I-prefix.
Unlike server side code file where good practice is to have one type per file, javascript files should really be an amalgamation of all your code. This is because they are directly consumed by the client. Merging techniques can be used if you want to keep your logical problem domains separate during development. Remember, its more efficient for the client to have to download fewer resources.
If your resource files are merged dynamically or as part of a deployment process then I would logically structure your files as per problem scope, e.g. /scripts/shared, /scripts/navigation etc.
精彩评论