Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
The benefit of first style is IDE intelligence.
The benefit of second style is less methods to learn. -
@2lazy2debug never!!
constructors are to get necessary data requires to construct the object. -
// adds handler to server
Server.addHandler(new StringBuffer(„Handler“).toString());
So the next one who touches my code as to use his brain... -
kiki351886ySecond all the way. That’s functional.
To be honest, I prefer the special, greatest way on terms of conceptions:
add(server, “compressor”) -
Handlers are the modules handle request, response. Consider them as servlet, if you're Java user.
handlers, serializers, compressors,and other need to be added dynamically. -
@uyouthe server is a 3rd party library who knows how to add any components to them.
The way you suggested can be possible when user can modify server's code which is not recommended. -
@uyouthe I'm implementing the server in JavaScript or rather node.js.. no idea above Clojure
-
depends on the language. langs like elixir where you pattern matching in definition exist, i do 2, but more statically typed langs like rust, 1.
-
Finally I've added both options so user can choose whichever way they prefer.
I've also added directory scanning to add them automatically so both options can be avoided.
2 lines to build a server...
Related Rants
Which way you prefer to write code?
1.
server.addHandler(...)
server.addSerializer(...)
server.addCompressor(...)
...
2.
server.add("handler",...)
server.add("serializer",...)
server.add("compressor",...)
...
3. Both. (as per mood) :p
question
pattern
code