My experience in Delphi Development

Source: Internet
Author: User
Tags ftp file testcomplete axosoft

--------
Development Environment
--------

Delphi 7 is a classic version. We recommend that you install Delphi 7 for software development under win2000/XP, and Delphi 2007 for software development under Vista. After Delphi 7 is installed, you should install Delphi 7 update Pack 1 immediately. If Delphi 2007 is installed, try to install the latest version. To improve development efficiency, you must first sharpen the tool to better handle the subsequent development work, we need to install some useful development auxiliary tools (Delphi names these plug-ins as experts ). First, we recommend delforexp.Source codeThe formatting tool is integrated in IDE, which is quite convenient to use. Even if I writeCodeThe style is very good, but it is still inevitable to read the messy code written by some people. In this case, delforexp can be used, and the code will look more pleasing to the eye in one second. Gexperts was once a well-known tool, but it is not updated yet. There are several functions worth using, such as grep search, replace components, and code proofreader. We strongly recommend that you install the cnpack ide expert package. Believe me, it will make your Delphi easier to use. Delphi 7 does not support refactoring. Therefore, I suggest installing Castalia. Some functions of this tool are still very good. Coderush has always been the most powerful tool in Delphi, but since it is easy to conflict with other tools after installation, people have to endure. We recommend that you install the IDE acceleration tool Delphi speedup in Delphi 7. The principle is that the RTL function is replaced by a function with higher execution efficiency from the fastcode project before Delphi starts. Modelmaker code explorer adds some functions for Delphi to facilitate code reconstruction and is worth installing and using.

Start Delphi 7 for the first time, disable Delphi direct in the settings to prevent Delphi from accessing the Borland server, and check the show compiler SS option to compileProgramYou can see the compilation progress, set the options of the installed experts, adjust the layout of the Delphi Form according to your preferences, and save it as the default layout. Close the project and set the default project options. Then you can install the control package. If you want to configure the development environment in the project team, the installation may be troublesome because many controls are required, it is recommended that an experienced developer pre-compile those bulk controls into an installer for other group members to install.

--------
Software Design
--------

When organizing your own ideas, you can use personalbrain to draw a mind map. This is an activity that expands your mind and inspires your thoughts, and records all your thoughts, in addition, you can find internal links and more problems during the sorting process, and consider them in the subsequent design. In addition to Visio, edraw soft diagrammer is recommended. Enterprise impact ect is a good choice for UML design. Modelmaker adds UML support for Delphi, which can maintain two-way synchronization between design and Code. It is a very good tool.

As a Delphi product designer, you should have a broad vision and be familiar with it. net, Java excellent framework design, familiar with the source code of the Delphi class library, there is always something we can learn from, based on the actual situation and specific needs of the company, you can choose to develop products in order to make high-quality products.

--------
Software Development
--------

Data structure is the basis of software development. Before developing a project, you must prepare container classes such as tstack, thashtable, tqueue, tcollection, TMAP, tbag, tset, and tassociation, then, in future development, select the appropriate data structure as needed to avoid direct use of pointers and tlist. If necessary, you can inherit and implement common classes such as tstream and Tregistry, that is, make a package. This leaves an interface that can be added to the extension at any time for future development.

DGL (the Delphi generic Library) can also be found online to add generic support for Delphi. In fact, it can also be called a template library, but this library is used only once, no one has ever used it online, so it remains to be verified whether it is reliable. Speaking of the template library, I also think of a deex, which is a pre-processor that allows you to use similar STL syntaxes. It also has a built-in DTL (Delphi Template Library) Library.

With regard to AOP, Delphi is totally different from Java or. compared with net, the technology that can be used can only be implemented by dynamic proxies or hooks. Although frameworks such as meaop have also emerged, I still recommend that you design them to meet the requirements of such AOP, alternatively, you can consider using pre-compilation preprocessing during dailybuild (for example, designing it as {logaction} is similar. NET attributes to modify specific methods, of course, the pre-processor must be developed by itself ).

All development-related files should be managed, not just code management. In the beginning, directory planning should be completed. In particular, code should be separated from the resources required for running, generally, it can be divided into four categories: Doc, SRC, res, and Misc. Doc stores all the relevant documents and creates a specific classification directory. SRC stores the files required for compilation, such as source code and help source files; Res stores various resource files required to create installation packages and release software, such as comparison files and web pages. This will prepare for the subsequent dailybuild.

Delphi does not have the concept of package and namespace. Therefore, it can only use physical division on directories to replace logical division and place units of the same nature to the same directory, divide more sub-directories to store units as needed.

The interface of the program has better all the new naming rules, avoiding Code such as label1.txt: = 'abc' in the code. Developers should be familiar with the system functions provided by Delphi and should not implement the functions provided by Delphi by themselves, second, the code you write has not been fully tested, and it is very likely that the Code is not properly handled. We do not advocate repeated inventions, especially in formal development. The principles of object-oriented design should be grasped during development: single responsibility, open and closed, Lee's replacement, dependency inversion, interface isolation, high cohesion and low coupling. Code is the best annotation, and variable naming expresses its own meaning as much as possible. The best annotation is that the code can be easily understood without annotations, and only comments are added as needed. Developers should regard their code as a product for others' use. Do not arbitrarily declare the method as a public method, but only provide the method required by others, each public method should be annotated with its function. Any warnings or prompts during program compilation should be taken seriously, and every warning or prompt should be eliminated to avoid potential risks in some code.

Experienced programmers will fully consider the variable situation when completing specific functions, extract these places, define them as method parameters or read them from the configuration file, so that even if the demand changes, it can also be easily handled. To write a program that is easy to maintain, efforts should be made on software configuration and program dynamics. A special mention of program dynamics is given. Currently, many online games are developed, and the script engine Lua is generally used to implement some logic. This makes it easier to adjust the code later in the development stage, later Modification on the server does not require restarting the program. Of course, you can consider using the script engine in a general project or product. Of course, you may not have to use Lua, but you may have many other options. For example: delphiwebscript, remobjects Pascal script, Automa atpascal scripter, fastscript, innerfuse Pascal script. If there are higher requirements, you can also consider using Coco/R (parserbuilder) to implement your own syntax parser.

Developers often encounter problems that they cannot solve. You need to know what problems you encounter may have been encountered and solved by others. Therefore, it is usually the best choice to ask others or ask Google. It is inefficient to ask questions on the forum. Local knowledge bases can also be used, such as the offline database codefinder of www.delphi3000.com and the offline database of monopoly,

--------
Control Development
--------

Controls are divided into non-visual controls and visual controls. non-visual controls are actually not much different from general classes. You only need to publish the attribute to be published as published, if necessary, you can design and register your own property editor.

Development controls also include professional development tools Eagle CDK and eagle react. You can not only easily create classes, but also test controls during runtime, which can easily modify attributes, real-time display of results greatly improves development efficiency.

--------
Software cracking
--------

More and more developers begin to use RSA for registration encryption.Algorithm, The effect is not bad, although still cannot prevent being cracked, but at least there will be no (memory) Registration machine. Adding shells to the software is not a pop-up suit. For experienced hackers, you can use ollydbg to dump the memory in a matter of minutes (use process explorer to kill the thread blocking the debugging tool ), the next step is to use import reconstructor to fix IAT, and then use Lord PE to optimize the exe.

Dede allows the attacker to view the resources and events in the program. It can perform static analysis or dynamic debugging on the analyzed addresses in the ollydbg.

Dede can also be used to crack the Delphi control, but we have a better choice, that is, dcucu and dcu2pas, which can be decompiled into assembly code directly, by statically analyzing the strings and calling APIs, it is really easy to crack.

Only by knowing ourselves and ourselves can we be targeted. Anti-cracking is to minimize the cost of protection, so that the attacker can make great efforts to crack the attack.

--------
Version Control
--------

The most popular versions of version control are VSS, CVS, and SVN. I prefer SVN, but since there is no convenient connection to SVN plug-ins under Delphi, delphi + VSS is the most convenient version control option. Vssconnexion is a plug-in dedicated to adding VSS support for Delphi, which indeed brings great convenience to developers. Delphi + tortoisecvs and Delphi + tortoisesvn are also good choices. The biggest disadvantage of VSS is that it can only be used in the internal network. Apart from allowing remote access through VPN, we can also use dynamsoft sourceanywhere or sourceoffsite to implement access to VSS over the Internet. Of course, VSS 2005 also supports Internet access. If you are a personal developer and think it is too difficult to use VSS, try filehamster.

--------
Software Testing
--------

Before submitting the information to the tester, developers are required to perform self-testing first. Do not show a version that is unavailable to the tester. This is a disrespect for the tester.

Java has JUnit ,. net has nunit, and Delphi also has dunit, which is mainly used for unit testing. Especially in code refactoring, it can detect the modified problems in a timely manner, is an important part of daily building. Developers should write the test case code before completing the function, also known as test-driven development, so that they can be the first users of their own code, to ensure that the code you submit is easy to use and correct, so that testers are more focused on discovering hidden logical errors.

Testcomplete is a professional automated testing tool produced by automatedqa. Compared with rational robot and mercury winrunner, testcomplete is especially suitable for testing programs developed by Delphi. Automated Testing can reduce the workload of testers and improve their testing efficiency. Of course, the use of automated testing has higher requirements for testers, because testers need to maintain the test script.

--------
Defect management
--------

The tester's report should be fed back to the developer, and the developer's modification opinions should also be known. The Superior Supervisor needs to know the current test progress and modification situation, which all need to be managed by the defect management system. Generally, defect management is made into a B/S system. Of course, it also provides clients. JIRA, Mantis, Bugzilla, axosoft ontime, axosoft Powertrack, bug tracker, bugfree, Dev hound, sourcegear dragnet, testtrack pro, and urtracker have many options.

--------
Memory leakage
--------

Java and. net has a garbage collection mechanism and no pointers. Except for external resources (data connections, files, and so on), they need to be closed after use, so that developers do not need to actively manage memory release, delphi requires you to manage the creation and release of objects by yourself (create and free, new and dispose, getmem and freemem). At this point, some beginners tend to pay little attention to it, the principle of who creates and who is responsible for release should be adhered. Although there is no garbage collection mechanism in Delphi, there are tools that can help us check for memory leaks.

Memproof is a software used to check the allocation of memory and other resources. The author Atanas Stoyanov joined the company automation QA.
Aqtime is a professional testing software produced by automatedqa, including performance analysis, memory and resource allocation. The most useful of course is Performance Analysis and Memory Leak Detection.
Fast Memory Manager is an excellent memory manager. After Delphi 2006, FMM is used to replace borlandmm. You can also mount FMM in Delphi 7 to improve program running performance. FMM is also an excellent memory leak test tool.

It is recommended to introduce FMM to the project to discover and solve the memory leakage problem as soon as possible during the development process. This is an ideal solution.

--------
Error locating
--------

The tester puts forward the test errors on the Error Tracking System, and the developer must solve them. First, they will encounter how to locate some complicated errors.
First, you can use outputdebugstring to trace, debug, and run in Delphi when you break a breakpoint, view the logs in View> debug Windows> event log. Codesite is a debugging tool that allows developers to conveniently perform debugging, especially remote output. In addition, the small and open-source overseer is also a good debugging tool. The debug unit function in Jedi code library is equally powerful.

AV errors are common unknown errors in Delphi. You can usually attach application. onexception to handle all exceptions by yourself. In this regard, professional software can help us handle exceptions. eurekalog is a professional exception handling software that can tell us very detailed error information, making it easier to locate errors. Madexcept in madcollection is also a very powerful exception handling software,

--------
Create and install
--------

Inno Setup and NSIs are both free of charge. They provide powerful professional installation and production software. Inno Setup is developed by Delphi. Therefore, it is particularly suitable for the installation program of products developed by Delphi. NSIs is suitable for the installation of C-developed products. We recommend that you use Inno Setup + issi (Inno Setup script already des) + istool to create the installation program.

--------
Daily build
--------

If a company still compiles and releases software manually, problems may occur, such as packaging a Chinese file and releasing it in English. For example, the released software version is not the final version.

To ensure the stability of software release, companies of all sizes should develop a software release process and use tools to solidify the process.

The first step is to obtain the code and resources of the latest or specific version from the version control software, perform necessary preprocessing on the Code and resources (such as modifying the version number and checking the code automatically), and compile the code, compile resources (for example, help), automatically report errors during compilation (for example, send an email), and automatically perform unit tests after compilation is successful (if the test fails, the system will also report the results automatically; after the compilation is successful, the warning and prompt should be automatically reported). After the test is passed, create the installer and release the software (for example, upload the software to an FTP file and copy it to a directory ). These processes are cumbersome. If they are executed by people, they are not reliable. Therefore, they must be implemented by software.

Code Review: Check whether the Code does not comply with the pre-defined code specifications. For example, fxcop under. NET is used for code review. In Delphi, You need to implement the reviewer by yourself and add the code review rules defined using regular expressions (for example, whether the control name is standard or not, and whether the English font is used on the form, whether the public method is marked with a comment or not ). Manual Implementation of code review is inefficient and unreliable. Using dailybuild for Automatic Code review can ensure code quality and even detect potential risks in the code in advance.

You can use scripts for daily building: for example, Perl, powershell, batch processing, etc. Of course, it is only suitable for some simple scenarios, and the requirements for script maintenance personnel are relatively high.

Java has ant ,. net has Nant, and Delphi also has want (why is it called want instead of Dant? Originally, want is a Windows ant, although kylix can be run in Linux, free Pascal can be run on more platforms, but it looks good to think that want is a command line tool, want clean, want compile, and want build, as a result, the author decided to use want). Want uses XML as the configuration file, which is a little difficult to maintain. However, after the XML is maintained, the wantui interface can be used for subsequent construction, it's quite convenient.

Finalbuilder is a fully graphical build tool that supports scripts, is very useful, and supports many tools. The only drawback is that it is a paid software.

Visual build professional is also a visual build tool that supports scripts, macros, virtual machines, and paid software.

--------
Network Resources
--------

Http://www.torry.net has a lot of Delphi resources, there are a lot of excellent free controls and code.

As time passes, we have accumulated a lot of development resources, such as e-books,ArticleSource code, development tools, etc. They should be named accurately and stored in different directories. If the size is too large, they can be burned into a CD and catalogued with whereisit for safekeeping. For example, for scattered articles and codes, you can consider using a document management software, such as mybase and Evernote. Management knowledge can be shared with others to learn and improve together.

--------
Other supplements
--------

Jedi project: jedi code library and Jedi VCL are two of the largest open source code projects in Delphi. They are worth a good study.

Kol + mck: VCL is indeed very convenient, but the cost is the increase of the program volume. Kol (Key Objects library) + mck (mirror classes kit) is a substitute for VCL.

Dwpl (the Delphi wdosx project library): enables the console program compiled by Delphi to run under DOS. In other words, a 32-bit dos program is developed, and a 16-bit program is developed using turbo/Borland Pascal.

Free PASCAL/Lazarus: Free Pascal is a 32-bit compiler that supports multiple platforms. It can also be regarded as a close relative of Delphi, and the other is TMT Pascal. Lazarus is a free Pascal integrated development environment, and the interface is similar to Delphi.

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.