Giter VIP home page Giter VIP logo

Comments (8)

schlessera avatar schlessera commented on August 16, 2024 6

I recently wrote a blog post about this: https://www.alainschlesser.com/interface-naming-conventions/

TL;DR:
Interface suffix (or prefix) is an unnecessary form of Hungarian Notation, and actually severely limits your architecture (by making it impossible to replace classes with interfaces later on, because their nature is encoded in their name). This forces you to proactively put interfaces everywhere to not cause a lock-in to a specific architecture.

from php-ddd.

Wirone avatar Wirone commented on August 16, 2024 2

For long time I've agreed with prefix/suffix like in Symfony or PSR naming conventions but recently I've changed my mind and I think exactly like @schlessera. You don't need to put Interface in name because there IS information that this is interface (the same goes for traits). IDE will display it too. The only thing I accept now is Abstract prefix for abstract classes, but I think it's possible I'll drop it too.

You don't introduce yourself JohnName SmithSurname ;-)

from php-ddd.

webdevilopers avatar webdevilopers commented on August 16, 2024 1

Upcoming PHP BC Break: PSR and all frameworks will remove Interface suffix and Abstract prefix from their naming conventions by default.

...Couldn't wait until April fools!

from php-ddd.

Wirone avatar Wirone commented on August 16, 2024 1

But PSR-8 doesn't use Interface suffix.

from php-ddd.

mablae avatar mablae commented on August 16, 2024

Hey @webdevilopers,

I personally go with the Symfony naming scheme aka ClientInterface.

from php-ddd.

webdevilopers avatar webdevilopers commented on August 16, 2024

Generally - even in your Domain Model namespace? Or just inside the bundles?

from php-ddd.

nilportugues avatar nilportugues commented on August 16, 2024

I drop the Interface and place all interfaces inside Contracts directory.

from php-ddd.

Wirone avatar Wirone commented on August 16, 2024

There is topic on PHP-FIG mailing group about changing conventions in PSRs (only future ones), but it's dead without conclusion.

Nobody expects such BC break, but for any new software it's not the only way of naming.

from php-ddd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.