javabeans - What is the convention with Java beans, and implementing interfaces like Comparable? -



javabeans - What is the convention with Java beans, and implementing interfaces like Comparable? -

java beans, far know, should always:

have empty constructor have fields, , getter/setter methods these fields.

however, wondering convention java beans implement interfaces comparable? leave java bean pure, meaning absolutely no behaviour, data, , write custom comparator-class. implementing comparable easier though.

are there conventions when comes implementing simple mutual interfaces comparable java beans? cannot find consequences myself, feels might breaking rules, , there might haven't thought of.

imho question not conventions needs.

you right separation of bean stuff business logic style. i'd add together here typically practice because relationship between beans , comparators many-to-many, i.e.

you hold several comparators 1 bean class , utilize them in different contexts sometimes can re-use 1 comparator several different classes or create hierarchy of comparators.

however right writing comparing logic class less verbose , in cases preferable. selection depends on author taste , requirements of application he/she working on.

java javabeans conventions comparable

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -