02.07.2017 at 8:34 am #4074
Васильев Владимир СергеевичKeymaster
Before discussing the topic of this article, dedicated to the concept of refactoring, let’s go back a bit to the previous articles and their clue.
In other articles on this blog, we talked about how important it is to pay special attention to planning the architecture of a program and working on its code design. And all that work logically precedes the writing of the application code, as it is an earlier stage of software development.
Here and now we will talk about the process of working on code, which can hardly be called a preliminary stage in the software development, as it is expected during development, or even after.
This is the process of improving, rethinking, refining. And, though there is a statement that you should not fix sometihng that is working , still a fresh look at the work after it’s done is needed, if we really want to create a good quality product.
It’s hard to argue with the fact that good ideas do not always come on time. Sometimes you need to try some approach to see its flaws and figure out how to fix it. This is what is called refactoring. You can define it as follows: a process of working on the code, when in result the functionality of the application remains the same, but the internal structure is getting better.
You can meet many reasons for refactoring ….
Anyone who had to deal with someone else’s project, or even had to go back to code written once by himself, certainly felt all the roughness of the code. And certainly had the feeling that you could have done many things differently, and it would be better for the project.
In fact, it is never late. If you have enough time you to work more properly on the project – it’s the best you can come up with.
I think I don’t even have to mention about how refactoring is useful for beginners in software development. When they write the code and then try to find its weak points in order to fix them.
First, it is the habit to treat your own work more critical.
Second, it is a habit to think, estimate, predict the behavior of the code under different circumstances.
I will repeat once again, that refactoring is not the same thing with designing. We work on code design before we satrt writing code. Refactoring can be performed WHILE working on the code and even AFTER
There are many reasons why you might need to refactor your code. Of course, here we will mention only some of them, the most popular. And for those who are reading this article, I can recommend also to read another article on my blog which is called “Design patterns overuse, or a “smelling code”.
If we talk about the complexity of the process of refactoring the code – it is not too difficult, rather it is a painstaking work that requires alot of accuracy and attention. Becauseit is rather easy to break a working code with the best intentions – to make it better .
If we talk about what makes you think about code refactoring , and what positive results we can have after it is done, we can highlight the following points:
- it improves the composition of code
- the code becomes more neat and easy to read
- it also becomes easier to modify
- no duplications
- all the logic is clearly determined(each class encapsulates its own part of program logic)
- after refactoring it becomes easier to find errors in code
- no bulky and difficult for understanding constructions
We could put more items on the list, but even this list is enough to understand – refactoring is a very important part of working on code!!
Once again, refactoring – is a process which is a part of working on code; it can be performed during or after writing the code is completed; it helps to remove code roughness, to improve the code structure, to make it easier for reading and for refining; and with all this the external application functionality remains the same.
In the following articles we will see the situations when refactoring is required.
Thank you for your attention;)
You must be logged in to reply to this topic.