JBuilder Practice 2: Accessor (gettersetter) method

zhaozj2021-02-08  267

Title: [JP2: Accessor (getter / setter) method]

Version: 5 ~ 9

"Fengshui wheel flows, this year to my home", now O / R mapping technology is very hot, it is like the trend of Sparks, and spread quickly. To understand the ORM, Entity Bean is the most loud brand in this technology. Now, Hibernate [Note 1] will appear, it is definitely the pioneer of this technology.

Since it is O / R, of course, there is a supporting development tool in both sides (OO and RELATIONAL), borrowed the development method mentioned in OO software development, I summarize three methods (already in the development tools) [Note 3]:

1, from top down

Object-oriented method refers to the process of generating from an analysis, designing to a table structure, and then generating a code. In such a development method, the Model tool will generally use, first capture the needs, then analyze the Class, and finally generate Database Tables and code. This method is supporting the most tools, Rose and Together et al., Is one of the ways to push now.

2, the middle begins

As a speed method, this method compares class XP, generates Database Tables, and then makes it back to the end of the design and database design documentation. This method is mainly used to drive project progress, or beginners. This method does not require other tools, only using the database client.

3, bottom up

Process method, this method is mainly designed to design a table structure, then generate Database Tables, and you can finally fill some other documents. It is often adopted in an environment where demand is mature and developers. The tools used in this method are PowerDesigner for designing the database, very good.

I said a big pass (first put the audience first), mainly introducing these concepts, for better promotion, because the development environment is very different, we advocate to solve practical problems in the most practical way.

When using the latter two methods, write a batch of Accessor methods when writing data objects, because the data objects generally correspond to the tables in the database. Write these Accessor methods very boring, and very wasting time. Is there a getter / setter method for this attribute?

The answer is certainly affirmative. I have to have this feature in JBuilder. I have never noticed it until I can't keep it because I can't hold it. I can't succeed, I have succeeded. The steps to say below:

1, there are multiple development views in JBuilder: Project, Content, Stucture and Message [Note 4]. When a new Java class, the source code of the program will appear in the [Content] view of JBuilder, there are several Tab buttons at the bottom of it, that is, the various expressions of the Class. see picture 1)

Figure -1 (V7)

2. Click on the [Bean] button in the bottom Tab button, the interface will appear as (Figure -2).

Figure -2 (V7)

3, then click [Properties], all properties of the Class are displayed, you can also add attributes to the Class. The details of all properties displayed in the grame below are shown. Select [getter] and [setter], the Accessor method is automatically generated in the program, and the method is placed in the order you clicked. In this method, there is no "full choice" function, each need you click, not very convenient, I hope Borland can continue to improve.

Reference:

[Note 1]: Hibernate is a gradually popular ORM open source framework, you want to know it, you can access its primary site (http://www.hibernate.org), the Chinese site can refer to Robbin (http: // hibernate. FANKAI.com).

[Note 2]: The so-called model tool is modeling tool, and now the most popular is of course UML modeling tool, such as Rose and Togethe.

[Note 3]: These three methods mainly refer to which angle start design, if designed in OO, of course, it is "self-top" method; if you start designing the process, what I said "Since the bottom up" method.

[Note 4]: You can display these views by clicking "View" in Menus.

By befresh

2003-9-13

转载请注明原文地址:https://www.9cbs.com/read-1271.html

New Post(0)