Is it a bad practice to have multiple classes in the same file?

I think you should try to keep your code to 1 class per file.

I suggest this because it will be easier to find your class later. Also, it will work better with your source control system (if a file changes, then you know that a particular class has changed).

The only time I think it’s correct to use more than one class per file is when you are using internal classes… but internal classes are inside another class, and thus can be left inside the same file. The inner classes roles are strongly related to the outer classes, so placing them in the same file is fine.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)