Who can write a good paragraph that explains static and instance ? -
for the beginning NetRexx programmer who wonders why (s)he now has to define a class, and create an instance of it in method main to use the parts that are not static. Maybe also from the perspective of the Java programmer who does, at first sight, not have to do this. I remember back in '97 that this baffled me at first but it soon became a standard part of the cargo-cult programming routine we all go through. But I think a concise explanation at the right level still could be an asset for the Users Guide. best regards, René. _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Rene, try this:
At the factory they have a blueprint for a "class" of car. There is only one and it defines the car. Many cars are alike and "inherit" from the basic car blueprint, things like having four wheels. At the dealer they have many "instances" of each class of cars. There is a stitch in time, a thread, when each car object is created at the factory. When the car expires or is no longer useful it is moved to the garbage heap by the collector and it's thread ends. Cars can have options that may not have been on the blueprint by "extending" a class. "Getter and Setter" methods are like switches on the car that turn the lights on and off. Then you just need a cpu with enough gas... -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of rvjansen Sent: Monday, March 26, 2012 7:11 AM To: IBM Netrexx Subject: [Ibm-netrexx] static and instantiation Who can write a good paragraph that explains static and instance ? - for the beginning NetRexx programmer who wonders why (s)he now has to define a class, and create an instance of it in method main to use the parts that are not static. Maybe also from the perspective of the Java programmer who does, at first sight, not have to do this. I remember back in '97 that this baffled me at first but it soon became a standard part of the cargo-cult programming routine we all go through. But I think a concise explanation at the right level still could be an asset for the Users Guide. best regards, René. _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Mike,
yes, I think this is a good analogy of the 'cookie cutter' metaphore. I had a lingering memory that for NetRexx, other than Java in its own syntax, this instantiation is required every time and that they were different. Now looknig through some Java examples, I think that the Java I did before NetRexx either did everything out of 'main' with static methods, or that I just missed those instantiations because in Java, you can instantiate using the class name itself but starting with a lowercase. For clarity, I'll add the example to the Users Guide. In any case, thank you very much. best regards, René. On 2012-03-26 15:38, Measel, Mike wrote: > Rene, try this: > > At the factory they have a blueprint for a "class" of car. There is > only one and it defines the car. Many cars are alike and "inherit" > from the basic car blueprint, things like having four wheels. > > At the dealer they have many "instances" of each class of cars. > > There is a stitch in time, a thread, when each car object is created > at the factory. > > When the car expires or is no longer useful it is moved to the > garbage heap by the collector and it's thread ends. > > Cars can have options that may not have been on the blueprint by > "extending" a class. > > "Getter and Setter" methods are like switches on the car that turn > the lights on and off. > > Then you just need a cpu with enough gas... > > -----Original Message----- > From: [hidden email] > [mailto:[hidden email]] On Behalf Of rvjansen > Sent: Monday, March 26, 2012 7:11 AM > To: IBM Netrexx > Subject: [Ibm-netrexx] static and instantiation > > Who can write a good paragraph that explains static and instance ? - > for the beginning NetRexx programmer who wonders why (s)he now has to > define a class, and create an instance of it in method main to use > the > parts that are not static. Maybe also from the perspective of the > Java > programmer who does, at first sight, not have to do this. > > I remember back in '97 that this baffled me at first but it soon > became > a standard part of the cargo-cult programming routine we all go > through. > But I think a concise explanation at the right level still could be > an > asset for the Users Guide. > > best regards, > > René. > > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] > Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ > > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] > Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
> yes, I think this is a good analogy of the 'cookie cutter'
> metaphore. I had a lingering memory that for NetRexx, other > than Java in its own syntax, this instantiation is required > every time and that they were different. Now looknig through > some Java examples, I think that the Java I did before > NetRexx either did everything out of 'main' with static > methods, or that I just missed those instantiations because > in Java, you can instantiate using the class name itself but > starting with a lowercase. For clarity, I'll add the example > to the Users Guide. In either NetRexx ot Java one 'constructs' an 'instance' of the class using a constructor. Java requires the keyword 'new' to identify a constructor (because non-constructor methods can have the same name as the class(!)). NetRexx does not permit the latter, and so does not need the 'new' keyword. Mike _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Hello Mike, and al, may I add my personal opinion to this topic:l:
1.) This behaviour of NetRexx *might* disallow the use of Java classes in a NetRexx program, when they are using this Java convention Mike describes below. 2.) I personally *do* find the usage of the keyword *new* useful for seeing from the source-code that a *new object* is created (self-documentary). Not that I want to change NetRexx; it's just my 0,0003 cents I'm throwing in to this topic. Hence, in my opinion, NetRexx 4.00 should at least *allow* the usage of the keyword *new*. Thomas. ========================================================= Am 26.03.2012 17:01, schrieb Mike Cowlishaw: > In either NetRexx ot Java one 'constructs' an 'instance' of the class > using a constructor. Java requires the keyword 'new' to identify a > constructor (because non-constructor methods can have the same name as > the class(!)). NetRexx does not permit the latter, and so does not > need the 'new' keyword. Mike > _______________________________________________ Ibm-netrexx mailing > list [hidden email] Online Archive : > http://ibm-netrexx.215625.n3.nabble.com/ -- Thomas Schneider (Founder of www.thsitc.com) Member of the Rexx Languge Asscociation (www.rexxla.org) Member of the NetRexx Developer's Team (www.netrexx.org) _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/
Thomas Schneider, Vienna, Austria (Europe) :-)
www.thsitc.com www.db-123.com |
Free forum by Nabble | Edit this page |