Are Java Beans as data storage classes bad design?

后端 未结 6 1530
挽巷
挽巷 2021-02-14 11:49

Usually JavaPractices.com is a good site with good idea\'s, but this one troubles me: JavaBeans are bad.

The article cites several reasons, mainly that the term JavaBea

6条回答
  •  梦如初夏
    2021-02-14 12:08

    "The JavaBeans pattern has serious disadvantages." — Joshua Bloch, Effective Java

    I love those guys. Taking arbitrary quotes out of context is already reason for me not to trust such article.

    BTW, referred book (Effective Java) has extensive discussion about both those models, their advantages, disadvantages and alternatives. You might want to check it out. But there's nothing inherently wrong with JavaBeans, just sometimes they are not the best choice.

    Edit: See item 2 ("Consider a builder when faced with many constructor parameters") in Effective Java on Google Books: http://books.google.com/books?id=ka2VUBqHiWkC&lpg=PP1&pg=PA11#v=onepage&q&f=false

提交回复
热议问题