Re: Quick inheritence question
On 4 Jan, 16:28, Jason Cavett <jason.cav...@gmail.com> wrote:
On Jan 4, 10:46 am, andymconl...@googlemail.com wrote:
Hello all,
Would the following be considered bad practice...
I have a very simple bean called "SimpleTypeBean" which is constructed
as follows:
public class SimpleTypeBean {
private long id;
private String description;
public SimpleTypeBean() {
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
I then need to declare a very similar bean (in fact, it is identical
in terms of data types), except one of the identifiers is called lob
not id, so I have done the following:
public class LobBean extends SimpleTypeBean {
public LobBean() {
}
public long getLob() {
return super.getId();
}
public void setLob(long lob) {
super.setId(lob);
}
}
Is this considered bad practice or is this what I should be doing?
Many Thanks
Andy
Something I also missed...
Having "setLob" and "getLob" does NOT hide "setId" and "getId." So,
if someone is using your beans, it could be very confusing to the
differences of what an lob is and what an id is.
Thanks Jason. I think I will just remove LobBean and go with
SimpleTypeBean
Kind Regards
Andy