Page 4 of 4

Re: doAttack Method...

Posted: Fri Aug 02, 2013 3:39 pm
by lord_rex
Zoey76 wrote:
Don't "dude" me, I just gave you a proper answer from someone that has been doing this for a long time.

Provide a patch that actually proves the code is duplicated/useless and then we can continue talking about it.
telling same thing to you as I did to afk5min XD Leave him and answer to my PM xD

Re: doAttack Method...

Posted: Fri Aug 02, 2013 3:41 pm
by afk5min
SpooKNoF wrote:the point for null checks is THE NULL if somehting is null in 1 code how you will bypass it? we using 1 check for all methods
Sure, when you are the only developer, you can say that

'HO HO HO, merry xmas! this method does not need a null check, because all callers do a null check themselves! I know, because I wrote the code all by myself. Also, noone will ever add any code that violates these conditions, because I AM THE ONLY DEVELOPER'

Image

Re: doAttack Method...

Posted: Fri Aug 02, 2013 3:44 pm
by SpooKNoF
afk5min wrote:
SpooKNoF wrote:the point for null checks is THE NULL if somehting is null in 1 code how you will bypass it? we using 1 check for all methods
Sure, when you are the only developer, you can say that

'HO HO HO, merry xmas! this method does not need a null check, because all callers do a null check themselves! I know, because I wrote the code all by myself. Also, noone will ever add any code that violates these conditions, because I AM THE ONLY DEVELOPER'

Image

1 method call another method to continue the hit so if we will put the check on start so...

Re: doAttack Method...

Posted: Fri Aug 02, 2013 3:46 pm
by afk5min
SpooKNoF wrote:1 method call another method to continue the hit so if we will put the check on start so...
Honestly, I am tired of your whining, your broken english and the fact that you dismiss everyone who is trying to help you. That's why every time you post a message in this thread, I am going to reply with this:
Image

Re: doAttack Method...

Posted: Fri Aug 02, 2013 3:51 pm
by jurchiks
I believe this belongs in this thread:
Image
on point, I believe it's good to do the null checks only in the places where the parameters are used, so, for example, if a method simply passes a parameter to another method but doesn't use the value itself, no check is necassary.
But there are exceptions to this just like there are exceptions to everything else, for example, if you have a method designed to check parameters (doesn't use the values, just checks them and returns boolean).

Re: doAttack Method...

Posted: Fri Aug 02, 2013 4:15 pm
by SpooKNoF
So yes is ussules!
that is custom logs when i start to attack
AutoAnnoucements: Loaded 0 Auto Annoucement Data.
GameServer: Telnet server is currently disabled.
Registered on login as Server 1 : Bartz
L2CharacterAi onIntentionAttack System Check target: Spook.Gremlin
lets check that code...(onIntentionAttack)

Code: Select all

    @Override    protected void onIntentionAttack(L2Character target)    {        if (target == null) //First null check...        {            System.out.println("L2CharacterAi onIntentionAttack System Check null target: " + _actor.getName() + ".");            clientActionFailed();            return;        }                System.out.println("L2CharacterAi onIntentionAttack System Check target: " + _actor.getName() + "." + target.getName());
L2Character doAttack System Check target: Spook.Gremlin
lets check that code...(doAttack)

Code: Select all

protected void doAttack(L2Character target)    {                if (target == null) //second null check        {            System.out.println("L2Character doAttack System Check null target: " + getName() + ".");            return;        }        if (isAttackingDisabled() || !getEvents().onAttack(target))        {            return;        }                System.out.println("L2Character doAttack System Check target: " + getName() + "." + target.getName());
L2Character onHitTimer System Check target: Spook.Gremlin
lets check that code...(onHitTimer)

Code: Select all

public void onHitTimer(L2Character target, int damage, boolean crit, boolean miss, boolean soulshot, byte shld)    {        if (target == null) //third null check        {            System.out.println("L2Character onHitTimer System Check null target: " + getName() + ".");            getAI().notifyEvent(CtrlEvent.EVT_CANCEL);            return;        }                System.out.println("L2Character onHitTimer System Check target: " + getName() + "." + target.getName());
L2Character doAttack System Check target: Spook.Gremlin
L2Character onHitTimer System Check target: Spook.Gremlin
L2CharacterAi onIntentionAttack System Check target: Gremlin.Spook
L2Character doAttack System Check target: Gremlin.Spook
L2Character onHitTimer System Check target: Gremlin.Spook
//END THE SAME HERE..
L2Character doAttack System Check target: Gremlin.Spook
L2Character onHitTimer System Check target: Gremlin.Spook
L2Character doAttack System Check target: Gremlin.Spook

Re: doAttack Method...

Posted: Fri Aug 02, 2013 4:57 pm
by lord_rex
just do me a favor and run that:

Code: Select all

 /** * @author lord_rex */public final class PiffPuff{    public static void main(String[] args)    {        final SpooKNoF player = new SpooKNoF();                startSuffering(player);    }        static void startSuffering(final SpooKNoF player)    {        while (!player.hasSufferedEnough())            player.suffer();    }        static class SpooKNoF    {        public void suffer()        {            System.out.println("SpooKNoF is Suffering!");        }                public boolean hasSufferedEnough()        {            return false; // constant, never returns true        }    }} 

Re: doAttack Method...

Posted: Fri Aug 02, 2013 5:08 pm
by SpooKNoF
lord_rex wrote:just do me a favor and run that:

Code: Select all

 /** * @author lord_rex */public final class PiffPuff{    public static void main(String[] args)    {        final SpooKNoF player = new SpooKNoF();                startSuffering(player);    }        static void startSuffering(final SpooKNoF player)    {        while (!player.hasSufferedEnough())            player.suffer();    }        static class SpooKNoF    {        public void suffer()        {            System.out.println("SpooKNoF is Suffering!");        }                public boolean hasSufferedEnough()        {            return false; // constant, never returns true        }    }} 

you are bad :)

Re: doAttack Method...

Posted: Fri Aug 02, 2013 5:17 pm
by xban1x
null checks are more then usefull. what if that method sometime will be used directly and may be passed a null variable? then you will cry we got Npes.

Re: doAttack Method...

Posted: Fri Aug 02, 2013 5:23 pm
by lord_rex
xban1x wrote:null checks are more then usefull. what if that method sometime will be used directly and may be passed a null variable? then you will cry we got Npes.
everyone telling it to him for a week, but anyway good luck to explain him, but if I were u I woudn't waste my time with him... I just started the time wasting because he was breakin' my precious discussions with his stupid null checks :)

Re: doAttack Method...

Posted: Fri Aug 02, 2013 5:35 pm
by SpooKNoF
lord_rex wrote:
xban1x wrote:null checks are more then usefull. what if that method sometime will be used directly and may be passed a null variable? then you will cry we got Npes.
everyone telling it to him for a week, but anyway good luck to explain him, but if I were u I woudn't waste my time with him... I just started the time wasting because he was breakin' my precious discussions with his stupid null checks :)

dude come on you think you are good now because you say null check is usefull there?

its my opinion to say null check is ussules there so what did you try to explain me?

just open logs you will never use null check point in doAttack method..

Re: doAttack Method...

Posted: Fri Aug 02, 2013 5:37 pm
by lord_rex
SpooKNoF wrote:
lord_rex wrote:
xban1x wrote:null checks are more then usefull. what if that method sometime will be used directly and may be passed a null variable? then you will cry we got Npes.
everyone telling it to him for a week, but anyway good luck to explain him, but if I were u I woudn't waste my time with him... I just started the time wasting because he was breakin' my precious discussions with his stupid null checks :)

dude come on you think you are good now because you say null check is usefull there?

its my opinion to say null check is ussules there so what did you try to explain me?
1. saying same as Zoey, don't "dude me"
2. I am not "good", I am Divine.
3. you don't understand the whole way how developers work....

Re: doAttack Method...

Posted: Fri Aug 02, 2013 5:39 pm
by UnAfraid
I am not gonna remove that null check from there, not because current l2j code can cause NPEs but because all the community is applying patches which are not codded that good and they can get into NPE wall of errors because of that simple NPE removed check.
It doesn't causes any performance affections with/without u won't notice anything even with 10k players.
jurchiks already explain u few pages back that this is one of most light-weight checks that can be made.
We got so many null checks all over the code should we spend our time to remove them?
NO i wouldn't do that i got better things to do instead of wasting my time to change things that wouldn't matters at all.
Topic is closed.

@jurchiks, @lord_rex, @Zoey76 open new topic if u gonna continue your talk.