addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcredit-cardcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobe--smallglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1launch-new-window--smalllight-bulblinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Re: [ljc] Return types

From: Ged B.
Sent on: Wednesday, February 13, 2013 9:27 AM
Hi Jon,

Satire aside, the JSR should be for the "result self pattern".

By default void methods should return self, so that they can be used in method chains as part of a fluent interface.



Regards, 


Ged



On 12 February[masked]:14, Jonathan McNealy <[address removed]> wrote:
Hi guys,

We've been debating this for a while here, and we can't decide between the following two development methodologies with respect to the return statement.

It's currently policy to write functions that don't return a value like this:

public Void doTask() {
  ...

  return null;
}

this is best because:
- everything should be an object (Integer instead of int, and so on)
- it's type-safe
- reflection is more consistent, as the primitive/object difference api is a pain
- allows multiple calls on one line (saving vertical space, e.g. return runStuff(doTask()))

however some of the newcomers to the company are rather dismissive of the benefits of Void, and insist of the following nasty and inconsistent way of doing it:

public void doTask() {
  ...

  return;
}

and some deviants even insist on removing the return statement:

public void doTask() {
  ...
}

!!

I'm currently in the process of writing up a JSR to only support the Void/return null pattern, as it's clearly the most consistent and only having one way of doing something is the best approach, however I'm curious as to what the community thinks about the issue.

Please don't cheat by casting your vote more than once!

Kind regards

J.





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Jonathan McNealy ([address removed]) from LJC - London Java Community.
To learn more about Jonathan McNealy, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy