开发者

What are your Personal Templates?

After having written thousands and thousands of lines of code in a given language, you end up having your own personal templates. This is, code structures that you repeatedly use to address the same problems, or express the same ideas.

Most of these "personal templates" are polished versions of simple solutions, cleaner or easier ways to do things, that you discover over time.

I was thinking about my own personal templates today, and I grew curious as to what other people's practices were. What do you say, fellow Stack Overflow-ers, we share war stories?

For example, in C, whenever I have to fi开发者_运维技巧nd an empty slot in a fixed array of slots for whatevers, I always use these two lines:

for (i = found = 0; i < MAX_WHATEVER; i++)
    if ( (found = isEmpty(array[i])) ) break;

Then I can test the value of found, and use the index i.

What "personal templates" do you guys have?


My personal template is: when I answer to a non-question I give a non-answer. Like this. :)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜