Why do some developers never useCodeRawGenerator
Code Generator. I think many developers have used it. At least I have heard of it. Why do some developers never use it? I have summarized the following situations:
1. I am used to my personal habits. I don't like tools. I like to handle everything myself.
2. I have not encountered any code generation tool that satisfied myself, and I do not want to modify it.
3. Some companies have been maintaining these projects for several years, and there is no code generator unless large-scale reconstruction. Such companies are concerned about business logic, technical depth, and other issues.
Features of small enterprise projects
My recent projects are all small projects that belong to some internal system applications of the enterprise. These projects have the following special features:
1. Small scale. It can also be understood that there is not much investment.
2. The number of developers is small. Generally, there will be no more than 8 developers plus testers.
3. The project cycle is short and generally does not exceed 3 months.
4. There are many small-scale projects.
What problems can code generation solve?
In the above scenario, it is quite necessary to have a code generator suitable for the internal style of the enterprise. It can effectively solve the following problems:
1. quickly build a project solution. The solution here refers to simple Project Creation and layering.
For example, what kind of UI project should be created, MVC or Asp.net webform, and how should we layer them? Is it a traditional layer-3 or domain-based model.
Is the project structure generated by me:
2. Ability to quickly generate a set of internal system UIS based on the entire company style
This is very important. Some companies have many systems, but it is not a good thing if the UI style of each system is too different, and the maintenance is extremely difficult, in addition, users need to adapt to different system styles. whatever the reason, it is very helpful for the company to implement a standard and unified UI.
3. quickly build a set of functional modules for simple addition, deletion, modification, and query of business data tables.
As long as there is a data table, there must be a place to maintain the data. We can make the Code Generator automatically complete these simple and boring tasks, no one wants to add, delete, modify, and query this type of Hello world every day.
4. Ability to integrate most common solutions
4.1 Record Database execution to analyze database query performance problems
To some extent, this function can help us collect database queries and monitor database access easily and intuitively.
4.2 A common and easy-to-use configuration function
It can be simplifiedProgramSupport Class Object-based access to configuration files, including collection-type configuration data reading. (How to separate web. config to improve versions)
4.3 log function
Further packaging can be made based on log4net.
4.4 cache functions. cache is an essential function template for systems with a certain degree of concurrency. Mature solutions are even more important.
Website architecture-cache application (1) Concept
Website architecture-cache application (2) implementation
Website architecture-cache application (3) Implementation
5. Achieve a unified warehousing Model
We can use EF 4.3 to implement the storage function, and then add the traditional storage mode on some basis.
6. You can build a hierarchical structure for all projects.
For example, we can add a service layer between the UI Layer and the business logic layer to achieve better decoupling. For example, we can further implement IOC between the service layer and the UI Layer.Decoupling.
Note:
1. The code generator is best based on the template form.
Template-based tools provide great flexibility. When you need to generate other types of projects, the cost of writing templates is much lower than that of writing code. so I chose T4 Text Template, and Microsoft MVC also uses it, so I have no reason not to choose it.
2. The Code Generator not only generates code
I don't think it is enough to generate code. For me personally, I hope that it can provide various good experiences from the team to the team for reuse in an integrated manner, advantages:
2.1 project members do not need to find a solution for the same function repeatedly
2.2 project members have a centralized place to learn some general solutions, which is an important learning platform.
After searching for a while in the park, I found a T4-based code generator, and the UI is made of WPF. If you think it is good, let's try it, finally, I decided to create my own code generator.
Code Generator improvements:
1. The original project cannot generate a full set of solutions. Only files can be generated.
After transformation, you can generate a complete solution and run it directly.
2. A new template is created.
It adopts the EF 4.3 code first mode, the UI adopts MVC 3, the storage mode is the traditional storage mode, and IOC is referenced for the server and UI Layer to achieve further decoupling.
3. I modified some of my personal experience in the original project.
Note: original project Article Address
Http://www.cnblogs.com/fangrobert/archive/2011/10/01/2196923.html