B Sleek

Greenhorn
+ Follow
since Mar 02, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by B Sleek

Anyone using Antlr for parsing? I am building an application with a limited command set (maybe 100 commands). Should I be using Antlr? How much performance cost is their in a large if statement?
Bill -

That looks promising. I will research the Decorator Pattern.

Thanks for everyone's help.
19 years ago
Interesting approach. I'm a little scared about redesigning my base objects though. I'll have to carefully examine my design, to look for other approaches.



Thus, to "promote" an object, the underlying struct size would have to change. Java doesn't do this. Period. Could it? possibly. Is is necessarily a good idea? Maybe, but probably not.




I don't necessarily care if the structure changes...Why not just provide a way to create a NEW object with the values initialized to any base object, because the NEW structure will already have "room" for these values (class inherits structure). At this time you could just dispose the OLD object.
19 years ago
I understand that I could add behavior to my base class by wrapping the object but that does not help me add NEW data to the objects. A ball is not a Football. You can throw both the balls, true, but all balls won't have "seems" etc.

I'll accept the fact that this can't be done the way I want to do it, and is not a scenario that comes up everyday. However I am still struggling to see WHY the instance data belonging to my parent class can not be inherited to child objects. I'll be happy if I knew there is some low level language obstacle that prevents this, or there is an effective alternative method, or a good reason never to do this.
19 years ago
Joel-

My base objects have functionality over a certain lifetime some of them may never become objects belonging to the subclass. What I am trying to avoid is re-initializing the instance data of my base objects. The main reason is that subsequent changes to my base class will require ALL my object conversions to change.
19 years ago
Stefan-

Suppose hypothetically ball's had their own behavior, and only certain types of balls would be eligible to become "specialized" balls. At that time they would still keep their characteristics as ball objects.

*Kicks himself for poor name choice of base class*
19 years ago


You could create a constructor that takes a reference to the original object but it would still have to explicitly initialize all the variables.



Isn't this redundant?

I mean if I my base class is clearly defined why must "promoting" my object be so round-a-bout?
19 years ago
I would like to create a new object by converting an object of a base class to the type of a sub class.

For instance, if I have the below classes... If I want to create a Ball object before I know what type of ball it is. How would I create a football from the ball without having to explicitly set all my base class member data again.

Super() seems like no help because I still have to either provide an overloaded constructor, or explicity reset my instance data.


[ December 13, 2004: Message edited by: B Sleek ]
19 years ago
How would I write a write a web service that returns this response? Should I just create a single object to encapsulate the date, or what? Thanks for help.

19 years ago
Would someone please explain the correct answer to this question?
4. Does every Java variable use a data type?
a. No---only numeric variables use data types.
b. No---data types are optional.
c. Yes---all variables are of the same data type.
d. Yes---each variable must be declared along with its data type.
The answer is b. Could someone give an example? Thank you!
20 years ago
I find this confusing as well. Would a2 then be of type Cat or of type Animal? Would it have access to all members (if more existed) of the Cat class or just overriden methods?