Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename API entry point #10

Closed
drapostolos opened this issue Apr 16, 2014 · 5 comments
Closed

Rename API entry point #10

drapostolos opened this issue Apr 16, 2014 · 5 comments

Comments

@drapostolos
Copy link
Owner

@Elisedlund suggested to change the API entry point from StringToTypeParser to something else. Since library is called type-parser it feels more intuitive to call the entry point TypeParser.

However, the problem with that is: There already is an interface called TypeParser... so what to do?

There are a few suggestions:

  • Prefix the interface with "I" as in ITypeParser and rename StringToTypeParser to TypeParser
  • Rename TypeParser interface to TypeParserHandler and rename StringToTypeParser to TypeParser.
  • Rename StringToTypeParserBuilder to TypeParserBuilder.
  • Rename StringToTypeParserBuilder to TypeParserFactory.
  • Rename StringToTypeParser to TypeParser and rename TypeParser to StringToTypeParser.

Any other suggestions?

I'm leaning towards the last one, with the motivation that the API entry is the actual usage (and visible in code), while the TypeParser interface will not be used at all by some (i.e. default TypeParser are enough). I.e. keep the most used as short/simple as possible.

Usage example:

TypeParser parser = TypeParser.newBuilder()  
 .setsplitStrategy(SplitStrategy)  
 .registerTypeParser(StringToTypeParser)  
 .setInputPreprocessor(InputPreprocessor)  
 .build()
@drapostolos
Copy link
Owner Author

API entry class has been re-named as below (a non-backward compatible change) and pushed to the master branch.

Usage example:

TypeParser parser = TypeParser.newBuilder()  
 .setsplitStrategy(SplitStrategy)  
 .registerTypeParser(Class<?>, StringToTypeParser)  
 .registerTypeParserForTypesAssignableTo(Class<?>, StringToTypeParser)  
 .setInputPreprocessor(InputPreprocessor)  
 .build()

Will be available in v0.2.0

@Elisedlund
Copy link

Looks a lot better.

Other possible changes:
StringToTypeParserHelper could be renamed to TypeParserHelper/ParserHelper

Still don't like StringToTypeParser even on the interface could it be renamed to just Parser?
or is it to short/generic.

@drapostolos
Copy link
Owner Author

I was thinking the same about Parser being too generic. But I think we should go for that anyway :)

Which gives ParserHelper and

TypeParser parser = TypeParser.newBuilder()  
 .setsplitStrategy(SplitStrategy)  
 .registerParser(Class<?>, Parser)  
 .registerParserForTypesAssignableTo(Class<?>, Parser)  
 .setInputPreprocessor(InputPreprocessor)  
 .build()

+1 from me

@drapostolos
Copy link
Owner Author

Renaming the StringToTypeParser interface to just Parser has been pushed to master.

@Elisedlund
Copy link

Nice.
Looks a lot cleaner!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants