How does a script-built program keep the robustness of later refactoring?

Source: Internet
Author: User
I generally use strongly typed languages, such as Java or C + +. But I know a lot of systems are using weakly typed scripting languages, like watercress.
I've tried weak type development, but it's hard to maintain later, and it's almost impossible to refactor.
Is there any other way to avoid this problem, or can it support a robust refactoring?
I have been on the dynamic language Building system Maintenance mode is more curious, ask the great God enlighten!
——————————
Seeing a lot of great gods mentioning unit tests, it's true that stability after system reconfiguration can be guaranteed.
But I write programs like to write while fine-tuning the program structure (micro-refactoring), almost few unit tests, so need type safety to do at any time error detection. Don't know if this is a good habit?

Reply content:

Dynamic type a moment of cool, the project is a lot more people, maintenance is killing, don't say refactoring.
An API appears to return a, and no one can guarantee that there will be no 1% chance of returning a null, and a 0.01% chance of returning a B. A small change to look down on the N-layer code to rest assured that the result of a commit or hang up.
Facebook knew it was wrong and got a hack. Rescue ... In any language, refactoring to maintain robustness depends on a large number of unit tests. This is not a unique issue with scripting. Without him, a lot of regression unit tests, integration tests. Reply A little more, in fact @vczh said right, but it is a paradox. Because most of the time, people use scripting language is the development speed of the graph, now in order to make it robust and as far as possible to the unit test coverage, to be honest, the script is much more in the business logic and the frequency of large changes in the field, the unit test is

This is like, you use a for the benefit B, but in order to compensate for a defect and have to do something to sacrifice the benefit B.

So, personally, it's a paradox that unit testing overrides projects developed for scripting languages.

My idea is to weigh it myself, want to hurry up on the time on the script, back to slowly change back to the compiled type.

Fish and Bear's paw, not both. The script is like this Ah, the crematorium after crawling out, hurry to a hot update is.

God has blocked a door for you and will give you a window. The robustness of the system depends more on its architecture and how it isolates errors. For example, Chrome uses a multi-process architecture to avoid the crash of rendering engines and plug-ins, and Python Web Server uses exceptions to capture business errors that isolate separate HTTP requests.

The maintainability of the system depends on how to design the module partition of the system, how to regulate the external interface of the module and the communication between the modules, and how to reduce the coupling degree between the modules so as to make the reconstruction less affected by the module.

Design practices are not checked by the compiler. First of all, it seems that you want to talk about static/dynamic language rather than the problem of strength type, type strength and whether the compiler language does not have an absolute relationship with the dynamic or static language is two different children. Second, I was @vczh this very hostile camp of Lori, but why do I always want to give him praise? It is also impossible to offset the later code entropy increase when the previous design is great.

A strongly typed language like Java can only be said to be renamed by the IDE with the help of a variable/method, method extraction ... It is easier to manipulate the underlying refactoring strategy.

We can think of a type check as its built-in constraint. These built-in constraints can only alleviate some of the problems. There are many scenarios where large-scale refactoring is required, and there is no difference between strongly typed and weakly typed languages.

Instead, there are many weakly-typed languages, with Ruby as an example, where logic is very flexible in the ducktype mechanism, and in many scenarios the code is easier to maintain.

In general, the solution is only a rigorous test-driven development.
Testing is a good way to add constraints to your code at all levels, as you think. Instead of relying solely on so-called type checking.

Test-driven development, not the end of the development of the so-called unit test check.
This is completely different from the two development ideas.
The former leads to continuous improvements in code design. The latter cannot be compared.

Use tests to cover requirements as much as possible. Test drivers are also used for bugfix.
Progressively improve test coverage in ongoing code submissions.
Set up CI service, if it is a project on GitHub can be used https:// travis-ci.org/

Mastering the methods of writing tests, forming the idea of writing tests, and taking time to reconstruct them on this basis.
There is no other way. Test script: Unit test, acceptance test, stress test, if you want something reliable, one can not be less. TDD, BDD, said effective. As for the coverage problem, it can be perfected, but it has to be built by testing scripts and wealth.

CI: front @ Liang song refers to continuous integration, this is also necessary. Repeat things must be handed to the machine, the person responsible for creative things.

Premise: The business cannot be refactored, otherwise the test cases and scripts will have to be redone.

Blind area: Front-end automatic test, mainly is the browser rendering aliasing problem. It seems that stackoverflow on the image of the prototype pixel comparison of the way to make assertions, but did not practice. The original design should also be divided into the module, the interface should also be designed
The use of refactoring should be scoped to the implementation within the module, even if the internal changes to the module should not be too large.
  • 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.