Tool class for improving work efficiency"

Source: Internet
Author: User

Note: The title "class" does not necessarily refer to object-oriented classes, but generally refers to code files with specific functions)
I have a habit of writing code. At the beginning of a project, I will first create a "tool code" Directory, which will contain multiple tool "classes ", such as file operations, String Conversion, dump file output windows), registry operation windows), Timer service ...... and so on. Don't underestimate these tool classes or methods. For a simple example, let's take the conversion of ANSI and UNICODE characters as an example. File Operations are common to many projects. Why not encapsulate them into a tool "class" and add them to each project for use at any time, in short, we can encapsulate code implementations that we think can provide certain functions into tool classes for other projects to call. You can think of it as a Swiss Army knife. In the beginning, there may be only knives and starters, it's easy to use it. However, please note that if you use an inferior military knife, the cutting blade will break down and the scissors will not be able to cut, and you will surely complain about it. The same is true for writing tools. These tools must be of high quality, stable, and robust. It is best to use cross-platform tools. Next, let's talk about some of my experience in Writing Tool classes:
Experience 1: do not duplicate the wheel and ask others to write it.Note that it does not mean that those searched on the Internet are of high quality. I like to search for code files containing the util keyword in the famous open-source code or some leaked famous commercial code, which is spectacular and piled up in a pile, the following is my choice of these tools. Anyway, I still believe in high-quality open-source code and commercial software, which is generally used. No adverse reactions have been made yet.Experience 2: cross-platform platforms as far as possibleAfter all, we now pay more attention to cross-platform development. I like to use STL, boost, or posix interfaces. For systems that depend on the system API, you can add the system identification condition to compile the code;Experience 3: Method interface parameters and return values must be commonIn addition to logical design, the C ++ template is a good thing;Experience 4: You must perform unit tests on your own tool classes.You think about it. Your tool class may provide the entire project, other projects, to others, the entire project team, or more people. Do you allow it to go wrong?Experience 5: accumulated, Accumulate a number of functional methods in your daily work and study, and gradually expand your tool Library; when you have such a military knife, 650) this. width = 650; "src = ".. /attachment/201204/195815424 .jpg" border = "0" alt = ""/> you are cool. Appendix: Part of my tool https://github.com/yaocoder/utils

This article from "forever friends" blog, please be sure to keep this source http://yaocoder.blog.51cto.com/2668309/846106

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.