No I see no problem with your approach ;)
But inlining other examples (although possible) is not so simple (and
produce a bit of unreadable code):
for(...) {
if (condition) return a;
}
doSomething();
return b;
or:
if (a) {
doSomething();
if (b) return c;
else notB();
doAnotherThing();
}
doSomethingElse();
return d;
And there are many more examples of code like this ;)
So while spending a little time identifying some simple structures that
can be inlined can be profitable, I don't think it's worth spending to
much time over this issue.
Carlos
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: quinta-feira, 14 de Mar�o de 2002 17:21
> To: [EMAIL PROTECTED]
> Subject: RE: [Eap-list] Inline Method with "returns interrupting the
> control flow" error
>
>
> You are right! Never write emails when your wife is asking you to go
> home NOW ;-)
>
> I guess when you analyze FURTHER ( ;-P ) my code block
> if (i < 0) return 0;
> ....
> return i;
>
> You have a decision point and 2 sub blocks:
>
> if (i < 0) {
> return 0;
> }
> else {
> ....
> return i;
> }
>
> Then is clearer what to do in the refactoring
>
> public int foo(int i) {
> int res = 0;
> if (i < 0) {
> res = 0;
> }
> else {
> ....
> res = i;
> }
> return res;
> }
>
> I am sure I can trust Carlos to tell me if I made a fool of
> myself AGAIN
> ;-)
>
> Jacques
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> On Behalf Of Carlos Costa e Silva
> Sent: Wednesday, March 13, 2002 3:17 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [Eap-list] Inline Method with "returns interrupting the
> control flow" error
>
>
> > Am I missing something?
>
> Yes :)
>
> > public int foo(int i) {
> > return bar(i);
> > }
> >
> > private int bar(int i) {
> > if (i < 0) return 0;
> > return i;
> > }
>
> foo(-3) -> 0
>
> >
> > public int foo(int i) {
> > int res = 0;
> > if (i < 0) res = 0;
> > res = i;
> > return res;
> > }
> >
> >
>
> foo(-3) -> -3
>
> Carlos
>
>
> --
> Carlos Costa e Silva <[EMAIL PROTECTED]>
>
>
> _______________________________________________
> Eap-list mailing list
> [EMAIL PROTECTED]
> http://www.intellij.com/mailman/listinfo/eap-list
>
>
> _______________________________________________
> Eap-list mailing list
> [EMAIL PROTECTED]
> http://www.intellij.com/mailman/listinfo/eap-list
>
_______________________________________________
Eap-list mailing list
[EMAIL PROTECTED]
http://www.intellij.com/mailman/listinfo/eap-list