4 ms·
From: https://angular.io/styleguide#!#style-03-03 https://angular.io/styleguide#!#style-03-03 > Consider naming an interface without an I prefix. They give th
by robotnoises 10y ago
From: https://angular.io/styleguide#!#style-03-03 https://angular.io/styleguide#!#style-03-03
> Consider naming an interface without an I prefix.
They give the same recommendation in the Typescript style guide, but I still don't understand why.
- netinstructions 10y agoThis is a common discussion I see on the internet[0][1][2][3]. Paraphrased below You shouldn't need to know whether the client is using an interface or an implementation class. List represents a list, and a User represents a user - not an IUser. Another problem with using I, is that (oddly) we use it to communication the implementation decision of using an interface. Usually we don't want implementation decisions expressed so loudly, because that makes them hard to change. [0]http://programmers.stackexchange.com/questions/117348/should-interface-names-begin-with-an-i-prefix http://programmers.stackexchange.com/questions/117348/should... [1]http://stackoverflow.com/questions/541912/interface-naming-in-java http://stackoverflow.com/questions/541912/interface-naming-i... [2]http://stackoverflow.com/questions/5816951/prefixing-interfaces-with-i http://stackoverflow.com/questions/5816951/prefixing-interfa... [3]https://blogs.msdn.microsoft.com/brada/2004/02/03/why-do-interface-names-begin-with-i/ https://blogs.msdn.microsoft.com/brada/2004/02/03/why-do-int...
- robotnoises 10y agoExcellent reply, thank you. To me, it still seems more about people's gripe over the very existence of interfaces. If anything, using IUser in lieu of User is a pretty clear signal to, say, an uninitiated developer, that you shouldn't be attempting to create an instance of "IUser."