comp.lang.java.programmer
http://groups-beta.google.com/group/comp.lang.java.programmer
[EMAIL PROTECTED]

Today's topics:

* declare variable inside or outside block? - 5 messages, 5 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/51e12987795dd5c4
* Question on Pattern Matcher? - 4 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4f43abd9dd1ae29
* Stuff the purple heart programmers cook up - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ff788c5b12bf8d8f
* Modifying the parameter Objects passed to RMI server - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e958d8037e335b39
* Java Architects / Sr. developers / Developers - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cd526f321112451c

==============================================================================
TOPIC: declare variable inside or outside block?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/51e12987795dd5c4
==============================================================================

== 1 of 5 ==
Date: Sat, Jan 1 2005 11:39 pm
From: Angus Parvis  

thank you for your answers. very interesting, i think i'll have to 
change my coding style :)

Angus



== 2 of 5 ==
Date: Sun, Jan 2 2005 12:55 am
From: Thomas Kellerer  

Angus Parvis wrote on 02.01.2005 00:19:
> Hi,
> 
> I just asked myself, whether it is better to declare a variable inside 
> or outside a block, if you only want to use it inside the block;
> 
> I always do it like this:
> 
> String foo;
> while (true) {
>     foo = new String();
> }
> 
> Guess that's better than:
> 
> while (true) {
>     String foo = new String();
> }
> 
> In the second example i declare the variable String foo every time the 
> loop is repeated - guess that's the worse solution, isn't it?
> 
> Well, I'd be interested in your comments on this,
> 
> thanks in advance,
> 
> Angus


In contrast to the other two answers I prefer the first version. The simple 
reason: it's easier to debug, because the variable does not go out of scope 
each time the start of the loop is reached, so I can add a watch more easily.

Thomas



== 3 of 5 ==
Date: Sat, Jan 1 2005 10:07 pm
From: The Abrasive Sponge  

Angus Parvis wrote:

> Hi,
> 
> I just asked myself, whether it is better to declare a variable inside 
> or outside a block, if you only want to use it inside the block;
> 
> I always do it like this:
> 
> String foo;
> while (true) {
>     foo = new String();
> }
> 
> Guess that's better than:
> 
> while (true) {
>     String foo = new String();
> }
> 
> In the second example i declare the variable String foo every time the 
> loop is repeated - guess that's the worse solution, isn't it?
> 
> Well, I'd be interested in your comments on this,
> 
> thanks in advance,
> 
> Angus


If I need reference to foo after the while loop I use the first if I 
don't I use the second.




== 4 of 5 ==
Date: Sat, Jan 1 2005 10:15 pm
From: Chris Smith  

Andrew McDonagh <[EMAIL PROTECTED]> wrote:
> Its (was) typical for C programs to have all local variables defined at 
> the beginning of a function, but this isn't (IMHO) a good practice.

Though this is a bit off-topic for this newsgroup, the "typical" thing 
in C is to declare variables at the beginning of a block.  This isn't 
just "typical" in C, but in fact is required by the C language 
specification prior to C99.  Declaring variables anywhere else has been 
non-standard C for most of the C language's lifetime, though it's 
generally supported by many "C/C++" compilers, since it's valid in the 
C++ language.

I believe (but am not sure) that this changes with C99.  However, it 
seems somewhat rare to find compilers that are fully compliant with C99, 
so in practical terms you're either declaring variables at the beginning 
of a block, or not writing valid ANSI C code.

-- 
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation



== 5 of 5 ==
Date: Sun, Jan 2 2005 1:07 am
From: "hilz"  


"Angus Parvis" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
> I just asked myself, whether it is better to declare a variable inside
> or outside a block, if you only want to use it inside the block;
>
> I always do it like this:
>
> String foo;
> while (true) {
> foo = new String();
> }
>
> Guess that's better than:
>
> while (true) {
> String foo = new String();
> }
>
> In the second example i declare the variable String foo every time the
> loop is repeated - guess that's the worse solution, isn't it?
>
> Well, I'd be interested in your comments on this,
>
> thanks in advance,
>
> Angus

I like to agree with others that declaring variables as close to their scope
as possible is a better idea.
I just like to ask why would you do:
String foo= new String();
This does not seem to be the correct thing to do.
what you probably need is:
String foo = someOtherString;
or
String foo = "some hardcoded string";

String foo = new String() does not seem to serve any purpose to me. Does
anybody care to comment on this?

thanks
hilz







==============================================================================
TOPIC: Question on Pattern Matcher?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4f43abd9dd1ae29
==============================================================================

== 1 of 4 ==
Date: Sat, Jan 1 2005 6:38 pm
From: IchBin  

Given the following code snippet. Why would I not get a pattern match 
from a JTree Selection?

( Code Snippet )____________________________
System.out.println(selectedIP.substring(0,(selectedIP.indexOf("[")) 
-1).trim());

TreePath currentPath = tree.getSelectionPath();
TreePath parentPath = currentPath.getParentPath();
System.out.println(parentPath.toString());

Pattern openPattern = Pattern.compile("Opens");
System.out.println("openPattern:  "+openPattern);
Pattern closePattern = Pattern.compile("Closes");
System.out.println("closePattern:  "+closePattern);
Pattern dropPattern = Pattern.compile("Drops");
System.out.println("dropPattern:  "+dropPattern);

  CharSequence inputStr = parentPath.toString();
  System.out.println("CharSequence:  "+inputStr);

  Matcher openMatcher = openPattern.matcher(inputStr);
  System.out.println("openMatch:  "+openMatcher.matches());

  Matcher closeMatcher = closePattern.matcher(inputStr);
  System.out.println("closeMatcher:  "+closeMatcher.matches());

  Matcher dropMatcher = dropPattern.matcher(inputStr);
  System.out.println("dropMatcher:  "+dropMatcher.matches());

( Display Output per/selection )____________________________
24.229.165.60
[UDP, IP Opens,  509  Records]
openPattern:  Opens
closePattern:  Closes
dropPattern:  Drops
CharSequence:  [UDP, IP Opens,  509  Records]
openMatch:  false
closeMatcher:  false
dropMatcher:  false

24.229.165.60
[UDP, IP Closes,  489  Records]
openPattern:  Opens
closePattern:  Closes
dropPattern:  Drops
CharSequence:  [UDP, IP Closes,  489  Records]
openMatch:  false
closeMatcher:  false
dropMatcher:  false


Thanks in Advance...
IchBin
__________________________________________________________________________

'The meeting of two personalities is like the contact of two chemical 
substances:
  if there is any reaction, both are transformed.'
-  Carl Gustav Jung,  (1875-1961),  psychiatrist and psychologist



== 2 of 4 ==
Date: Sat, Jan 1 2005 6:44 pm
From: IchBin  


Would I have to take a substring of the CharSequence of the pattern I am 
looking for to have it match? that is say "Closes"?

CharSequence:  [UDP, IP Closes,  489  Records]
-- 


Thanks in Advance...
IchBin
__________________________________________________________________________

'The meeting of two personalities is like the contact of two chemical 
substances:
  if there is any reaction, both are transformed.'
-  Carl Gustav Jung,  (1875-1961),  psychiatrist and psychologist



== 3 of 4 ==
Date: Sat, Jan 1 2005 9:32 pm
From: "hilz"  

> Would I have to take a substring of the CharSequence of the pattern I am
> looking for to have it match? that is say "Closes"?
>
> CharSequence:  [UDP, IP Closes,  489  Records]

try this:

Pattern.compile(".+Opens.+");

thanks
hilz





== 4 of 4 ==
Date: Sat, Jan 1 2005 11:06 pm
From: IchBin  

hilz wrote:
>>Would I have to take a substring of the CharSequence of the pattern I am
>>looking for to have it match? that is say "Closes"?
>>
>>CharSequence:  [UDP, IP Closes,  489  Records]
> 
> 
> try this:
> 
> Pattern.compile(".+Opens.+");
> 
> thanks
> hilz
> 
> 
Thanks hilz.. That did it for me!

Guess I need to learn pattern matching!

IchBin
__________________________________________________________________________

'The meeting of two personalities is like the contact of two chemical 
substances:  if there is any reaction, both are transformed.'
-  Carl Gustav Jung,  (1875-1961),  psychiatrist and psychologist




==============================================================================
TOPIC: Stuff the purple heart programmers cook up
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ff788c5b12bf8d8f
==============================================================================

== 1 of 2 ==
Date: Sun, Jan 2 2005 1:24 am
From: Andrew Thompson  

On 1 Jan 2005 11:12:45 -0800, Last Timer wrote:

> For Andrew the old hag:

(snip drivel)  I want my money back.  

Why don't you reserve further posts until you have ..
a) taken your medication
b) something to say that is interesting
c) something that relates to Java.

Others can waste further attention on you if they see fit.
I'm outta' this one.

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane



== 2 of 2 ==
Date: Sat, Jan 1 2005 8:12 pm
From: "Ryan Stewart"  

"Andrew Thompson" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Others can waste further attention on you if they see fit.
> I'm outta' this one.
>
I'll jump in. Wouldn't the Starbucks/Pointerbucks be more suited to C 
programmers? I really don't see how that applies to Java.

And really, why are you posting all this junk? If you're just a troll, 
you'll make a name for yourself quickly. 






==============================================================================
TOPIC: Modifying the parameter Objects passed to RMI server
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e958d8037e335b39
==============================================================================

== 1 of 1 ==
Date: Sat, Jan 1 2005 8:58 pm
From: "Harish"  

RMI provides only pass by value mechanism.
Both the server and client see the same class def(of the param) So there is 
nothing preventing the server from modifying a parameter.
In case of the same JVM it is more efficient(faster) to pass the params by 
ref. But I guess there are options
by which you can enforce the pass by value behavior inside the same JVM. 
This obviously have an overhead of
making  a copy each parameter being passed. I am not sure about this option, 
just remember seeing
"pass parame by value even for in-proc calls" in some option screen 
somewhere!

The idea is this: since RMI uses pass by value, u r not(should not) supposed 
to modify'em.
But there is nuthing preveniting you from doing so.
So a client server program which runs fine as multiple JVM may have issues 
when they are put inside the same JVM.
so we have an option to enforce the "pass-by-value" even in case of in-proc 
calls.
This ofcourse will have some performance issues.

And yes, JNDI is another RMI server. And I thick, JNDI contains only Remote 
objects.

"Norris Watkins" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>I was wondering what will happen if the Objects passed as parameters to an 
>RMI call is modified by the server.
> Since these objects are serialized/deserialized before the server code 
> gets access to the parameter objects, what the server views is only a copy 
> of the original object.
> 1. What prevents the server from calling modifiers on such objects ?
> 2. Will the answer for 1 above  be different, if both server and client 
> are running under the same JVM ?
> 3. Is there a way in RMI to send the Class information along with the 
> object to the remote server ? ( So that the server does not have to have 
> compile time knowledge of the Class that it will handle at runtime )
> 4. Does JNDI use RMI ? ( If I do a lookup() for a particular object from a 
> client JVM, and if the object is sitting under a different JVM, how is 
> that the calls are being dispatched over the wire ? )
> 5.  Can I bind() objects to JNDI, that are not implementing 
> java.rmi.Remote ?
>
> Thanks for reading
> --nw
> 






==============================================================================
TOPIC: Java Architects / Sr. developers / Developers
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cd526f321112451c
==============================================================================

== 1 of 1 ==
Date: Sat, Jan 1 2005 10:04 pm
From: The Abrasive Sponge  

[EMAIL PROTECTED] wrote:
> We are a UK-based software firm, setting up our operations in
> Bangalore, India as a 100% EOU under STPI. We require persons with
> knowledge of front-end Java architecture - Swing, Eclipse, Ant, JUnit
> etc...
> 
> Java Architects - 5+ years exp:
> The role is of leadership, to guide a team of developers. Good
> communication, Leadership skills, work with 2 - 4 teams on different
> projects, UK travel may be needed. Work location: Bangalore.
> 
> Sr.Dev: 3+ years exp / Dev: 1.5+ years exp. Front-end Java Developers
> preferred. Mail to [EMAIL PROTECTED]
> 

Looking for cheap labor?



==============================================================================

You received this message because you are subscribed to the Google
Groups "comp.lang.java.programmer" group.

To post to this group, send email to [EMAIL PROTECTED] or
visit http://groups-beta.google.com/group/comp.lang.java.programmer

To unsubscribe from this group, send email to
[EMAIL PROTECTED]

To change the way you get mail from this group, visit:
http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe

To report abuse, send email explaining the problem to [EMAIL PROTECTED]

==============================================================================
Google Groups: http://groups-beta.google.com 

Reply via email to