[Efficient programmer series] 2. Do not make robots-automate work

Source: Internet
Author: User

Open your computer every day. The first thing you need to do is to open the most common software: contact your friends, Open QQ, receive emails, open outlook, and listen to music, you opened the cool dog ...... But you don't want to be a robot. You repeatedly open these software every day, so you let them start up. Congratulations, you have the basic idea of not making robots. These simple and repetitive operations should be thrown to the computer. You need to devote valuable energy to other more valuable tasks. But have you ever wondered whether there are other things that can be thrown to your computer in your daily work so that you can get rid of mechanical operations? I would like to share my experience with you if you have relevant experience!

1. Use and definition of vs code segments

When using Visual Studio for programming, you will certainly like smart prompts and the code snippet function. For example, enter foreach:

Press tab and a fixed code segment is displayed:

In the editor, press Ctrl + k and CTRL + X to view the code segment definition, for example:

If you are using vs2008, you can find the code snippet manager in the menu:

It lists the built-in system code segments (I don't know why there are so many VB codes and so few C # codes. In fact, there is no big difference between VB and C #, and the code segment should also be equal .) :

I believe you should be very familiar with some common code snippet applications, such as prop, for, if, try. In fact, the code segment can also be defined by yourself. The following describes the Definition of the code segment.

Here we will introduce three tools (all of which are free of charge ):

(1) snippet Editor ()

This is an independent software and a green version. Run snippeteditor.exe after decompression. Let's take a look at its interface:

It automatically identifies the vs version installed on the current machine and then lists it in the upper left corner. Select a different version. The tree control on the left lists the code segment definitions of this version. Double-click the code snippet file to list the edited information in the editing area on the left. The path of the currently edited file is displayed in the status bar. To create a code segment, click "new" on the toolbar. The operations in the editing area are described as follows:

[Properties]

Title
Title, which must be entered. It is the name of the node displayed in the tree control.

Description
Description: A detailed explanation of the code segment. A prompt is displayed when the code segment is entered in.

Author
Author: write your name.

Shortcut
Enter the custom cut in the editor and press the tab key to enter the code segment.

Language
Programming Language. Optional values include HTML, JScript, Visual Basic, Visual C #, Visual J #, and XML.

Kind
Code segment type. Optional values: class declaration, member declaration, member body, and unspecified. Generally, you can select the default unspecified.

Help URL
Help URL. If yes, enter

[Code]

This area contains two parts: the text editing box and the parameter editing box. Enter the code template in the text editing box, position the cursor in the desired position, and click the "add" button on the toolbar below, in the text editing box, the software inserts a text in the format of "$ newliteral $". newliteral is the name of the template parameter and can be modified as needed. Attributes of template parameters are listed below:

ID
Template parameter name, which is unique in a template.

Defaults
The default value of this parameter, which is defined as the most common default value. You do not need to enter it when you enter it. For example, the string is defined as "" and the number is defined as 0.

Kind
Parameter type. Options include literal and object. Generally, you can select the default literal.

Type
The data type of the parameter, which is generally not required. If kind is set to object, it is better to enter the data type of the parameter.

Tooltip
Prompt information

Function
Generally, you do not need to enter the code generation method. In some special cases, for example, the switch code segment automatically lists enumerated values.

Editable
Editable?

Defining a code segment is not difficult. You can write your own code segment by referring to the default code segment in the system, which greatly improves the speed of input code. There are two special template constants: $ end $ and $ selected $. "$ End $" is used to define the position where the cursor locates after the code segment is entered in. "$ Selected $" is generally used for multi-line code. I analyzed the system code segment and felt that it was useless.

[References]

This region is used to record which DLL references to be added, but it does not automatically reference them. Here it is only a record.

[Imports]

This area is used to record the namespaces to be added to the code. It does not actually add namespaces.

After editing, click "save" to save the file and place it in the custom code segment folder. This folder is located in "% My Documents % \ Visual Studio 2010 \ code snippets \ Visual C # \ My code snippets" or "D: \ Program Files \ Microsoft Visual Studio 10.0 \ Vc # \ snippets \ 2052 \ My snippets ", find the path and programming language you have installed. Put the defined code snippet file in this folder, open vs, enter the shortcut key, and press tab to enter the code snippet you have defined.

(2) snippetdesignersetup-for vs2008.msi ()

This is the plug-in for vs2008. Unzip the package and install it. Create a new. snippet file with the suffix. Open it with vs2008 and call the installed plug-in to edit the code segment.

I prefer the first method, so here on the plug-in method is not detailed introduction, if you need to understand the detailed operation steps can refer to the http://snippetdesigner.codeplex.com/wikipage? Title = createfromscratch & referringtitle = documentation, in English.

(3) snippetdesigner-for vs2010.vsix ()

This is an extension for vs2010. It is different from vs2008 and does not need to be installed in the system. After double-clicking, it will be added to the extension for vs2010. After installation, a file template will be added to vs2010. You can directly create a snippet file in vs2010:

By the way, vs2010 has many extensions that can be downloaded online. Open the Extension Manager:

2. Compile snippet Compiler

Snippet Compiler () is a Windows-based small application that allows you to write, compile, and run code. This tool is useful if you have a small code segment and you do not want to create a complete Visual Studio. NET project (and all files attached to the project. It is a. NET Framework Supporting Multiple programming languages, multiple versions, multiple code files, and editing and compilation software with smart prompts. Below is its interface, if you need a detailed understanding, can refer to: http://www.cnblogs.com/conexpress/archive/2011/07/24/2115308.html

3. SQL smart prompts and code segments

As mentioned above, smart prompts and code segment input can be used in Vs, and SQL Server is another commonly used software. However, for so many years, SQL Server has never had the smart prompt function. It was not added to the field prompt function until SQL Server 2008. However, the difference between the field prompt function and vs smart prompt is 108,000. If you are still typing SQL code in a field, we strongly recommend that you use SQL prompt. It not only prompts fields, but also inserts code segments, and the code segments can be defined by themselves ...... I will not go into detail about its advantages here. After you master it, the efficiency will be improved by more than two times. Specific usage can refer to the http://www.cnblogs.com/conexpress/archive/2011/07/28/2120432.html #

4. Automatic Code Generation

As A. Net developer, there is a code generation tool at hand. The most famous code generation tool is codesmith, Which is powerful, easy to understand and easy to use. If you still don't use codesmith, hurry and study. Refer to terrylee's series of articles: http://terrylee.cnblogs.com/archive/2005/12/28/306254.aspx

Codesmith is a commercial software that requires money to purchase. If you respect copyright and do not want to pay for it, we recommend that you use another equally powerful free tool: mygeneration, Which is based entirely on the template engine for code generation, the function is not inferior to codesmith. You can go to the http://sourceforge.net/projects/mygeneration/ to download, you can also refer to the http://www.docin.com/p-83919214.html to learn how to use.

5. Script tools

Script tools such as au3, Ahk, Python, Ruby, and Windows Power Shell

Although all current tools have a good ide interface, sometimes script tools can bring higher efficiency. In addition, some functions are easily implemented in scripting languages, but it is troublesome to switch to other languages.

(1) au3

The full name of au3 is autoit3, which is a script language similar to VB. It was designed to automate work. The following describes its features:

Similar to VB, the syntax is easy to understand.

The editor has a smart prompt, which is more powerful than VB6. It is a bit like the code editor after vs2005.

You can easily operate the mouse and keyboard, or the recording process, similar to a macro.

You can set the shortcut keys, and combine Ctrl, ALT, shift, win, and other keys. Press the shortcut key to perform the corresponding operations.

It can be compiled into an EXE file for independent operation and supports win7.

There is a VB-like interface designer that can design applications with Windows interfaces.

Powerful extension libraries, easy operating systems, WIN32API, network, files, databases, registries, and INI files ......

For example, you can use # include in a C language to introduce extension files, code can be folded, or even # region folding similar to C.

The interface designer is similar to the VB6 designer and can insert Win32 controls.

It contains powerful extension libraries, involving files, GDI +, interfaces, networks, mathematics, processes, memory, databases, office, audio, video ...... For example:

As for its wide range of application scenarios, the most common is to execute a large number of repeated operations. After recording these operations with au3, you can replace manual execution, for example, installing software in batches, implementing game plug-ins, and hotkeys. You can even think of it as a more powerful language than VB6, because it can be compiled into an EXE file and can be used to design a program with a Windows interface without runtime support, copy to another machine to run, also supports win7. In addition, many of its operations can only be implemented using one method, such as downloading files from the network using inetget (URL, filepath), opening the file or executing the program run (filepath ), click the mouse mouseclick (Key, x, y), move the mouse mousemove (x, y), send the send key (key), close the form winclose (title )...... The most common method is hotkeyset (hotkey, method), which is to register the hotkey. For example, hotkeyset ("# Q", "mymethod") means to register the win + q key to run the mymethod method. When you press the Windows key and the Q key, mymethod is called.

The detailed usage is not described here. If you need it, you can learn it at the following URL:

Huajun Software Park-au3 Chinese edition (recommended, containing Chinese help documentation): http://www.onlinedown.net/soft/54314.htm#down

Autoit Chinese Forum: http://www.autoit.net.cn/

Autoit Official Website: http://www.autoitscript.com/site/autoit/

New au3 Tutorial: http://wenku.baidu.com/view/b0915d1fb7360b4c2e3f6460.html

Let's autoit ebook: http://wenku.baidu.com/view/3418a0cfa1c7aa00b52acb6d.html

Another scripting language similar to au3 is named Ahk, which is called autohotkey. It is said that it was developed by some people separated from the au3 development team. Its functions are similar to au3, but its syntax is similar to C. If necessary, you can go to the following website for details:

Ahk download: http://www.onlinedown.net/soft/39219.htm

Niche software Ahk classification: http://www.appinn.com/category/autohotkey

Ahk Chinese Forum: http://ahk.5d6d.com/

Egg-Ahk fast food restaurant (entry): http://jandan.net/2007/10/21/ahk-fast-food-restaurant-advance-notice.html

(2) Windows powershell

This is Microsoft's scripting language. Previously, Microsoft only paid attention to the interface and lacked the command line. Especially for system administrators, some operations are faster with command lines than interfaces. The shell commands in UNIX and Linux are very powerful. Microsoft decided to develop a powerful shell command on its own Windows system. Here is the introduction of powershell:

Powershell is an object-based shell built on.. NET Framework, currently supported. net Framework 2.0. it can run on Windows XP SP2, Windows Vista, Windows 7, and Windows 2003. supports existing windows management models such as WMI, COM, ADO, and ADSI.

Powershell support is also added in SQL Server, for example:

It is also very easy to use powershell. Just like cmd, you can enter powershell in the running process. For example, you can also enter the CMD command.

If you are not familiar with powershell commands, you can consider using powershellanalyzer, which also has the smart prompt function. Http://www.powershellanalyzer.com/

The following example shows the convenience of powershell. For example, to recruit a group of new employees, you need to create a folder for each of them on the server. What most people will think of is: Create a folder, rename it, and then create a new name. A few people can accept it, but if there are dozens of people, it may be annoying. If powershell is used, the problem can be easily solved. First, enter the name of each person in a text file. Each name occupies one row. Then open powershell and enter the following command. Is it very convenient.

Find such a powershell series in the garden, you can refer to: http://www.cnblogs.com/brooks-dotnet/tag/PowerShellV2/

(3) Other scripting languages

Through the above introduction, do you think that sometimes the script language is more convenient. Other popular scripting languages such as Python and Ruby can be learned based on your preferences.

6. Automated testing tools

During software development, you must perform repeated tests. However, sometimes testing only involves repeated mouse and keyboard operations. It is a waste of manpower to spend a lot of time doing this manually. Selenium is a powerful automated testing tool.

Let's take a look at its introduction:

Selenium is also a tool for Web application testing. The selenium test runs directly in the browser, just as the real user is operating. Supported browsers include IE, Mozilla, and Firefox. The main features of this tool include testing the compatibility with browsers-testing your applications to see if they can work well on different browsers and operating systems. Test System functions-create a decline test to test the software functions and user requirements. Supports automatic recording and automatic generation. . Net, Java, Perl, and other testing scripts in different languages. Selenium is an acceptance test tool specially written by thoughtworks for Web applications.

If you want to get rid of the step-by-step mechanical operation and wait for the test process of the final verification result, you should study selenium. The following are some references:

Selenium kitchen series: http://www.cnblogs.com/hyddd/archive/2009/05/30/1492536.html

Automated Web Testing with selenium: http://www.oschina.net/question/12_15377

ASP. NET unit test tool Selenium: http://www.cnblogs.com/ljzforever/archive/2009/05/20/1467801.html

Selenium ide practice: http://qiuguangchun.blog.163.com/blog/static/126221212010213114517993/

Selenium Chinese Forum: http://seleniumcn.cn/

This article is written here. It involves a lot of things and cannot be described in detail. It provides you with some reference materials. If you need it, you can learn it in detail.

If you have any good methods to avoid repeated operations and improve work efficiency, we hope to share them with you so that you can have more time to do more meaningful things. Thank you!

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.