Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


[Share] Graph PP filter_list
Author
Message
RE: [Share] Graph PP #11
Quote:I thought they meant the same thing. When are we suppose to use empty string assignments and when are we suppose to use null assignments? Could you explain that to me?

String name = null means that you don't initialize anything at all, where as using "" would mean that it would mean that it would check for some string data within the quotes and that general gives you a warning "String cannot be left empty" or something equivalent.

Using "" means that you are creating a reference object of size 0.
using null means that you create no object.

So, did you get it ?

Why create even a single useless object.

Quote:I think if I dispose instead of exiting when I hit the close button, the jvm process would not stop after i expect it to, right?

Read this : http://www.hackcommunity.com/Thread-Java...#pid162671

Quote:I have been suggested that in past too. I guess I'll have to make a habit of it. I don't know why, I find Listeners more neater that Adapters.. :Laughing:

You see I have been taught that programming is an art and the your pc or laptop is your canvas. If you use extra colors and try to make it more brighter then it might have some negetive effects such as the color might went off the line which would make it look less beautiful. Your PC is like your girl why do you intend to put more more burden on it by letting it execute more lines of codes, just let her enjoy. So, I hope you understood. Also it is a good programming practice to avoid writing unnecessary methods.

I liked the way you have used the math to get your things done. I can evaluate very well what you have hiding inside you.

Quote:Strangely I never experienced that before. I updated a line in the code and now it should work fine in that department.


Thank you very much for taking time to go through my code. I'll keep your suggestions in mind while coding. :Smile:


No Need to thank me, it was my pleasure help you if I can in any manner. I was taught by someone and know I can pass that onto others. Even its a part of my learning too.
[Image: OilyCostlyEwe.gif]

Reply

RE: [Share] Graph PP #12
Quote:I thought they meant the same thing. When are we suppose to use empty string assignments and when are we suppose to use null assignments? Could you explain that to me?

String name = null means that you don't initialize anything at all, where as using "" would mean that it would mean that it would check for some string data within the quotes and that general gives you a warning "String cannot be left empty" or something equivalent.

Using "" means that you are creating a reference object of size 0.
using null means that you create no object.

So, did you get it ?

Why create even a single useless object.

Quote:I think if I dispose instead of exiting when I hit the close button, the jvm process would not stop after i expect it to, right?

Read this : http://www.hackcommunity.com/Thread-Java...#pid162671

Quote:I have been suggested that in past too. I guess I'll have to make a habit of it. I don't know why, I find Listeners more neater that Adapters.. :Laughing:

You see I have been taught that programming is an art and the your pc or laptop is your canvas. If you use extra colors and try to make it more brighter then it might have some negetive effects such as the color might went off the line which would make it look less beautiful. Your PC is like your girl why do you intend to put more more burden on it by letting it execute more lines of codes, just let her enjoy. So, I hope you understood. Also it is a good programming practice to avoid writing unnecessary methods.

I liked the way you have used the math to get your things done. I can evaluate very well what you have hiding inside you.

Quote:Strangely I never experienced that before. I updated a line in the code and now it should work fine in that department.


Thank you very much for taking time to go through my code. I'll keep your suggestions in mind while coding. :Smile:


No Need to thank me, it was my pleasure help you if I can in any manner. I was taught by someone and know I can pass that onto others. Even its a part of my learning too.
[Image: OilyCostlyEwe.gif]

Reply

RE: [Share] Graph PP #13
Nice project you have started there. Kudos.

Code:
emphasized=false;
x=0;
y=0;

Code:
public Edge() {
        weight=0;
        source=null;
        destination=null;
        emphasize=false;
    }

This is superfluous. Class properties (unlike local variables) have default values. In all of these cases you assign the default values again.

See here for a list of the default values:
http://docs.oracle.com/javase/tutorial/j...types.html

For the same reason name = null; would be superfluous too.



Code:
public void setEmphasized() {
    emphasized=true;
}
public void removeEmphasize() {
    emphasized=false;
}

The Java way of doing this would be:

Code:
public void setEmphasized(boolean b) {
    emphasized = b;
}

There is no need for two methods.



Code:
public ArrayList<Edge> getDestList() {
    return destList;
}

Return a copy of the list to avoid modifications by other classes.
Test it out, if you return the original list, you don't have any encapsulation, another class can just modify it and it will be modified in your instance too.

Also: It's not important if the implementation of the list is an ArrayList or something else, so use the more general List interface.

Code:
public List<Edge> getDestList() {
    return new ArrayList(destList); //returns a copy
}

Same applies to getAllEdgesList() and getSrcList()



The methods paint() and mousePressed() are far too long and nested too much. Do some refactoring, extract methods, maybe classes to get this more clean and better readable.

It is also weird that the JPanel creates it's own container (the JFrame). Usually you would have the JFrame create it's contents.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: [Share] Graph PP #14
Nice project you have started there. Kudos.

Code:
emphasized=false;
x=0;
y=0;

Code:
public Edge() {
        weight=0;
        source=null;
        destination=null;
        emphasize=false;
    }

This is superfluous. Class properties (unlike local variables) have default values. In all of these cases you assign the default values again.

See here for a list of the default values:
http://docs.oracle.com/javase/tutorial/j...types.html

For the same reason name = null; would be superfluous too.



Code:
public void setEmphasized() {
    emphasized=true;
}
public void removeEmphasize() {
    emphasized=false;
}

The Java way of doing this would be:

Code:
public void setEmphasized(boolean b) {
    emphasized = b;
}

There is no need for two methods.



Code:
public ArrayList<Edge> getDestList() {
    return destList;
}

Return a copy of the list to avoid modifications by other classes.
Test it out, if you return the original list, you don't have any encapsulation, another class can just modify it and it will be modified in your instance too.

Also: It's not important if the implementation of the list is an ArrayList or something else, so use the more general List interface.

Code:
public List<Edge> getDestList() {
    return new ArrayList(destList); //returns a copy
}

Same applies to getAllEdgesList() and getSrcList()



The methods paint() and mousePressed() are far too long and nested too much. Do some refactoring, extract methods, maybe classes to get this more clean and better readable.

It is also weird that the JPanel creates it's own container (the JFrame). Usually you would have the JFrame create it's contents.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: [Share] Graph PP #15
Nice project you have started there. Kudos.

Code:
emphasized=false;
x=0;
y=0;

Code:
public Edge() {
        weight=0;
        source=null;
        destination=null;
        emphasize=false;
    }

This is superfluous. Class properties (unlike local variables) have default values. In all of these cases you assign the default values again.

See here for a list of the default values:
http://docs.oracle.com/javase/tutorial/j...types.html

For the same reason name = null; would be superfluous too.



Code:
public void setEmphasized() {
    emphasized=true;
}
public void removeEmphasize() {
    emphasized=false;
}

The Java way of doing this would be:

Code:
public void setEmphasized(boolean b) {
    emphasized = b;
}

There is no need for two methods.



Code:
public ArrayList<Edge> getDestList() {
    return destList;
}

Return a copy of the list to avoid modifications by other classes.
Test it out, if you return the original list, you don't have any encapsulation, another class can just modify it and it will be modified in your instance too.

Also: It's not important if the implementation of the list is an ArrayList or something else, so use the more general List interface.

Code:
public List<Edge> getDestList() {
    return new ArrayList(destList); //returns a copy
}

Same applies to getAllEdgesList() and getSrcList()



The methods paint() and mousePressed() are far too long and nested too much. Do some refactoring, extract methods, maybe classes to get this more clean and better readable.

It is also weird that the JPanel creates it's own container (the JFrame). Usually you would have the JFrame create it's contents.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: [Share] Graph PP #16
@Psycho_Coder and @Deque
Thank you very much for going through my code and explaining me things I didn't know prior to this. I really appreciate it.
Confusedmile:
Folow me on My YouTube Channel if you're into art.

Reply

RE: [Share] Graph PP #17
@Psycho_Coder and @Deque
Thank you very much for going through my code and explaining me things I didn't know prior to this. I really appreciate it.
Confusedmile:
Folow me on My YouTube Channel if you're into art.

Reply

RE: [Share] Graph PP #18
@Psycho_Coder and @Deque
Thank you very much for going through my code and explaining me things I didn't know prior to this. I really appreciate it.
Confusedmile:
Folow me on My YouTube Channel if you're into art.

Reply

RE: [Share] Graph PP #19
@Psycho_Coder and @Deque
Thank you very much for going through my code and explaining me things I didn't know prior to this. I really appreciate it.
Confusedmile:
Folow me on My YouTube Channel if you're into art.

Reply

RE: [Share] Graph PP #20
This is pretty nice, Judging from the image, it would be good if you could make it into a more functional FLOW CHART generator or maker (Whatever you think is correct).
My Blog: http://www.procurity.wordpress.com
Donations: 1HLjiSbnWMpeQU46eUVCrYdbkrtduX7snG

Reply







Users browsing this thread: 1 Guest(s)