Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Good idea or full of it?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  11 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Abrasive Sponge  
View profile  
 More options Sep 23 2004, 3:48 pm
Newsgroups: comp.lang.java.programmer
From: Abrasive Sponge <theabrasioncontin...@yourhouse.com>
Date: Thu, 23 Sep 2004 13:48:59 -0600
Local: Thurs, Sep 23 2004 3:48 pm
Subject: Good idea or full of it?
public class Person {
        private String firstName;
        private static int count;

        public void setFirstName(String firstName) {
                this.firstName = firstName;
        }

        public String getFirstName() {
                return firstName;
        }

        public static setCount(int count) {
                static.count = count; //using a static keyword as such
        }      

        public static int getCount() {
                return static.count; //using a static keyword as such
        }

}

I was wondering if the java language can use something
like this....maybe there is something that I don't know, but having a
static reference like this would kick butt.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Davison  
View profile  
 More options Sep 23 2004, 4:26 pm
Newsgroups: comp.lang.java.programmer
From: John Davison <nospample...@cinci-solutions.com>
Date: Thu, 23 Sep 2004 16:26:43 -0400
Local: Thurs, Sep 23 2004 4:26 pm
Subject: Re: Good idea or full of it?

Do you mean this?

public static setCount(int count) {
        Person.count = count;

}

public static int getCount() {
        return Person.count;

}

Now, go kick some butt!  ;)

- john


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Abrasive Sponge  
View profile  
 More options Sep 23 2004, 5:03 pm
Newsgroups: comp.lang.java.programmer
From: Abrasive Sponge <theabrasioncontin...@yourhouse.com>
Date: Thu, 23 Sep 2004 15:03:19 -0600
Local: Thurs, Sep 23 2004 5:03 pm
Subject: Re: Good idea or full of it?

Hahaha, I do that already :)

It's just a feature unused that makes sense, so I thought why not. :)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bryce  
View profile  
 More options Sep 23 2004, 5:06 pm
Newsgroups: comp.lang.java.programmer
From: Bryce <spamt...@berzerker-soft.com>
Date: Thu, 23 Sep 2004 17:06:13 -0400
Local: Thurs, Sep 23 2004 5:06 pm
Subject: Re: Good idea or full of it?
On Thu, 23 Sep 2004 13:48:59 -0600, Abrasive Sponge

uhhh... Would this do?

public class Person {
        private String firstName;
        private static int count;

        public static void setCount(int count) {
                Person.count = count;
        }

        public static int getCount() {
                return count;
        }

        public static void main(String[] args) {
                Person.setCount(100);

                System.out.println("getting count [" +
Person.getCount() + "]");
        }

}

or am I missing something in your request...

--
now with more cowbell


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Abrasive Sponge  
View profile  
 More options Sep 23 2004, 5:21 pm
Newsgroups: comp.lang.java.programmer
From: Abrasive Sponge <theabrasioncontin...@yourhouse.com>
Date: Thu, 23 Sep 2004 15:21:08 -0600
Local: Thurs, Sep 23 2004 5:21 pm
Subject: Re: Good idea or full of it?

Yeah, sorry, I am just wondering everybody thinks of that idear is all.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jacob  
View profile  
 More options Sep 24 2004, 5:07 am
Newsgroups: comp.lang.java.programmer
From: Jacob <ja...@yahoo.com>
Date: Fri, 24 Sep 2004 11:07:13 +0200
Local: Fri, Sep 24 2004 5:07 am
Subject: Re: Good idea or full of it?

John Davison wrote:
> Do you mean this?

> public static setCount(int count) {
>     Person.count = count;
> }

> public static int getCount() {
>     return Person.count;
> }

I guess the question is wether this syntax should be
mandatory or not. I think it should. At least the
compiler should give a compilation warning when
the "Class." prefix on static elements is omitted.

Same of course when calling the methods:

   Person.setCount(count);
   Person.getCount();

Both from other classes and from within same class.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Uppal  
View profile  
 More options Sep 24 2004, 5:13 am
Newsgroups: comp.lang.java.programmer
From: "Chris Uppal" <chris.up...@metagnostic.REMOVE-THIS.org>
Date: Fri, 24 Sep 2004 10:13:01 +0100
Local: Fri, Sep 24 2004 5:13 am
Subject: Re: Good idea or full of it?

Abrasive Sponge wrote:
> public static int getCount() {
> return static.count; //using a static keyword as such
> }
> }

Personally, I rather like this idea.

I've speculated for a long time that Java could use a "thisClass" notation of
some kind.  It would eliminate a large chunk of completely pointless verbosity.

However I think that an explicit "thisClass" notation would probably work
better, in the sense that it could be used in more circumstances without
confusion.

For instance, consider a typical Singleton implementation:

    class MyClass
    {
        private static final MyClass singleton = new MyClass();

        public static MyClass
        getSingleton()
        {
            return MyClass.singleton;
        }
    }

using "thisClass" in the above code would eliminate a great deal of redundancy:

    class MyClass
    {
        private static final thisClass singleton = new thisClass();

        public static thisClass
        getSingleton()
        {
            return thisClass.singleton;
        }
    }

but I'm not sure that overloading "static" to the same extent is feasible:

    class MyClass
    {
        private static final static singleton = new static();

        public static static
        getSingleton()
        {
            return static.singleton;
        }
    }

As I'm sure you'll agree ;-)

BTW, I'm not saying that "thisClass" wouldn't have problems too, e.g. what
would be the declared return type of a method overriding

    public thisClass aMethod();

, would it be the parent class or the subclass ?

    -- chris


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alex Hunsley  
View profile  
 More options Sep 25 2004, 5:36 am
Newsgroups: comp.lang.java.programmer
From: Alex Hunsley <l...@tardis.ed.ac.molar.uk>
Date: Sat, 25 Sep 2004 09:36:57 GMT
Local: Sat, Sep 25 2004 5:36 am
Subject: Re: Good idea or full of it?

What is wrong with writing:

          getSingleton()
          {
              return singleton;
          }

even less verbosity!
alex


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tor Iver Wilhelmsen  
View profile  
 More options Sep 26 2004, 3:02 am
Newsgroups: comp.lang.java.programmer
From: Tor Iver Wilhelmsen <tor.iver.wilhelm...@broadpark.no>
Date: 26 Sep 2004 09:02:35 +0200
Local: Sun, Sep 26 2004 3:02 am
Subject: Re: Good idea or full of it?

Alex Hunsley <l...@tardis.ed.ac.molar.uk> writes:
> What is wrong with writing:

>           getSingleton()
>           {
>               return singleton;
>           }

If the goal is to remove Sun's error of allowing referencing static
members via instances, that's really "return this.singleton", and
hence bad since it uses an instance reference implicitly.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Uppal  
View profile  
 More options Sep 27 2004, 5:14 am
Newsgroups: comp.lang.java.programmer
From: "Chris Uppal" <chris.up...@metagnostic.REMOVE-THIS.org>
Date: Mon, 27 Sep 2004 10:14:50 +0100
Local: Mon, Sep 27 2004 5:14 am
Subject: Re: Good idea or full of it?

Alex Hunsley wrote:
> > For instance, consider a typical Singleton implementation:
[...]
> > using "thisClass" in the above code would eliminate a great deal of
> > redundancy:

> What is wrong with writing:

>           getSingleton()
>           {
>               return singleton;
>           }

> even less verbosity!

A: It doesn't solve the general problem of excessively redundant reiteration of
the class name everywhere.

B: I'd prefer not to have to refer to a static directly like that.  I admit I
do it, but that's /because/ of the lack of an explicit, but not redundant,
syntax.

Incidentally, the lack of explicitness is why I prefer to tag the names of
static and instance variable with 's_' and 'm_' respectively.  I know that some
people don't like that, but I think they are confusing the idea with either the
similar but badly misguided practice of tagging them with 's' or 'm' (note the
lack of separating underscore), or with the, even worse, practice of tagging
the names of local variables.  (Or even with Hungarian notation -- which is
quite simply an offence against humanity...)

    -- chris


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bryce  
View profile  
 More options Sep 27 2004, 2:18 pm
Newsgroups: comp.lang.java.programmer
From: Bryce <spamt...@berzerker-soft.com>
Date: Mon, 27 Sep 2004 14:18:35 -0400
Local: Mon, Sep 27 2004 2:18 pm
Subject: Re: Good idea or full of it?
On Thu, 23 Sep 2004 15:21:08 -0600, Abrasive Sponge

No problem with it, in fact, that's what static variables are for.

--
now with more cowbell


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google