Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class Naming Convention [closed]

As the size of my project becomes larger, I feel there should be a convention for class names that have similar functionality.

Let's assume that there are three data handlers having similar functionality, and the only difference is the data type they handle.

There is interface DataHandler.

interface DataHandler

There are three different types of data, Bitmap, Video, and Sound.

Which option is more widely-used naming convention?

Option 1.

class BitmapHandler

class VideoHandler

class SoundHandler

Option 2.

class DataHandlerBitmap

class DataHandlerVideo

class DataHandlerSound

I am currently using option 1 since it sounds better, but I think using option 2 also has advantages, especially the size of project is large. I can easily check how many data handlers exists by sorting class names alphabetically, and it also makes people can easily figure out and use all similar type of classes using IDE's intellisense.

EDITED

I removed c# tag. I couldn't think that C# and Java have different naming conventions.

like image 674
Heejin Avatar asked Mar 16 '26 09:03

Heejin


1 Answers

First of all, the naming convention for an interface would be

IDataHandler

Then, your classes should be:

class BitmapDataHandler
class VideoDataHandler
class SoundDataHandler

In any case, I believe option #2 is not so relevant; in order to discover classes in your project use the Find all References command (for example, if you don't use ReSharper which makes things much more easier).

like image 98
Ofer Zelig Avatar answered Mar 19 '26 00:03

Ofer Zelig