The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

harrylaou (2) [Avatar] Offline
#1
Is it a good idea to include return types in all sample code?

for example

def getMarketValue(e: Equity, a: BigDecimal) = //..
def getAccruedInterest(i: String) = //..

to become

def getMarketValue(e: Equity, a: BigDecimal) :XXX= //..
def getAccruedInterest(i: String):XXX = //..


For me it is always clearer when I read code , I get the function signature at once.
Debasish Ghosh (116) [Avatar] Offline
#2
At least for public API I think it's an essential practice to include the return types. For some very obvious methods they may be omitted, but a must for non trivial methods. I have a plan to include all of them before the book is released. Marking this post as an issue on Github.

Thanks.