Document-driven code designer-the code is designed !, Document code
Is the code typed? Are they generated in batches?
No no, the Code is designed!
If it comes to code generators, you may think of three layers, dynamic software code generators, database tables, and so on. The general idea is to first have a database and then automatically generate a series of code based on the tables in the database, including entity classes, persistence, business layer (empty function), page code, and so on. It can also generate database documents. This is really good and powerful, and it can save programmers from manual coding work.
("This mainly enables the automatic generation of base class code for tables in the corresponding database, including generating basic code snippets such as attributes, adding, modifying, deleting, querying, existence, and Model class construction, supports code generation in three different architectures, allowing programmers to save a lot of time and repetitive work for mechanical input, and focus on the development of core business logic."
-- This is an introduction from the official mosoft website)
However, we all know that table design is based on the customer's needs, business logic, and the project experience of designers, among them, the most important thing is the characteristics of relational databases (So nosql ). The table does not fully reflect the business needs, otherwise it will teach the customer to use the Enterprise Manager (Database client software. It is impossible to directly give the table to the customer, otherwise the programmer will be unemployed collectively.
To sum up, the general idea of the Code Generator is: database table-code-document.
The idea I am talking about here is the opposite: Document-code-database-business logic
Generally, the order of projects is research, design, coding, testing, and launch. A large number of documents, such as function descriptions, various flowcharts, domain designs, database designs, and prototype diagrams, need to be written in the design phase. We also need to prepare a task plan and Team division of labor. Then start encoding. When coding, you will find that the various documents in the previous stage can only be viewed, and it has no direct effect on the code to be written. The programmer must translate the code ". Translate the document into code-as a result, the codoon is born!
The actual situation is that the project is tight and the task time is short. What should we do? Documents can be left blank or supplemented, but the Code cannot be left blank. Therefore, documents are often ignored or even completely killed. This is a contradiction between documents and code.
What should we do? Sacrifice document? Next we will introduce a double-edged sword: it can make the document a power of code! Code farmers can be freed from simplicity, machinery, and repetition, but it also means there will be no "code farmers" positions!
We should also start with the company we just entered. The company is mainly engaged in a variety of enterprise management projects, adopt the most basic structure of the ABC, and then further encapsulate.
To put it simply, we use EF code frist as an entity class, then generate a database, and then design Dto based on business needs. There are a lot of Dto. Use angularjs for overall control and form, and kendoui for list. The storage part defines at least one interface, and the webapi part also defines one interface. In short, interface-oriented programming. There are more and more details.
The biggest problem for new people is-what is it. With code frist, there will be no database documentation. There are a lot of dto, But what are these dto functions? Click it one by one.
I saw monden for two weeks. How nice is there a series of documents? But as we all know, if a task has a short schedule, how can we get documents?
Well, it turns around again. If the document we designed can automatically generate code, Will everything be solved?
Database perspective: First design the database documentation, then automatically generate the entity class of ef code first, and then create a table using ef database migration function. Then generate the default Interface Definition. This is not difficult.
Business perspective: Design function modules, pages, data lists, queries, pages, deletions, and forms on the page, and then generate corresponding Dto and related interfaces based on these designs, there is also the Code required for the page. In this way, both the Code and documentation are available.
How can we implement two functions (document and Code) in one copy ). At this time, all the basic functions are available. Then make some adjustments and optimizations Based on the generated code, mainly on the page.
In the end, each project always has some special requirements, so we can focus on killing them,
By the way, you can also generate test cases and test platforms used by testers.
Now you believe it: the code is designed!