Six misunderstandings in building enterprise-level applications

Source: Internet
Author: User
Before coding your team, let's take a look at some common errors in enterprise-level applications. Before focusing on how to do this, I want to focus on what should not be done first.

Many programmers get knowledge from the book, and then add some good things to the code, but they also leave the same error in the program, so I will introduce some common errors in enterprise-level coding and briefly explain how to avoid these errors.

1. The data storage type you use is irrelevant.
The first step in designing an application is the storage of your data. All applications are based on a database. This is not just a result. However, there are other popular ideas recently: You can use relational databases, XML databases, object databases, directory services, and more.

As a result, many companies often do not exchange their own ideas to exchange these different forms of data storage. If the directory service is cheaper than the database, some companies will use directory services to replace databases. XML databases are also put into applications because of their "charm" and industrial vigor. However, the trend of using any data storage in any case is ridiculous. Your performance will be degraded, and the code will become more and more complex. You will not be able to know what to do.

Each data storage method has its unique characteristics. For example, the Directory Service provides the best support for frequent reads and few writes. Verifying and searching for names and addresses is a perfect usage of the Directory Service. However, if you write some data to the Directory Service frequently, you will find that its performance degrades. Such a case is the best for the database.
It is also important to decide what type of database to use. For example, it is silly to use an XML database without pulling the XML directory out of the database. You have chosen XML, but never used XML.

In my new book, I made these choices. In fact, you will learn how to combine database and directory services, and how to transfer data between them.

2. The seller's Special Nature adds encoding tasks
Programmers often use shortcuts to accelerate encoding. However, more often, these shortcuts become a long-term defect. No matter how much time is saved before the encoding is completed, it will always take a lot of time to change the code after the end. Let me give the following example.
Obtain the version of the EJB and database table. A common version is to insert an idnumber in a field of the table. Because Oracle uses sequences to do this, MySQL uses an automatic incremental field, other tables may not support this numbering method at all.

As I can see, it is directly used to access Oracle sequesnce, MySQL incremental fields, or other databases. In other words, ejbs will not run databases other than specific encoding on any database; in fact, they cannot work on different databases of the same seller. The result is heavy, short-lived, and cannot keep up with the code that the company needs to change.

3. I need an editor or tool to write my EJB
I am often asked what tools I use to develop ejbs. it is clear that people want to know what I use to generate source code for remote interfaces, home interfaces, and execution classes. so to make coding easier, you must have a tool to help you do the repetitive tasks. If you modify the framework in the code, forget a Punctuation Point, or accidentally make a wrong method. The result is that the code compilation is incorrect and debugging is difficult.
Maybe it seems very economical to use VI and notepad to edit Java :), but I use Ctrl + C, CTRL + V, and 'yy' in these text editing tools ', 'kk 'and 'P' are better to cut and paste code than Reagan, a tool I 've used in any editor. The result is that I have a higher understanding of my code and know what is in everything in my code.
I did not say that you should not use an editor or tool (jedit is the most commonly used tool); however, when you rely on these tools, you will be in trouble, I can't compile anything in a week, except an editor. You will be surprised by your new understanding of your code management. I didn't recommend any tools in my book, in this way, you can end up with a valid and logical code bean. And other components in your application.

4. technologies including JMS, XML, and JAXP are used in applications.
I learned that if you have read my books and articles for a long time, you may try your best to do this. I have always insisted on what you need in the program, knowing that I have seen people's industrial energy or that I have called out loud.
The most basic error I want to talk about is that all J2EE technologies must be used in J2EE applications. If ejbs, JMS, and JMX are not used in applications, XML and other things are in your app server, and you will think you are wasting money.

Everything is nothing more than the facts. In fact, although in my last book, I am writing a chapter about JMS, which does not mean that JMS is not important; obviously, the application I wrote for that book really does not need JMP .. I have written a few applications that require JMS, and I also have a few very cute examples of using JMS in the book. However, the versions are all legends: Sometimes they are not all what you need.

In any case, you only need to use what you need 50 times. If you need all the technologies in a pair of servlets and JDBC code, stick to the following: do not add complex ejbs. If you do not need them, Do not worry if you need ejbs but the message-driven bean is out of the scope of your application. At the end, you will still be happy with your simple application.

5. stateful beans are more object-oriented programs.
This is the most common problem and is often the simplest to correct. Basic errors include method calling methods. For example, you may find such methods in a remote interface of a stateful Session Bean:
Public user create (string username );
Public Address getaddress ();
Public list getaccounts ();
Public Boolean deleteaccount (account Account );

The idea here is that you need this bean so that you can use username at one time. Therefore, your method call should be as follows:
User user = userhome. Create (username );
Address = user. getaddress ();
List accounts = user. getaccounts ();

Using this method in Session Bean seems more object-oriented.
Public user create ();
Public Address getaddress (string username );
Public list getaccounts (string username );
Public Boolean deleteaccount (string username, account Account );

The call method is as follows:
User user = userhome. Create ();
Address = user. getaddress (username );
List accounts = user. getaccounts (username );

Wow ~! Obviously, this is too difficult to work :) As you can see, it is not very similar to Oo, however. After you change the status to stateless, the speed increases by 10 times and 100 times. Sacrifice a little on the object-oriented interface can miraculously increase the speed of your code.

6. I don't need anyone to tell me how to encode it.
A, yes, so we will always be in one place, right? I remember that during my years of programming, I often made changes, made them, never copied others, and never needed anyone's help. Of course, later I found that my smartest reform is very poor for understanding many of the best use cases. It is silly for others to help you and you to reject it.

I suggest you integrate it into open source programs for communication, and you will learn more than you think. The bottom line is that there are a lot of really smart people. I suggest you learn the most from these people. When you decide that you don't need anyone's help, you must have made more mistakes than before.

Well, here are the six most common problems I have seen. You will find one or two of your problems here. Don't be shy. It doesn't matter if you have one or two problems, you can change it. Think of these as what you need as a better programmer. I hope you like this new book and I will wait for you to hear back.

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.