Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

User Created Methods/Classes

 
P. Sagdeo
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly what is a user created method/class?

Can a user created class extend a non user-created one (i.e. extends JApplet). Likewise, can a user created class implement anything? Is actionPerformed a user-created class (you put the contents in, but essentially its from the ActionListener interface, non user-created.

Sorry if I'm sounding redundant or just plain weird,
Parth
 
P. Sagdeo
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone perhaps give a definition?
Thanks again,
Parth
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"User created XXX" is not a formal (or informal) concept in Java, so I think it would be hard to give you a definition. It's just a couple of English words, which presumably mean "a class (or method) written by the user."

Maybe if you gave us some context -- i.e., where you came across this term and why you need it to be clarified -- we could help more. But as it is, it's tautological at best.
 
P. Sagdeo
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, its all about what we've been learning in school. Generally, there hasn't been that much of an explicit definition. Obviously, a class that does not implement or extend anything, whether or not it uses methods not created by the same programmer is user-created, and obviously the instantiation of say, JFrame is totally non user-created. However, there are some things that seem to be borderline. The main example I was thinking of was actionPerformed. My dilemma is that the basis for this method was not fully written by me, but the actual meaningful content was. I'm leaning toward the direction of actionPerformed is a user-created mthod, as is something extending JPanel, as long as it is different from the original, but the instantiation of JFrame in the form of JFrame j=new JFrame(); is not. Just needed a more professional opinion on the topic.
Thanks,
Parth
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EVERY class extends Object (either directly or indirectly) whether you create it, the person next to you, or someone at Sun.
Even classes James Gossling create extend Object.

That should answer your second question.

If classes you create couldn't implement interfaces or extend other classes they'd be pretty useless right?
And so would those interfaces which after all are there to be implemented by someone.
That should answer your third question.

As to "user created", everyone is a user. Even the people writing the core APIs are users.
That should answer your first question.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"User Defined Types" rings a bell. Is that an official term in C or C++ or something? The ability to define your own types - classes and interfaces and the like - is a key bit of coolness in the whole OO world. It's so fundamental that we don't even think about it. Pretty much everything we write must be in a user defined class of some kind.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Stan James:
"User Defined Types" rings a bell. Is that an official term in C or C++ or something?


It rings a pretty old and creaky bell, now that you mention it. C++ people used to use this term, back in the dark ages before there was a standard library. The more modern term for the same concept is "abstract data type", or ADT; again, for the same reason as Jeroen described: because there's no useful distinction between classes written by a "user" and the standard library classes.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
UDT stems from C where you have built-in types and compound types you define yourself (records).
It's also used in other languages.

In Java and other OO languages where types defined by end users plug into the same object hierarchy as those defined by the language creators there is no such distinction.
Java might be a special case if you consider everything except the primitives to be UDTs, part of which happen to be shipped by the same people that bring the built-in types.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic