Hi, I've created a class for a bug tracking app, it's called Bug. Bug has some properties like ID, author, dateadded, etc. It also has a validate method, which checks for values being present before it can enter the bug in a DB. That's all fine... then I created another class, an extension of Bug, called Comment. Comment is for programmers to comment on the progress of the bug. It has properties like ID, author, dateAdded, etc, as well as a validate method. A Bug can have a vector of comments. I had some trouble tracking down a scope-related error because I had accidentally crossed up some variable names between the two classes. I was wondering if anyone has some general Java advice for correctly dealing with/naming variables in an extended class. Should I simply preface all the variables and methods within Comment with "cmt" or something like that, or is there a more elegant way. My instinct says to do that, because I will then be able to use those same names in HTML forms. But I was just wondering if there is a better way of doing it? thanks Zman
Some people use a prefix for the different type of variables. So a class variable could have a prefix of "m_", a parameter variable could have a prefix of "p_" and local variables not have any. Having a prefix (or some other type of identifier) for variables in a subclass wouldn't be a good idea. I don't think that you would want to jump though hoops to name your variables for the small number of times you have errors with scope. You should write your code with the assumption that it isn't going to break. (Maybe a more detailed example of the problem you are having would be helpful.)
Please ignore post, I have no idea what I am talking about.