Delphi

zhaozj2021-02-08  176

First, regarding the interface interface for a program, as if it is a person, the importance is self-evident. The interface of a program is very beautiful, but if the interface can't reflect the function, then the beautiful interface is a bunch of garbage, this, I have experienced, when your energy is full how is it

When you make a beautiful interface, the disaster is coming, you will never do the functionality of the program! If you want to do your program, don't consider the beautiful interface, wait until all the features are all implemented, the interface is natural.

It will appear, and it is not too late to beautify. On this issue, Delphi's programmer may have the most, because all the sky is a beautiful control, this is good, that is good, no need to be a pity, so find a bunch of controls, one of the tests

The function is completely ignorant. In fact, the user uses a software, not because the interface is beautiful, but because of the function. Even the program running running in the DOS window, as long as the function is strong, the user still uses the use of taste, if work

A weak mess, even if the interface is incapable cool, the last fate is also deleted. So, when writing a software, please start with the function, not an interface! So don't you use a beautiful interface? Nor. After all, the beautiful interface is very attractive, but if you mean, let's get an ordinary interface, and finally beautify, it will cause a problem,

It is necessary to modify a lot of code, such as:

Procedure TMAINFORM.BUTTON1CLICK (Sender: Tobject) Begin FWidth: = start (edit1.text); FHEIGHT: = StrtOINT; fscreensize: = fwidth * fheight;

There is no problem when the code is running, but once you change an edit control, or just change the name of Edit, the workload is coming out, and a two changes have no problem, if

This edit1.text has more than 100 places in the code? How to do? My method is to separate the interface and function of the program! The code is try not to be associated with the specific control. As follows: procedure TMainForm.SetParam (const Width, Height: string); begin FWidth: = StrToInt (Width); FHeight: = StrToInt (Height); FScreen: = FWidth * FHeight; end; procedure TMainForm.Button1Click (Sender: TObject) Begin setParam (edit1.text, edit2.text); END; this example is a bit extreme, it seems to be a snake to add, but when you have a lot of modification of the control or replace the control name, the role is displayed. When you finally want to beautify the interface, modify the work of the code.

The amount will be reduced. Because only the incoming parameters can be replaced once, not in countless places. Principle: interface and implementation

Second, the global variable should not use global variables! ! ! Even if you set a global variable, you don't turn it, don't use it, because you have modified a feature that day, this global variable is to be dismantled into two variables, then

What will happen, or pass the parameters. Or come to an example: // mainconst showwidth = 384; showheight = 288; ... // setParamdlg sub-window spinedit1.value: = mainform.showwidth; spinedit2.value: = mainform.showheight;

The above code work is good, but if one day customers say that I want to resolution, what should I do? Re-add ShowWidth1, showwidth2 ,,, in Const Finally, the volume of Const will get more and more.

When checking const, you will be exhausted, that is changed: // mainfunction readwidth: integer; function readheigth: integer;

SetParamdlg.Width: = readwidth; setParamdlg.height: = readheight;

// setParamdlg Spinedit1.Value: = fwidth; Spinedit2.Value: = FHEIGHT

Is it better? Principle: Try to make all the parameters that do not change in the current point when designing is designed.

Third, a small problem this is what I saw on a website, more interesting, and feeling very easy, plagiarism here, but this is just programming skills, not method function sum (A: array of word; count: Word: longword; var i: word; begin result: = 0; for i: = 0 to count - 1 do inc (Result, A [i]); end;

Is there a problem with the code? At first glance, there is no problem, but if he is not necessarily when he is. why? Because count is a word, if the incoming parameters, what happens to count = 0? Correct

, Word flipped, then wait for him to loop fffff again :) So please pay attention to unsigned types!

Tired, I feel that I haven't written, rest ing, welcome bricks, welcome experts to express their opinions ....

转载请注明原文地址:https://www.9cbs.com/read-3231.html

New Post(0)