deified architecture and exaggerated CTRL + C and CTRL + V

Source: Internet
Author: User

Why do I want to talk about architecture, and code copy paste these two topics, mainly in the past few days saw an article mentioned these two topics, here want to talk about my views.

A lot of new people, are very talk about the structure, as if affixed to the structure of the label to show high-end like, the design model as the Bible, it is ridiculous. Do the structure, not holding a book, and then behind closed doors to think out.

The architecture is done, not designed.

Structure, in the mean of decoupling, the change of things out, this is its essence. In general, the closer to the bottom the more stable things are, the more likely things are to change as they approach the business layer. If you want to encapsulate on the business layer, that is to say, you want to do architectural design, you must fully understand the business, not enough coding experience is impossible to do. So I often say that the architecture is not designed, but do it, as long as you finished, the whole business has been determined down, fully understand, you can design a reasonable structure. Because the architecture is dependent on the needs of the need to do not determine the circumstances of the framework to do, the demand for a change, those so-called architecture is not to be changed to a step confused, and finally even their own can not see down, and then down again. In fact, it should be at the end of the project, the completion of the business process is also determined, this time to have the framework to talk about.

Architecture design, but also consider the cost, many novice, often ignore this problem, that is, you have to consider how much time it takes to do this architecture, how much time you can save. If the cost is much greater than the profit, then it is meaningless. But they tend to explain that it takes a little longer to spend more time later. But the fact is often, upfront spend more time, later also spend more time, always want to make this architecture become more perfect and indulge in it, unable to extricate oneself. We tend to be overly obsessed with architecture and forget to do the project. To do the project, is to solve the customer's business problems, can improve their business level, this is the essence.

Architecture, in fact, nothing, your code is much more, write more, naturally there will be a structure, remember the package changes this core on the line. In fact, reading code, analysis code, writing code are the real basic skills, is the so-called "Lianquan do not practice, to the old one empty", write the program is also, as a newcomer, should spend more time to read code, write code above, their basic skills to practice a solid is the most important.

Copying and pasting code is not a scourge

Many people habitually despise ctrl+c,ctrl+v, as if with them, is rotten code, in fact, can not be. Let's think about it, why not ctrl+c,ctrl+v it? Because the code is difficult to maintain, for example, there are two identical code, then it is possible to change two places. But have you ever encountered such a situation, we first assume that there are three places, a, b,c, are called to a function, this function is called M Bar.

However, soon after, received a change in demand, A's business changed, need to modify the function of M, but the b,c is not changed, then we habitually in the function M Riga an If to judge, if it is a business, on how.

After a while, a change in demand, B's business changed, and then habitually, in the M function Riga an IF logic block.

Soon after, the change in demand, and C's business changed, so habitual, will be in the M function Riga an IF logic block.

Excuse me, so the M function is full of so many if, still easy to maintain? You might as well write three functions.

Therefore, we can not see the copy paste as a scourge, as long as within the controllable range on the line, of course, if the business is determined will not change, or a. What is controllable? I think the duplication is only three place, it is not a problem. In short, it is reasonable to exist, many times, we are always used to overestimate ourselves, and underestimate others.

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/project/

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.