How to distinguish the technical level of java programmers?

Author: nonesuccess
link: http: //www.zhihu.com/question/20034808/answer/20457416
Source: know almost
copyrighted by the author. For commercial reprints, please contact the author for authorization, and for non-commercial reprints, please indicate the source.

Logo for campus-level programmers:

The most part of the code is nested if (null == xxx). I also need to tell you that null must be written in the front, I rely on.

Prevent the mistakes often made in the era of c language when writing == as =. Since null cannot be used as an lvalue, a compilation error occurs when writing =. Generally speaking, in java, because boolean and other types will not be implicitly converted, it is meaningless to write this way.

I wrote and suddenly remembered such a code:

Boolean b = true;

if(b=null)
{

}

Compiled successfully, maybe it makes sense to write null on the left side of ==.

The background is full of system.out.println("--------The program should run here... userId:").

In the process of debugging the program, if you want to print something in the console, it is best to use a log tool, such as log4j, which has become popular for many years. The advantage is: the statement that prints the log is decoupled from the statement that controls whether or not to print the log, and the statement that controls how to print the log is decoupled. You can write the statement that prints the log at will in the program, and then after the official launch, pass an option to make all of them invalid .

The popular combination back then was log4j+apache commons logging. In the program, reference the commons logging api, put a log4j jar package in the build path, and then write a log4j configuration file and initialize it. The actual effective is log4j. The advantage of this is that you don't need to modify the program code when you want to change the log implementation class.

This year's popular model is logback+slf4j, which corresponds to the above two things. The implementation of logback is said to be many times more efficient, but except for very critical modules, this overhead is basically negligible.
The html page is always sorry for the line of one or two divs. I always use firefox to display that div in a frame.

The front-end people are all gods, and I still don't align the bunch of divs. Another thing to mention is that bootstrap is a work of conscience, and good people live a safe life.
IO exception handling is the stack of Arhats.

Exception handling is a technical job. My thinking back then was that I didn’t know that there was an uncontrolled exception. When an unhandled compilation error of a controlled exception occurred, I clicked on the automatic handling option of eclipse, and then chose one according to my mood.

A little experience:

Database exceptions and io exceptions are thrown directly. If the framework has to be checked (such as ibatis2.x), a RuntimeException will be sealed if it is found, and it will be thrown to the top level to let the transaction hang. Then the customer will clearly know that the program is sb, and call the maintenance in anger, then maintain the remote ssh and restart the database. If the project manager is a little more conscientious, what you can do to deal with this kind of error includes: 1. Log the exception, 2. Give the customer a clear prompt "The system is down, please contact the system maintenance staff at 13xxxxxxxxx" instead of displaying one Stack the exception stack and then let the customer look through the phone book. The idea of ​​writing a piece of code to automatically handle these exceptions is not impossible, but it is too costly for a business-customized system.

Nullpointerexception, various illegelxxxexceptions, and various other exceptions that developers are too lazy to learn. These are basically bugs in the program. If they appear in the development and testing phase, they will be adjusted and various patches will be applied until all the testing processes are completed. If it comes out in the actual operation stage, compare it to the previous one.

When the business is basically connected, the normal process is no problem, and the project team happens to have enough time to invest in the exception architecture. The following things can be done: analyze the business and find out the business exception that needs to be handled, such as according to the ID number I found out two completely different people, defined the logic for handling these exceptions, and defined the project-level exception base class api. After that, you can add various if judgments from the bottom layer, throw the exception, and then find the To handle exceptions, write catch code. The most important thing is to record all the meaningful information when throwing exceptions, such as the abnormal ID number mentioned above. At least it is necessary to record what the ID number is, the primary keys of the two people found, and you can also Record operation time, operator and other information. As long as you do this when an exception is thrown, you decide which level of catch you want, even if you just make a log, it will make the maintainers and subsequent developers thank you for your conscience.


General level programmer logo:
know struts+spring+hibernate|mybatis, interview artifact.

Previous views:

How to use these things: find a document and read a little, you can learn.

Why use these things: reflect the true level of the problem.

Current view:

How to use these things: you can give the technology casually, and you can use it when you read the documents. They are all people with good levels.

Why use these things: I searched a lot of answers on the Internet, and I need to distinguish whether it is a direct conclusion, or it was really bombed by some thunder and then very conscientiously tell you that struts2 is really fucking.

The struts1, 2, spring mvc layer is not used much. Since I haven't done any particularly high-traffic projects, I don't have much complaints about the efficiency of struts2. The current selection criteria: 1. Whether sufficient syntactic sugar is provided to allow people of average level to develop quickly 2. Whether improper syntactic sugar is not provided, which greatly increases the difficulty of maintenance. I personally think that annotations and zero configuration are best used for meta-attribute settings, not for process control. A colleague once found that the parameter passed in from the front desk would be lost for some reason, and later found that there was a filter defined by annotation in a certain jar package that was referenced. Although the actual problem is that the architecture team did not write complete documentation and did not conduct training, but after that, I also agree that this kind of thing will be clearer in a unified configuration file, and the control granularity will be more. Be thinner.

At that time, when I was a beginner in spring training, I felt that this thing was very painful. So far, I have not encountered a place where the complexity is so high that there are large quantities of attributes that need to be injected. There are a few application scenarios for aop, but out of fear of huge spring and expansion of configuration files, I would rather change the entire framework, set an abstraction layer and use various strategy modes. I feel that a lightweight aop with perfect annotation support should be a good choice.

Hibernate is not used much, I seem to have instinctive resistance to the mainstream s2sh... I have always been deeply obsessed with the structuring of SQL, because you really don’t want to be okay and always adjust the bunch of variable names to others at every turn. It's strange that there are sql statements in upper and lower case. So when I saw that hibernate must use hql to do some complex queries, I gave up this technology. I didn't want to look at SQL itself, and found that this SQL was actually assembled with String in Java...

The reason why the ibatis/Mybatis series is used more is that the author of the first one-stop framework used in his career used this thing, which belongs to the nature of horse ass. The advantage of this thing is that the sql and java code are separated, and the program looks cleaner. But letting the programmer of each module decide which sql to write and how to write it is also a terrible thing. So back then I defined a set of standard SQL lists for each table, and a few basic CRUD operations. The select operation only supports id query and equal query of each attribute. This can basically meet 80% of the needs, and the remaining 20%. After setting the configuration file splitting strategy, find someone with better SQL to write it slowly. In addition, a big slot of this thing is that it only supports false paging. Our processing method is generally to fudge the customer to buy a machine with a larger memory. Those who do not have this flicker mechanism please choose carefully. The problem requires a hack jar package, and mybatis also needs to write a plug-in support by itself, which may take a half-day to a day's workload.

Later, I felt that the configuration file was a bit cumbersome, so I encapsulated a set on the basis of apache commons dbutils. There was no need to write a configuration file. After defining the mapping relationship between column names and attribute names, CRUD operations were automatically generated and db access operations were performed. I found nutz while encapsulating the complex select operation. I felt that the ideas were basically the same, so I didn't bother to continue writing.

The dao tool provided by nutz realizes the use of a more structured method to spell sql statements, tried it, and it worked well. The transaction management mechanism is said to have slots, so I didn't take a closer look.

Decided that I did not actually use the slots: 1. It does not support the manual configuration of the name mapping between db and java, and the mapping rules I set for the project team are rather weird. It is a bit painful to write an annotation for each attribute. 2. It seems to use reflection to read and write java properties directly, instead of using the get and set methods of the java bean specification. Many of my tool classes are made of virtual properties. There are only two extremely complicated get/set methods. The actual attributes. When it was discovered that the annotation could only be added to the field, I had to give up crying without tears.

Mybatis is still used in the project. The official mybatis generator is used to generate the configuration file. The single-table operation is well supported, and the multi-table operation is solved by writing sql by yourself.


Can distinguish the difference between group and having.

Another question about db: try not to put complex things in sql. It is enough for the orm layer to provide basic operations, and the rest of the logic is handed over to the java layer for expression. Do a good job of packaging, there is a problem of efficiency, and then special optimization. Well, I admit that I don't know the difference between these two brothers.


The fields in the database must be only 2 lengths, not 32 lengths, performance problems. The table name should start with T, the egg is about to break.

The length issue didn't understand what to say. I encountered a problem two days ago. If the char type is used in Oracle, and the actual content is not exactly equal to the length of the char, the selected data is with spaces... After all kinds of trims feel not so good, Decisively varchar2 too. Anyway, this difference in efficiency has long been offset by all kinds of weird business logic. Again, if there is a problem, optimize it.

The table name problem, I think the prefix is ​​to distinguish it from the view. When there are only a few watches, no distinction is needed. When there are one hundred and seventy watches, no distinction is needed. So, strategically look at the demand decision...

A bit of experience: adding T and not adding T is an effect. The current project approach: Most of the tables in the database correspond to a business entity. Just write the names of these classes directly. The views built on these tables are uniformly prefixed with a V_ to distinguish them. Generally speaking, at least one hundred and fifty-five of the one hundred and seventy tables are of this kind. Most of the other tables correspond to some special scenarios or algorithms. In actual development, dedicated core personnel are generally responsible for them. According to practical purposes such as access control and transaction control, which prefix is ​​added, whoever is responsible for which module will pay attention to which prefix Enough.


Will use jquery.ajax to get data, do not know the synchronization lock of ajax.

I do not know either. Regarding all locks, my opinion is that the last maximum granularity is to ensure data consistency. Specific analysis of all the problems that occur, one by one to reduce the granularity of the lock.


After a while, the displayed table has data, and there is no data for a while. I'm so angry.

When encountering such complaints: 1. Tell him that there is no fantasy story in the industry, 2. If you ask the same question again, I resigned. To make this kind of person feel that he still has the illusion of being in the programmer world is not responsible for him.

Record the operating environment at that time in detail, and the reason will usually be found.


Symbols of programmers at the Sao level:

Understand the meaning of float and clear of div.

1. The last set of bootstrap solves 80% of the problems. 2. For the remaining 20% ​​of the problems, find a front-end that has a good relationship with you, ask others to eat, and then solve it.


The database has more than n record tables horizontally and vertically divided into tables.

The problem is that n is equal to how many. It doesn't matter to overestimate n, any problems that will arise will definitely arise. If you underestimate n, the resulting schedule loss will make you have the urge to commit suicide, and the resulting data loss will make the project manager have the urge to kill you.


Knowing that Oracle uses with, this sql looks comfortable to write.

I don’t know this. I googled it, and it’s really useful.


Seeing that aop can say a lot of nonsense, it is also an agent and reflection, but I haven't written it.

Your mistake is to study the implementation principle without knowing the purpose.


DateUtil must have been written many times. It is simply too complicated. There are a lot of format definitions, and that static format variable must be understood in depth.

1. There is a good comment: writing almost all methods of a toolkit to mark obsolete, this is how hostile this society is.

2. Since having JodaDate, my mother no longer worry about handling my date. When a colleague stayed up all night again and wrote a DateUtil and I took out JodaDate...


Mainstay level programmer logo:

Know how to structure programs, write a frame with extjs or easyui, and write a recursive menu.

All the knowledge points are very basic, but it is the mainstay that can write all of this completely, let the project team use it after debugging, and maintain or add some new functions after a period of time. To put it bluntly, this is a job where EQ requirements are greater than IQ requirements. Customized development of business systems is actually this type of activity. You don't need to have a particularly advanced technique, and you won't face such huge difficulties suddenly. You will only wear away all your passion in seemingly inconspicuous bugs.

Can use ps to process pictures, and can write a few words, XXXX system beta version.

Those who can ps are gods, do not explain.


Basically, the author of the util package uses log or interceptor to record logs.

And, willing to kill anyone who has touched your util package.


Can use fiter or Interceptor to handle permissions, but don't know how to handle button permissions.

Just remove the need for button permissions at the business level.

The real solution has not been actually implemented, but just an idea: when the system is modeled, the permission model is built directly to the operation level, for example, each Action processing function corresponds to an operation, and the permissions of each role are defined for this operation. The button is conceptually mapped to permissions as well. As for how to control permissions for functions, just use xml or annotation to define it.


Understand that the conversion of exception handling to RuntimeExcetion is great, not lost and easy to handle.

Exception handling is really a technical job. When I said, I didn't know the goodness of my plan, but just felt that your approach was not elegant, I clearly heard the sneer in the other party's heart. Often my conclusions will be confirmed within about three module development cycles.


The code and css style and class in the page tab are all in the jsptag. I think it can't be divided. This is typical.

The front end is used to submit parameters, and the code mentioned by visual inspection is to calculate the attributes of page and rowperpage. Just find a set of js grid controls and see their parameter submission method. The front end does not depend on any JSP. I think it is enough to assign it to that part.



Mavericks level programmers:

Know the difference between url resource tree and menu.

I don't know how serious it is In fact, many people don't pay much attention to this kind of conceptual thing. They used to oppose this kind of inattention, but after paying attention to it for many years, they really haven't paid much attention to any gains. The current point of view is, let's talk about it when it is used.


Being able to write css by hand, knowing what important can be used to do, this is very fun.

It's the front end again, let's go to bootstrap


Able to understand that the database must use primary and foreign keys, otherwise the guys will write programs randomly.

As long as it is an entity class, it must have a primary key, and it must have a physical primary key, not just rely on a logical primary key. If you can’t find other uses for id, you can simply use it as a tool for quick search and positioning. As the complexity of the business increases, you will find that it becomes more expressive. In most business systems that rely on persistence, it can be simply defined. If there is an id, it means the thing exists, and if there is no id, it means it doesn't exist. If you think about this, many businesses will be simplified.

Only use id as a foreign key, don't use things like Shenma ID number and order number. Then your program can be written whatever you want.


Know how to design a database model, a few hundred tables.

For the real world, only abstract, no modification, to maintain the conceptual consistency of the entire system. Then you will find that the designed model will exactly meet the various criteria of database design. At this time, the database structure can be used.

If you design a relational table that you think is useful, but you can't name it properly; or there is a redundant field in the database that is not set purely for efficiency issues, trust me, you will eventually meet one of you The model cannot express the business needs.


The comment uses // only one line, not multiple lines /**, because the program is a comment.

Jdk standard comments are not used, what about javadoc?

Well, the program is the annotation thing. Several people of the same level and similar ideas can still do it through irregular pair programming and mutual code reconstruction. If it is a large-scale development, it is still recommended to solve it through a reasonable layered architecture.


Knowing that struts model-driven instead of attribute injection is convenient for too many things.

Another syntactic sugar. If you need to use it after you have the actual needs, it will be endless arguing about whether or not to use it. Just follow these two points. This sincerity is not the core issue.


I have used this for parameter passing, and many people have never seen it before.

Ha is amazing! Someone really said this to me.

Technically this is a reference to itself. Certain specific scenarios are indeed very interesting to use. The high-level meaning is not too clear. There is only a vague impression. It is probably a matter of entrusting itself to other objects, encapsulating the transfer of a certain parameter. The process of encapsulating the relationship between itself and the delegated class.


SE level programmers:

I have studied the source code of struts and hibernate. There is the concept of complementary colors in the ui, which seems to be more comfortable.

Learning source code should be combined with writing code for execution. After learning a new model, think about the application scenarios, but you must be cautious in actual use. For example, after seeing the layer-by-layer wrapper mode of struts2, I used it once, and it was sprayed for a long time.

I think struts, hibernate, spring, if you want to throw away a framework, it must be spring, this is a waste.

If I choose, I throw hibernate.


I have written mvc and know the front-end interceptor, central dispatcher, post-processing, and bean mapping.

You must know that even without these concepts, the code level will certainly achieve all the functions of mvc. Then find the cost of not having these concepts, which things are coupled, which changes cannot be dealt with, and so on. In the end your level will improve.


Will use model-driven user.save() instead of dao.

Passing one less parameter is conceptually more elegant. Model-driven too tests the modeling ability, so we must think clearly about all the problems in a range before using it. It is recommended to read the DDD book two or three times before repeating it.

But this thing looks really attractive.


It's much cooler to be able to generate a bunch of messy code with metadata.

The interpretation of metadata is "data describing data". For example, the table structure definition of a database may be regarded as a kind of metadata. After the metadata can be correctly abstracted in the process of writing code, the vision will be raised to a level. As for whether or not to engage in tools to generate code, it varies from project to project.

I have used freemarker for a while, and it is quite easy to write some lightweight code generation tools.


I have studied Annotation, used Annotation to write annotations, know how Annotation inherits, it is too complicated to understand.

I have used Annotation to implement a set of Model tools, but I haven't had a deep understanding of ejb. Maybe I have some idea of ​​entity bean in it.

Some of the annotations were mentioned earlier. The advantage of this thing is that the metadata is put together with the java code, so it is easy to find or change it, and the disadvantage is also put together so it is coupled. If the amount of code reaches a certain level, it is best to gather all the main players together and discuss whether it is better to xml or annotation.

If the amount of code is not large enough, or the data of the annotation configuration is only used by the class where the annotation is located, you can consider this issue in terms of development efficiency. Jdk provides an annotation operation tool at the language level, which is simple to use, and has a part of compile-time checking, and it is more comfortable to write than xml. In addition, I personally think that the grammar of annotation is not suitable for defining a structure that is too deep. Write four layers of annotations in front of the class and then use ide as a formatter. To be honest, it is quite worrying.


BOSS level programmers:

Admire it. . . .

The above experience is based on the following:

Most of the projects I have done have very simple technical requirements, moderately complex business requirements, particularly frequent changes in requirements, insufficient average quality of developers, and not very tight schedules, so the focus is on how to isolate business complexity through layers. And how to reduce development complexity through syntactic sugar. In terms of bugs, I pay more attention to bugs that affect data consistency. As long as it does not affect data consistency, even if the system is directly hung up, it is not a life or death factor that affects the project.

When making technical solutions, I tend to:

1. Encapsulate complexity through various design patterns, provide as simple as possible, or even brainless development interface

2. Ignore all efficiency issues and want to optimize things after the business gets through

3. What can be done in the compiler will not be released to the runtime, even if it will affect the flexibility of development

Guess you like

Origin blog.csdn.net/cao919/article/details/51861697