java - Service s = new ServiceImpl() - Why you are doing that? -


i read article service s = new serviceimpl() - why doing that?

would know views it.. wondering name other impl?

impl suffixes naming anti-pattern. denotes lack of effort on developers part descriptively name class. flip side of iservice interface naming anti-pattern well. both practices reek of laziness or poor design choices or both. both code smells, should alert developer isn't right.

the fact code says interface service , class myservice implements service should enough, else tautology. more today's advanced java ides.

if have service interface, name implementations descriptively. service generic, interfaces good. httpservice, authenticationservice specific classes good. self documenting part in both cases.

if can't give unique descriptive names interfaces , classes, doing wrong.

in mocking argument, assuming real classes in com.company.app.service. mock implementations should in own com.company.app.service.mock package, in different directory structure test classes, in maven, allow them have same names non-mock classes, , still document mocks testing only, , not pollute name space of production code , make easy not-include code in deployment.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -