开发者

Snippets vs. Frameworks

I've been finding that a lot of libraries and frameworks can seem a bit too unwieldy and hard to 开发者_JS百科maintain. I like the way that FlashGameDojo approaches this problem by promoting the use of snippets that can be dropped into code as needed. Obviously, there are drawbacks to this approach too like trying to keep track of disparate pieces of code.

I'm wondering if there is some kind of agreed upon approach to managing this type of code library. How do you keep each snippet fresh, find the ones you need for a project, etc. If there is no "best practice" for this, perhaps you can share some of your experiences.

Thanks!


Frameworks tend to have a cost too. While they can abstract away lots of repetitive tasks, they have a learning curve. The good thing here is that the documentation is usually very good. I shall cite CakePHP and Symfony as my examples.

Snippets have always been helpful, but sooner or later, it makes the codebase patchy. It takes brainpower to understand the different snippets of code too. The code came from different sources, so there won't be once central source of information.

For me, the biggest factor in picking between frameworks and snippets is my skill, and the skill of the other folks in the team. Communication is the key.

Teams where developers are okay with reading documentation should stick to frameworks. I've been in such teams, and developers there tend to play it safe. Such a team tends to breeze through standardized tasks quickly, leveraging the API of the framework. However, when customization is required (because clients like making changes) they tend to go slower. Advantages of such a team is that each person can potentially fill in for another. The biggest disadvantage though, is that the lack of specialization makes people less attached to their work.

Teams where developers are okay with reading the code itself should go with snippets. I've also been in teams like that, and developers there tend to know a little more. They are really fast in customization, but they get bogged down when doing repetitive tasks. Each developer has an identity that they tend to care about. It's highly likely that they are proud of their work, and will do everything to "look cool" in front of their peers. The biggest disadvantage though, is that some developers can be pompous jerks.


My first preference would be to keep a single or multiple projects that contain all of the code you want to re-use. It makes sense to break the code out by folders/namespaces.

Then you can include this project into other projects and use the code directly without having to copy/paste.

Advantages: you immediately see if code is broken (it won't compile), you immediately see if a function/method is not specific enough for your current needs. Then you can decide if you need to update or extend the code.

Preference two would be to use an online snippet manager (since it's accessible from anywhere). You will loose the ability to fix something only in one spot since you will be copying/pasting this code.

An example of an online snippet manager is http://www.int64.io - you can organize snippets into "boards" (like folders), you can tag them using pre-defined tags or your own. You will be able to search through the snippets in the near future.

There are other snippet managers as well, like GitHub Gist, jsfiddle, codepen, etc.

Disclaimer: I'm the owner of http://www.int64.io


There is GitHubGist where you can keep and organize your snippets. I like the GistBoxApp that integrates with it and has a nicer (and more organized) UI.

I've tried to keep things in Evernote, too, but because it doesn't keep things nicely formatted, I quickly gave up on that. (And it was a hard thing to give up on - I have 15K notes in Evernote for everything in my world already.)

The best thing about GistBoxApp is that I can keep snippets that either get me started with files or have my quirky little functions that I feel emotionally connected to.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜