Thursday, January 13, 2005

Java Tip #6 - Don't capitalize first two letters of a bean property name

This is in our java standards. You should not create a java bean property name that begins with a capital letter in the 1st two places. It can lead to confusing results. We had this happen a few times & finally added it to our standards & enforce it in code reviews. One place we saw problems was in struts. The form bean properties are used in the JSP page, but the Struts framework has to use the getter() & setter() to interact with the bean. This mapping happens based on the java bean spec & in certain cases can cause a method not found error if the developer doesn't name the method just right. The java bean spec provides guidelines on how to map between property and the associated getter() & setter().

The following is from the javabean spec at http://java.sun.com/products/javabeans/docs/beans.101.pdf .

8.8 Capitalization of inferred names.

Thus when we extract a property or event name from the middle of an existing Java name, we normally convert the first character to lower case. However to support the occasional use of all upper-case names, we check if the first two characters of the name are both upper case and if so leave it alone. So for example,

“FooBah” becomes “fooBah”
“Z” becomes “z”
“URL” becomes “URL”

We provide a method Introspector.decapitalize which implements this conversion rule.

Here’s the source code for Introspector.decapitalize().


public static String decapitalize(String name) {
if (name == null || name.length() == 0) {
return name;
}
if (name.length() > 1 && Character.isUpperCase(name.charAt(1)) &&
Character.isUpperCase(name.charAt(0))){
return name;
}
char chars[] = name.toCharArray();
chars[0] = Character.toLowerCase(chars[0]);
return new String(chars);
}
The following table shows how the 1st two characters map. If this was a mathematical function, I’d say it wasn’t one-to-one. (‘aa’ and ‘Aa’ imply the same getter)

property
-----------
getter
---------
aa getaa()
aA getaA()
Aa getaa()
AA getAA()


59 Comments:

Anonymous Anonymous said...

Believe it or not this tip really helped me out. Thanks a lot!

1:56 PM  
Anonymous Anonymous said...

Is it not rather like this?

property x getter
-----------------
aa = getAa()
aA = getaA()
Aa = getAa()
AA = getAA()

8:23 AM  
Blogger Stevo Slavić said...

This comment has been removed by the author.

3:42 AM  
Blogger Unknown said...

everything mentioned above is wrong,its not working
I have scenario Wind_shrt is my field, and according to this post I have tried every possible solution to form getter/setter method, nothing helpful guys.

5:51 AM  
Blogger Unknown said...

Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing..
java training in chennai
java course in chennai

4:40 AM  
Blogger Gheel said...

Really helpful subject dealt in the Aorta Digital Marketing Training Institute in Chennai.
Digital Marketing Training Institute in Chennai | SEO Training in Chennai

2:01 PM  
Blogger service care said...

Remarkable post! That's a lot of information. Thanks for taking your time and effort to share this with us. Keep us updated.
mi service center in chennai
redmi service center in chennai
xiaomi service centre chennai
redmi service center
mi service center

4:45 AM  
Anonymous vishwa said...

Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
oneplus mobile service centre in chennai
oneplus mobile service centre`
oneplus service center near me
oneplus service
oneplus service centres in chennai

7:41 AM  
Blogger service care said...

Inspiring writings and I greatly admired what you have to say , I hope you continue to provide new ideas for us all and greetings success always for you.
Keep update more information..
honor service center near me
honor service
honor service centres in chennai
honor service center velachery
honor service center in vadapalani

7:15 AM  
Blogger service care said...

Amazing article. Your blog helped me to improve myself in many ways thanks for sharing this kind of wonderful informative blogs in live. I have bookmarked more article from this website. Such a nice blog you are providing.
samsung mobile service center near me
samsung service centres in chennai
samsung mobile service center in velachery
samsung mobile service center in porur
samsung mobile service center in vadapalani

5:07 AM  
Blogger service care said...

This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic.
oneplus mobile service center
oneplus mobile service centre in chennai
oneplus mobile service centre

3:11 AM  
Blogger service care said...

This is the exact information I am been searching for, Thanks for sharing the required infos with the clear update and required points.
apple service center chennai
apple service center in chennai
apple mobile service centre in chennai
apple service center near me

6:02 AM  
Blogger digitalsourabh said...

C C
++ Classes in Bhopal

Nodejs Training in Bhopal
Big Data Hadoop Training in Bhopal
FullStack Training in Bhopal
AngularJs Training in Bhopal
Cloud Computing Training in Bhopal
PHP Training in BhopalC C
++ Classes in Bhopal

Nodejs Training in Bhopal
Big Data Hadoop Training in Bhopal
FullStack Training in Bhopal
AngularJs Training in Bhopal
Cloud Computing Training in Bhopal
PHP Training in Bhopal

2:10 AM  
Blogger Kayal said...

This is the best post and I got more information about this topic. I am waiting for your next post...!
Pega Training in Chennai
Pega Developer Training
Linux Training in Chennai
Tableau Training in Chennai
Spark Training in Chennai
Primavera Training in Chennai
Excel Training in Chennai
Corporate Training in Chennai

1:34 AM  
Anonymous Anonymous said...

Nice Post
Visit for the best AI training in Bangalore:-
Artificial Intelligence training in Bangalore

5:12 AM  
Blogger Unknown said...

Excellant submit!!!.
The strategy you've got published on this generation helped me to get into the subsequent stage and had lot of information in it..

click here formore info.

12:39 AM  
Blogger menon said...

This blog is very helpful for us...I got some important information from this blog..
DOT NET Training in Chennai
DOT NET Training in Bangalore
DOT NET Training Institutes in Bangalore
DOT NET Course in Bangalore
Best DOT NET Training Institutes in Bangalore
DOT NET Institute in Bangalore
DOT NET Training Institute in Marathahalli
PHP Training in Bangalore
Spoken English Classes in Bangalore
Data Science Courses in Bangalore

1:45 AM  
Blogger hami said...

Click here to read more.
.......................................................................

2:16 AM  
Blogger gadgetsdora said...

Can I just say what a relief to find someone who actually knows what they are talking about on the net. You certainly realize how to bring a problem to light and make it important. A lot more people have to look at this and understand this side of your story. I was surprised you aren't more popular given Web that you surely have the gift.

6:05 AM  
Blogger Unknown said...

The next time I read a blog, I hope that it won't disappoint me just as much as this one. After all, I know it was my choice to read, but I actually thought you would probably have something interesting to say. All I tech hear is a bunch of moaning about something you could fix if you weren't too busy seeking attention.

4:04 AM  
Blogger Joyal said...

Effective blog with a lot of information. I just Shared you the link below for ACTE .They really provide good level of training and Placement,I just Had Artificial Intelligence Classes in ACTE , Just Check This Link You can get it more information about the Artificial Intelligence course.
Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery

9:51 AM  
Anonymous Anonymous said...

Hey guy's i have got something to share from my research work
Louiz
Redox-os
https://diigo.com/0hmsvz

3:01 AM  
Blogger akshaya said...

I can feel the great dedication in you when I read this post. All the information’s are furnished to the point.I am filled with this zeal after reading this blog.
Web Designing Course Training in Chennai | Web Designing Course Training in annanagar | Web Designing Course Training in omr | Web Designing Course Training in porur | Web Designing Course Training in tambaram | Web Designing Course Training in velachery

11:00 AM  
Blogger lavanya said...

Thanks for sharing an informative blog keep rocking bring more details.I like the helpful info you provide in your articles. I’ll bookmark your weblog and check again here regularly. I am quite sure I will learn much new stuff right here! Good luck for the next!Java training in Chennai

Java Online training in Chennai

Java Course in Chennai

Best JAVA Training Institutes in Chennai

Java training in Bangalore

Java training in Hyderabad

Java Training in Coimbatore

Java Training

Java Online Training

9:20 AM  
Blogger sathya said...

Thank you for the nice article here. Really nice and keep update to explore more gaming tips and ideas.

selenium training in chennai

selenium training in chennai

selenium online training in chennai

selenium training in bangalore

selenium training in hyderabad

selenium training in coimbatore

selenium online training

1:12 PM  
Blogger sathya said...

This concept is a good way to enhance the knowledge.thanks for sharing. please keep it up

selenium training in chennai

selenium training in chennai

selenium online training in chennai

selenium training in bangalore

selenium training in hyderabad

selenium training in coimbatore

selenium online training

1:14 PM  
Blogger surya said...

I just got to this amazing site not long ago. I was actually captured with the piece of resources you have got here.
angular js training in chennai

angular training in chennai

angular js online training in chennai

angular js training in bangalore

angular js training in hyderabad

angular js training in coimbatore

angular js training

angular js online training

3:41 AM  
Blogger surya said...

Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style.
angular js training in chennai

angular training in chennai

angular js online training in chennai

angular js training in bangalore

angular js training in hyderabad

angular js training in coimbatore

angular js training

angular js online training

9:09 PM  
Blogger deiva said...

Nice post. Thanks for sharing! I want humans to understand simply how excellent this facts is to your article.
It’s thrilling content material and Great work.
java training in chennai

java training in omr

aws training in chennai

aws training in omr

python training in chennai

python training in omr

selenium training in chennai

selenium training in omr

11:45 AM  
Blogger deiva said...

Nice post. Thanks for sharing! I want humans to understand simply how excellent this facts is to your article.
It’s thrilling content material and Great work....
web designing training in chennai

web designing training in omr

digital marketing training in chennai

digital marketing training in omr

rpa training in chennai

rpa training in omr

tally training in chennai

tally training in omr

9:17 AM  
Blogger Jayalakshmi said...

Wonderful blog with great piece of information. Regards to your effort. Keep sharing more such blogs.Looking forward to learn more from you.
angular js training in chennai

angular js training in tambaram

full stack training in chennai

full stack training in tambaram

php training in chennai

php training in tambaram

photoshop training in chennai

photoshop training in tambaram

7:55 AM  
Blogger Ramya said...

Subsequently, after spending many hours on the internet at last We've uncovered an individual that definitely does know what they are discussing many thanks a great deal wonderful post.
DevOps Training in Chennai

DevOps Online Training in Chennai

DevOps Training in Bangalore

DevOps Training in Hyderabad

DevOps Training in Coimbatore

DevOps Training

DevOps Online Training

11:16 PM  
Blogger jeni said...

Wow, amazing weblog format! How lengthy have you been running a blog for? you make running a blog look easy. The total glance of your website is wonderful, let alone the content!
oracle training in chennai

oracle training in velachery

oracle dba training in chennai

oracle dba training in velachery

ccna training in chennai

ccna training in velachery

seo training in chennai

seo training in velachery

12:24 PM  
Blogger shiny said...

This information is impressive; I am inspired with your post writing style & how continuously you describe this topic.


oracle training in chennai

oracle training in annanagar

oracle dba training in chennai

oracle dba training in annanagar

ccna training in chennai

ccna training in annanagar

seo training in chennai

seo training in annanagar

12:44 AM  
Blogger Revathi said...

I feel really happy to have seen your webpage.I am feeling grateful to read this.you gave a nice information for us.please updating more stuff content...keep up!!

Android Training in Chennai

Android Online Training in Chennai

Android Training in Bangalore

Android Training in Hyderabad

Android Training in Coimbatore

Android Training

Android Online Training

12:52 AM  
Blogger prabhu said...

Thanks for sharing an informative blog keep rocking bring more details.I like the helpful info you provide in your articles. I’ll bookmark your weblog and check again here regularly. I am quite sure I will learn much new stuff right here! Good luck for the next!

IELTS Coaching in chennai

German Classes in Chennai

GRE Coaching Classes in Chennai

TOEFL Coaching in Chennai

spoken english classes in chennai | Communication training

3:47 AM  
Blogger vivekvedha said...

Great post and informative blog.it was awesome to read, thanks for sharing this great content to my vision.
Good discussion.
acte chennai

acte complaints

acte reviews

acte trainer complaints

acte trainer reviews

acte velachery reviews complaints

acte tambaram reviews complaints

acte anna nagar reviews complaints

acte porur reviews complaints

acte omr reviews complaints

9:50 AM  
Blogger jhansi said...


Oracle Corporation is an American multinational computer technology corporation headquartered in Redwood Shores, California.
tally training in chennai

hadoop training in chennai

sap training in chennai

oracle training in chennai

angular js training in chennai




12:48 AM  
Blogger Aishwariya said...

Superb post, the post is very impressed to me in this content was having more kinds of details about this topic. Good job...!
Primavera Online Training | Primavera Course in Chennai

12:42 AM  
Anonymous Anonymous said...

It is amazing and wonderful to visit your site. Thanks for sharing information; this is useful to student....

SASVBA provides the best R Programming Training In Delhiusing the latest development environment and framework in Delhi. We constantly update our program to reflect the latest industry trends. SASVBA is one of the top deep learning teaching institutes at NCR in Delhi that assists students in interviewing tech giants. We educate both college students and schoolchildren.

FOR MORE INFO:

6:52 AM  
Blogger aishu said...

Thanks for Sharing This Article.It is very so much valuable content. . AWS course in Chennai

5:55 AM  
Blogger technews said...

Hello there! I simply wish to offer you a major approval for your incredible data you have here on this post. I will be returning to your site for all the more soon. update news

2:32 AM  
Anonymous Getdigitalera said...

The 1tac TC1200 utilizes Cree XML2 LED innovation and has a yield of 1200 Lumens. The life expectancy of the electric lamp is around 100,000 hours of light. The TC1200 additionally has a carefully directed net to guarantee that the splendor is kept up for the duration of the existence of the morning. You may have used the flashlight before, but 1tac TC1200 tactical flashlight is different from others. Check now 1Tac Flashlight Reviews to clear your doubt. These are flashlights intended to pull twofold obligation. In addition to the fact that they function as electric lamps to help you find uncertainty, they also fill in as weapons.

6:41 AM  
Anonymous odass software said...

company in bhopal
website devolopment company in bhopal

1:10 AM  
Blogger Hussey said...

Happy to read the informative blog. Thanks for sharing
IELTS Coaching Center in Chennai
best ielts coaching centre in chennai

5:37 AM  
Blogger Matt Reeves said...

Great post. Thanks for sharing such a useful blog.
Hadoop Training in Anna Nagar
Big Data Training in Anna Nagar

12:16 AM  
Blogger milka said...

Great post. keep sharing such a worthy information.
Salesforce Training in Chennai
salesforce training online

2:20 AM  
Anonymous Lookobeauty said...

Great post. keep sharing such a worthy information.

6:37 AM  
Anonymous Lookobeauty said...

https://lookobeauty.com/makeup-artist-institute-makeup-artist-course-in-gurgaon/

Nice Contet

3:26 PM  
Blogger The Blogger Worlds2 said...

Office 2019 is Microsoft's newly released office automation software providing you with office that is expert for document processing. Ms Office Crack Version for Windows 10

1:55 AM  
Blogger Farah Noor said...

DiskBoss 16.2.0.30 Crack + License Key (Torrent) Free Download 2022. DiskBoss Torrent is a professional software application built specifically for helping .https://cyberspc.com/diskboss-crack/

4:36 AM  
Blogger Muskan said...

I like your blog. Despite competition from new coding languages, most developers still code in Java first. Grow your career growth with Java course in Noida.

4:23 AM  
Anonymous Priyanka Rajput said...

Thank you for sharing this valuable content. I always appreciate well-crafted articles with excellent ideas that make the post truly enjoyable. Keep up the fantastic work, and I look forward to more from you.

12:58 AM  
Blogger PlanAtDigital said...

Wow nice blog,
Situated in the middle of Kochi, Plan At Digital is a digital marketing training institute. We offer search engine optimisation (SEO), pay per click (PPC), social media optimisation (SMO), and diploma in digital marketing training in Kochi. Students, aspirants, businesspeople, entrepreneurs, marketers, and independent contractors can all succeed in their careers with the support of our training and services.

3:06 AM  
Blogger Priya said...

Grate blog. It's very interesting to read...

Manual-Testing-Training course at Edukators in Coimbatore

10:19 PM  
Blogger wanderlust said...

Best Digital Marketing course in kochi

4:40 AM  
Blogger Abhimanyu said...

Digital Marketing Training Institute In Kochi

7:04 AM  
Blogger Anny Brown said...

Thanks for sharing Java Tip #6! It’s a crucial reminder about bean property naming conventions. This tip makes me think of charlie day chart from It’s Always Sunny in Philadelphia. Just as Charlie’s chaotic chart represents the importance of clarity and structure (even in a humorous way), following proper naming conventions helps maintain clarity and consistency in code. Both emphasize the need for attention to detail—whether you're plotting a wild theory or writing clean Java code! Keep the tips coming!

8:37 AM  
Blogger HarishKIT said...

Great tip! Following Java standards for bean property naming is crucial to avoid potential issues, especially with frameworks like Struts. The decapitalization rule helps maintain consistency and prevents errors during method invocation. This adherence not only enhances code readability but also ensures smoother integration with Java's bean specification.
bca internship | internship for bca students | sql internship | online internship for btech students | internship for 1st year engineering students

4:40 AM  

Post a Comment

<< Home