NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

global variables
Goto page 1, 2  Next
 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
efred



Joined: 12 Sep 2009
Posts: 27

PostPosted: Sun Jan 03, 2010 9:27 pm    Post subject: global variables Reply with quote

Hi

I would like to make global variables. (project scope)
No luck on the web.

Thanks in advance.
efred
Back to top
Pat Farrell
Posted via mailing list.





PostPosted: Mon Jan 04, 2010 9:30 pm    Post subject: global variables Reply with quote

efred wrote:
Quote:
I would like to make global variables. (project scope)
No luck on the web.

This is a Java question, not specific to Netbeans.

Its generally considered poor software engineering to have global
variables. Google for Dependency Injection.

--
Pat Farrell
http://www.pfarrell.com/
Back to top
PEB
Posted via mailing list.





PostPosted: Mon Jan 04, 2010 11:49 pm    Post subject: global variables Reply with quote

No virus found in this outgoing message.
Checked by AVG - www.avg.com
Version: 9.0.725 / Virus Database: 270.14.124/2599 - Release Date: 01/04/10 05:24:00
Back to top
Pat Farrell
Posted via mailing list.





PostPosted: Mon Jan 04, 2010 11:55 pm    Post subject: global variables Reply with quote

PEB wrote:
Quote:
Again, another netbeans policeman with his stick.

I answered his question. But there are tons of places that are better
suited for pure Java questions, such as Javaranch.com
or the Java section of devshed.com

Quote:
Bad or good practice depends of the program and what do you need and in
what time, etc ... . If , for example, you are just translating an old
Fortran calculation into java it would be very economic to just use
something to provide the COMMON area and forget all about programing
perfectionism. To continue with the example make a class (common.java)
full of public variables, etc ...

No, re-implementing Fortran COMMON in Java using Global variables is
insane. I wrote professional Fortran for years in the 60s and 70s. It
was needed then, as million dollar computers had 32k of memory. It was
dangerous then and is insanely dangerous today.


Quote:
I encourage everyone to remember that here came people from all areas,
young and old, science, design, music, etc ...

I want to improve the signal to noise ratio about Netbeans, at least in
the small amount of time that Netbeans will still exist.

@Pablo's messages are just adding to the noise.

--
Pat Farrell
http://www.pfarrell.com/
Back to top
JCDescy



Joined: 25 Nov 2009
Posts: 78

PostPosted: Tue Jan 05, 2010 12:14 am    Post subject: global variables Reply with quote

Thanks, Pat.
Back to top
Thomas Wolf
Posted via mailing list.





PostPosted: Tue Jan 05, 2010 1:01 am    Post subject: global variables Reply with quote

Quote:
As said, Java and Netbeans problems are entangled many times. There is
not reason why *efred* would suppose that Netbeans has not a way to do
that being it a good or bad practice.
Moreover if *Pat* considered the question was out of place _why to add
any comment about the matter._

Quote:
I encourage everyone to remember that here came people from all areas,
young and old, science, design, music, etc ... and not only workers of
the lego programing industry. Just help everyone in their own needs or
forget about it. Thank you.


You answered your own question by stating that people here come from all
areas - Pat was suggesting to the poster, who may not be from the "lego"
industry (how hypocritical of you to disparage the people/industry who
wrote the IDE that you're using), that global variables are typically
considered bad practice. Believe it or not, but there are people who
are not intellectual snobs and who are open to learning what people from
the "lego" industry have to offer.

....where is that darn "PEB" filter that I had installed months
ago....oh, here it i

**********************************************************************************************
IMPORTANT: The contents of this email and any attachments are confidential. They are intended for the
named recipient(s) only.
If you have received this email in error, please notify the system manager or the sender immediately and do
not disclose the contents to anyone or make copies thereof.
*** eSafe scanned this email for viruses, vandals, and malicious content. ***
**********************************************************************************************
Back to top
PEB
Posted via mailing list.





PostPosted: Tue Jan 05, 2010 2:27 am    Post subject: global variables Reply with quote

No virus found in this outgoing message.
Checked by AVG - www.avg.com
Version: 9.0.725 / Virus Database: 270.14.124/2599 - Release Date: 01/04/10 05:24:00
Back to top
Pat Farrell
Posted via mailing list.





PostPosted: Tue Jan 05, 2010 2:29 am    Post subject: global variables Reply with quote

PEB wrote:
Quote:
If you care for noise ratio look first to the trunk in your own eye.

Plonk

Do folks without a kill file a favor and simply shut up.

--
Pat Farrell
http://www.pfarrell.com/
Back to top
PEB
Posted via mailing list.





PostPosted: Tue Jan 05, 2010 2:39 am    Post subject: global variables Reply with quote

Thomas Wolf escribi
Back to top
tony_Mresangelo



Joined: 01 Sep 2009
Posts: 40
Location: Italy

PostPosted: Tue Jan 05, 2010 6:28 am    Post subject: global variables Reply with quote

----- Original Message -----
Da : "efred" <address-removed>
A : address-removed
Oggetto : [nbusers] global variables
Data : Sun, 03 Jan 2010 21:27:36 +0000

Quote:
Hi

I would like to make global variables. (project scope)
No luck on the web.

Thanks in advance.
efred




---------------


hi,

I read many answers about this threat ..

The ask of Efred is very intriguing, so I too would say
some thing about it.

I think that the ask of Efred come from a particular need to
solve a his particular problem.
And don't really come from some general consideration about
the way to realize programs.

Change the rules of a language to write software.. is to a
different level to cope a problem when you write a program.
*USUALLY*..programmers only *use* the languages ...

Languages define a way for programming that has a very
general target... And (in my opinion) you cannot think to
solve a particular problem thinking to change the general
rules of a language for this..


Thinking to a new language is more general than thinking to
a problem.

In particular OOP is a way to realize code that allow to
encapsulate code, how the stile of "structural programming"
is a way to do the code easy to be read..
And this has nothing to see with solving problems writing
code...

When you decide to write code in a language you accept to
write code with a particular stile and, coding, you have to
solve the problems in the context of the philosophy of the
language allow you to do...

For example... I use global variable in the software that I
write in java putting it in a class of only properties that
I call GlobalVariable ...for example...

So I don't see what the problem can be...

I excuse me very much for my poor English

regards

Angelo
Back to top
Pat Farrell
Posted via mailing list.





PostPosted: Tue Jan 05, 2010 6:36 am    Post subject: global variables Reply with quote

address-removed wrote:
Quote:
For example... I use global variable in the software that I
write in java putting it in a class of only properties that
I call GlobalVariable ...for example...

So I don't see what the problem can be...

The problems are many. The first and most obvious is how do you do unit
testing. A key concept of software engineering for the past couple of
decades is to automate unit testing. For Java, JUnit is well used, and
Netbeans will automatically generate the JUnit test classes for you. It
generates each of the public functions, and stubbs out Objects for
paramters and calls them.

This lets you easily do Test Driven Development, or other agile techniques.

The problem is how do you test classes that use the Global Variables?
How do you isolate the unit to just the class?

Dependency Injection (and similar concepts) allow you to pass in real or
mock values that would be in a Global Variable or a Singleton, so you
can isolate the unit tests.

Its simply not a unit test if every execution invokes many classes, and
that is usually what happens on large systems that use Global Variables.

A quick google of "java dependency injection" will find many articles.

--
Pat Farrell
http://www.pfarrell.com/
Back to top
Peter Ford
Posted via mailing list.





PostPosted: Tue Jan 05, 2010 9:16 am    Post subject: global variables Reply with quote

On 05/01/10 06:35, Pat Farrell wrote:
Quote:
address-removed wrote:
Quote:
For example... I use global variable in the software that I
write in java putting it in a class of only properties that
I call GlobalVariable ...for example...

So I don't see what the problem can be...

The problems are many. The first and most obvious is how do you do unit
testing. A key concept of software engineering for the past couple of
decades is to automate unit testing. For Java, JUnit is well used, and
Netbeans will automatically generate the JUnit test classes for you. It
generates each of the public functions, and stubbs out Objects for
paramters and calls them.

This lets you easily do Test Driven Development, or other agile techniques.

The problem is how do you test classes that use the Global Variables?
How do you isolate the unit to just the class?

Dependency Injection (and similar concepts) allow you to pass in real or
mock values that would be in a Global Variable or a Singleton, so you
can isolate the unit tests.

Its simply not a unit test if every execution invokes many classes, and
that is usually what happens on large systems that use Global Variables.

A quick google of "java dependency injection" will find many articles.


Using agile development techniques as a justification for not using global
variables in some way is a bit false - you're assuming that everyone wants to
turn their life upside down and use someone else's idea of best practise on
every possible project.

I suspect that the original poster has a bit of code that needs to be ported
into a Java project as of yesterday, and is looking for the quickest way to do
it. OP probably doesn't give a <expletive-deleted> about best practise and
certainly isn't about to go all "agile" for it!

This is not intended as a rant, or a personal criticism of the way you (Pat)
think: just bear in mind, however, that some people are not in a position to
implement "best practise" methods, at least not for a quick hack... :)

--
Peter Ford, Developer phone: 01580 893333 fax: 01580 893399
Justcroft International Ltd. www.justcroft.com
Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom
Registered in England and Wales: 2297906
Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS
Back to top
JCDescy



Joined: 25 Nov 2009
Posts: 78

PostPosted: Tue Jan 05, 2010 9:39 am    Post subject: global variables Reply with quote

Am 05.01.2010 um 07:35 schrieb Pat Farrell:

Quote:
address-removed wrote:
Quote:
For example... I use global variable in the software that I
write in java putting it in a class of only properties that
I call GlobalVariable ...for example...

So I don't see what the problem can be...

Another problem is, that he asked if there was a way in Netbeans to do this. This is wrong thinking as this is not a Netbeans issue, but a Java issue. So, as Pat stated, there are much better places to look for an answer. I mean: I use Netbeans for webdevelopment. Shall I start asking all of my HTML-, CSS- and AJAX-Questions here? What about Ruby and Python and PHP problems? Would you all care to read and answer them? To tell you the truth, I am really considering unsubscribing from this list, because I feel this is not the right place for me as a non-Java developer.

@admins: would you care to establish a dedicated general Java Users forum, just like the Ruby Users and C/C++ Users forums? I have noticed that there are forums for Java EE and Java ME which are, from what I know, only subsets of the Java technology, aren't they? That way we might be able to straighten out this perceived entanglement. =
Back to top
PEB
Posted via mailing list.





PostPosted: Tue Jan 05, 2010 1:12 pm    Post subject: global variables Reply with quote

No virus found in this outgoing message.
Checked by AVG - www.avg.com
Version: 9.0.725 / Virus Database: 270.14.126/2601 - Release Date: 01/05/10 04:35:00
Back to top
Thomas Wolf
Posted via mailing list.





PostPosted: Tue Jan 05, 2010 2:10 pm    Post subject: global variables Reply with quote

...
Quote:
Another problem is, that he asked if there was a way in Netbeans to do this. This is wrong thinking as this is not a Netbeans issue, but a Java issue. So, as Pat stated, there are much better places to look for an answer. I mean: I use Netbeans for webdevelopment. Shall I start asking all of my HTML-, CSS- and AJAX-Questions here? What about Ruby and Python and PHP problems? Would you all care to read and answer them? To tell you the truth, I am really considering unsubscribing from this list, because I feel this is not the right place for me as a non-Java developer.

@admins: would you care to establish a dedicated general Java Users forum, just like the Ruby Users and C/C++ Users forums? I have noticed that there are forums for Java EE and Java ME which are, from what I know, only subsets of the Java technology, aren't they? That way we might be able to straighten out this perceived entanglement.


I kind of have a related question for anyone who might know: is it
possible for a community member to create a moderated mailing list on
the netbeans.org site or for an existing mailing list to become
moderated? address-removed doesn't appear to be moderated. This
is not meant as a slight against the people asking off-topic questions -
beginning users (especially those brought up with MS products) often
don't distinguish between the language and the IDE - but in the past,
off-topic questions have been far and few between (I have asked them
occasionally myself occasionally because the list has traditionally been
frequented by very experienced Java engineers and I needed quick
answers). Given the increased "noise" on this mailing list, it would be
nice if either (a) this mailing list became moderated or (b) there was a
way to create a moderated mailing list. I've never been a mailing list
moderator, but I would be willing to volunteer as a moderator for either
(a) or (b).

Best regards,
Tom
**********************************************************************************************
IMPORTANT: The contents of this email and any attachments are confidential. They are intended for the
named recipient(s) only.
If you have received this email in error, please notify the system manager or the sender immediately and do
not disclose the contents to anyone or make copies thereof.
*** eSafe scanned this email for viruses, vandals, and malicious content. ***
**********************************************************************************************
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo