Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Naming convention for Delphi Interface Units [closed]

Is there a widely used naming convention for Delphi units that contain only interface definitions?

I'm asking specifically if anything exists that has become a widespread convention in the Delphi community. I am not asking for your opinion on what is a good convention, or even necessarily what you use personally. Your answer needs to demonstrate that what you describe is a widespread convention by saying where you've seen it used.

To illustrate the question more clearly I'll describe my organisation's homegrown convention and why I'm not satisfied with it: If a class is called TFoo, then its unit would be called uFoo. An interface implemented by TFoo would probably be called IFoo, but obviously I can't save this unit as iFoo because the interface already has that name.

In other words, I'm trying to complete this grid:

+--------+---------------+---------------+
!        !  Class        !  Interface    !
+--------+---------------+---------------+
!        !               !               !
! Name   !  TFoo         !  IFoo         !
!        !               !               !
+--------+---------------+---------------+
!        !               !               !
! File   !  uFoo.pas     !  ????.pas     !
!        !               !               !
+--------+---------------+---------------+

Updated on 19 March 2014 to make it clearer that I'm looking for fact-based (not opinion-based) answers.

like image 988
Ian Goldby Avatar asked Sep 03 '25 02:09

Ian Goldby


2 Answers

I would use Foo_Intf for the file name. I have seen RemObjects use it when it automatically generates units. I think the programmers I worked with picked it up from RO and I picked it up from them. It makes sense to me since it makes finding the interfaces easy.

like image 114
Sentient Avatar answered Sep 05 '25 00:09

Sentient


I would use uFooAPI.pas for the unit declaring the abstract interface. It's my own convention.

like image 37
SpeedFreak Avatar answered Sep 05 '25 01:09

SpeedFreak