Abstract class naming convention

Do we have standard coding code that abstract class names have the Abstract prefix? eg.

 public abstract class AbstractB implements B {} 
+44
java coding-style
Jul 28 '11 at 15:37
source share
6 answers

Yes, in fact, if you look at the javadocs of the standard library at http://download.oracle.com/javase/6/docs/api/ , you will see that the list of classes in the lower left frame starts with abstract classes using the convention about the names mentioned in your question.

 AbstractAction AbstractAnnotationValueVisitor6 AbstractBorder AbstractButton AbstractCellEditor AbstractCollection AbstractColorChooserPanel AbstractDocument AbstractDocument.AttributeContext AbstractDocument.Content AbstractDocument.ElementEdit AbstractElementVisitor6 AbstractExecutorService AbstractInterruptibleChannel AbstractLayoutCache AbstractLayoutCache.NodeDimensions AbstractList AbstractListModel AbstractMap AbstractMap.SimpleEntry AbstractMap.SimpleImmutableEntry AbstractMarshallerImpl AbstractMethodError AbstractOwnableSynchronizer AbstractPreferences AbstractProcessor AbstractQueue AbstractQueuedLongSynchronizer AbstractQueuedSynchronizer AbstractScriptEngine AbstractSelectableChannel AbstractSelectionKey AbstractSelector AbstractSequentialList AbstractSet AbstractSpinnerModel AbstractTableModel AbstractTypeVisitor6 AbstractUndoableEdit AbstractUnmarshallerImpl AbstractWriter 

Take any of them, say the first, and check its definition: AbstractAction . It really implements Action , which again looks like your agreement. Subclasses are called such: ClosedAction , MaximizeAction , etc.

+62
Jul 28 '11 at 15:43
source share

As a rule, any type of standard is a good thing in setting up a team. Otherwise, team members can name classes in a way that only they understand, and then you can get a combination of different coding styles, which leads to confusion.

+11
Jul 28 '11 at 15:42
source share

For readability, this sounds good. When reading the code, you will immediately know what a class is. As long as everyone follows the standard, that's good.

+5
Jul 28 '11 at 15:41
source share

Modern IDEs will pop up descriptive text when hovering over an object. In this case, the prefix is ​​redundant.

+4
Jul 28 '11 at 15:43
source share

I will not say yay or nay in the answer, but whatever you choose, use a good static analysis tool to verify this.

+2
Jul 28 '11 at 3:45 a.m.
source share

As with most questions of this type: "it depends." I like the consistency and clarity, so if this works for you and your store, great. However, if you have legacy abstract classes, you'll want to go back and reorganize them into the same naming convention.

+2
Jul 28 '11 at 16:09
source share



All Articles