comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * Newbee question Mobile software - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f36a637b3fe577e4 * Multiple client implementations. - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1797faf6a8123bf3 * Who is the best WebSphere Studio or Oracle JDeveloper?? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/747e9a4c137251d2 * passing several arguments - use inner class? - 4 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cdb480d0184f6bd5 * Applet and .jar files - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e2d57dc6d0a11bb3 * byte representation of a class - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/754ced8b07b9a2d3 * Thread synchronization - 3 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/172837b7b0667fd1 * J2ME: The Complete Reference - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/29dde018c381d116 * Looking for open source Asteroids game - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6113c3e5f8b103b6 * Getting Exception info in commons.log - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8706074408a502ad * Literature on boolean naming/usage conventions? - 5 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/dabf0085d6427c15 * JSP CeWolf JFreeChart JSP wrapper - how to set data series colors? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4019ec9a156ad5be * Browser Back Button (IE) Caching Problem in Struts Land - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2661162f4dfe878 ========================================================================== TOPIC: Newbee question Mobile software http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f36a637b3fe577e4 ========================================================================== == 1 of 1 == Date: Wed, Sep 15 2004 5:58 am From: Andrew Thompson <[EMAIL PROTECTED]> On Wed, 15 Sep 2004 14:34:36 -0700, fm wrote: (multi-posting) > but no answer in other ng... That is not surprising, after the passage of less than 15 minutes. When you make a post you need to wait at least a day or two before you consider posting the same to another group. On the occasions you *do* repost a question in a different group, it pays to forewarn people with the short note at the top.. "Previously posted on ..., reposting because ..." > and I X posted .. No. Cross-posting ('X post') is different to multi-posting, and less problematic. On the rare occasions that a post needs to go to several different groups, you should cross-post, rather than multi-post. >..only once ! That's why I asked you not to do so, only once*. OTOH, if you continue to waste the time and effort of those who might help you, I will repeat it each time you post, on every multi-posted message you make. As people tend not to help those who multi-post, your requests for help on *every* group will begin to fall on deaf ears. * Note that I might also have mentioned your multi-posting on the other post you made, but decided that I should leave one thread without any suggestion of multi-posting so that you might have a better chance of getting an answer. Do not expect that concession in future. -- 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 ========================================================================== TOPIC: Multiple client implementations. http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1797faf6a8123bf3 ========================================================================== == 1 of 3 == Date: Wed, Sep 15 2004 6:08 am From: "Rowland" <[EMAIL PROTECTED]> Hi all, I've written a server program in Java that allows clients to transmit commands and recieve an appropriate response (e.g. some data from a database, etc.). There will be several different clients, designed for people with different roles within the company. These different clients will share a number of forms, with maybe one or two role specific forms being added, and certain buttons being disabled within each client. What would be the best way to go about implementing this in terms of code-reuse, modularity, etc. My original idea was a BasicClient superclass with most of the forms contained within that. This would then be extended to an AdminClient, UserClient, ManagerClient (for example), which would enable / disable specific forms/buttons. Would this work well, or is there a better suggestion? Many thanks, Rowland. == 2 of 3 == Date: Wed, Sep 15 2004 6:44 am From: Sudsy <[EMAIL PROTECTED]> Rowland wrote: <snip> > What would be the best way to go about implementing this in terms of > code-reuse, modularity, etc. <snip> I'd use a Struts/Tiles combination. How's this for simple?: <tiles:insert name="adminButtons.jsp" role="admin"> The content is only included if the user is in the specified role. It might be worth picking up "Programming Jakarta Struts" by Chuck Cavaness (ISBN 0-596-00328-5). The whole book is great but you will be particulary interested in chapter 14, "Using Tiles". == 3 of 3 == Date: Wed, Sep 15 2004 6:57 am From: Chris Smith <[EMAIL PROTECTED]> Rowland wrote: > What would be the best way to go about implementing this in terms of > code-reuse, modularity, etc. > > My original idea was a BasicClient superclass with most of the forms > contained within that. > This would then be extended to an AdminClient, UserClient, ManagerClient > (for example), which would enable / disable specific forms/buttons. Would > this work well, or is there a better suggestion? It's hard to answer general design questions like this on USENET where a lot of details aren't available. That being said, my initial hunch is that you'd be better off going for either of the following instead, depending on exactly how similar these clients are: 1. Composition; provide the building blocks, and let each client assemble them in the way appropriate for that piece of software, or: 2. One piece of software with all the code, and a configuration file specifying how it should appear to this specific user. Inheritance is not generally well-suited as a fundamental approach to these kinds of problems. That's not to say that there won't be some inheritance involved in your implementation; but at the most basic level, I'd think of it as a composition problem. -- www.designacourse.com The Easiest Way to Train Anyone... Anywhere. Chris Smith - Lead Software Developer/Technical Trainer MindIQ Corporation ========================================================================== TOPIC: Who is the best WebSphere Studio or Oracle JDeveloper?? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/747e9a4c137251d2 ========================================================================== == 1 of 1 == Date: Wed, Sep 15 2004 6:09 am From: [EMAIL PROTECTED] (Dave Monroe) "REM" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > Can anybody tell me which IDE tools, Web Sphere, JDeveloper or etc, is the > best for the enterprise applications. > > I know that JDEveloper have good IDE for map database object but I am > interesting for web presentation, which has the best framework part for web > component, JSP, servlet and etc. I know that in WebSphereStudio can put > plug-in for Struts framework, but it's look very difficult for develop and > support. I've talked to Oracle sales people that say JDeveloper runs rings around the competition. Strangely, the competition says the opposite. They're all different flavors of the same gruel. ========================================================================== TOPIC: passing several arguments - use inner class? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cdb480d0184f6bd5 ========================================================================== == 1 of 4 == Date: Wed, Sep 15 2004 6:15 am From: Sebastian Kerekes <[EMAIL PROTECTED]> Michael Borgwardt wrote: > He meant the *programming* situation, not the social one. Uhm, I *know*, but of course you can can split my sentences when quoting me and then say, I'm talking about social stuff. > More details, please. "min/avg/max<Something>" sounds like it would make > a lot of sense even as a top-level class, not an inner class. I'm afraid I can't since it's not my program that I mentioned (no source code available). Anyway, I'm not interested in a solution for this one special case, but in general answers. Actually ppl have posted some interesting ones though I didn't post code .. Thx anyway. == 2 of 4 == Date: Wed, Sep 15 2004 6:43 am From: "Thomas G. Marshall" <[EMAIL PROTECTED]> Sebastian Kerekes coughed up: > Hi, > > I have a rather theoretical question. > > Let's say I have a method which gets a handful of arguments, maybe ten > or more. Passing that much arguments doesn't look nice, so what about > implementing a inner class that contains all those variables for use > in this method? Is it good style to create a data structure just to > use it for one method? > > And there's the other case: The method has to return several > parameters. Well, YMMV on this one, but two things: 1. Methods with 10 parameters, while not ideal, are ok for once in a while. Gross things occur in source code from time to time that don't warrant the extra design. 2. If that bothers you, you can try something similar to the following for input variables as well as outputs. 3. I think you're on the right track with an inner class. I've used one before on occasion for just this purpose, though the exact [mis?]-design reason escapes me noggin: Note, there might be a detail to this I'm forgetting, so regard this as pseudo-code: public class Thing { public static class Out { Bla bla; Foo foo; Oi oi; Etc etc; } public Out method(.......10 things........) { ... return new Out() { Bla bla = ...; Foo foo= ...; Oi oi = ...; Etc etc = ... }; }; } //...elsewhere... Thing.Out results = myThing.method(.......10 things........); -- Onedoctortoanother:"Ifthisismyrectalthermometer,wherethehell'smypen???" == 3 of 4 == Date: Wed, Sep 15 2004 6:55 am From: "Thomas G. Marshall" <[EMAIL PROTECTED]> Thomas G. Marshall coughed up: > Sebastian Kerekes coughed up: >> Hi, >> >> I have a rather theoretical question. >> >> Let's say I have a method which gets a handful of arguments, maybe >> ten or more. Passing that much arguments doesn't look nice, so what >> about implementing a inner class that contains all those variables >> for use in this method? Is it good style to create a data structure >> just to use it for one method? >> >> And there's the other case: The method has to return several >> parameters. > > Well, YMMV on this one, but two things: > > 1. Methods with 10 parameters, while not ideal, are ok for once in a > while. Gross things occur in source code from time to time that don't > warrant the extra design. > > 2. If that bothers you, you can try something similar to the > following for input variables as well as outputs. > > 3. I think you're on the right track with an inner class. I've used > one before on occasion for just this purpose, though the exact > [mis?]-design reason escapes me noggin: > > Note, there might be a detail to this I'm forgetting, so regard this > as pseudo-code: > > public class Thing > { > public static class Out > { > Bla bla; > Foo foo; > Oi oi; > Etc etc; > } > > public Out method(.......10 things........) > { > ... > return new Out() { > Bla bla = ...; > Foo foo= ...; > Oi oi = ...; > Etc etc = ... > }; Oh, I remember. Attempted overriding of fields. Eeek, I forget if that normally illegal notion actually happens to work here in annon-classes or not. This is closer to what I've done before I think, now that my mind is clearing up from all the caffeine :) public class Thing { public static class Out { public Out(Bla b, Foo f, Oi o, Etc e) { bla = b; foo = f; oi = o; etc = e; } public Bla bla; public Foo foo; public Oi oi; public Etc etc; } public Out method(.......10 things........) { ... return new Out(bb, ff, oo, ee); }; } //...elsewhere... Thing.Out results = myThing.method(.......10 things........); ...[snip]... -- Onedoctortoanother:"Ifthisismyrectalthermometer,wherethehell'smypen???" == 4 of 4 == Date: Wed, Sep 15 2004 7:57 am From: Stefan Siegl <[EMAIL PROTECTED]> Sebastian Kerekes wrote: > Hi, > > I have a rather theoretical question. > > Let's say I have a method which gets a handful of arguments, maybe ten > or more. Passing that much arguments doesn't look nice, so what about > implementing a inner class that contains all those variables for use in > this method? Is it good style to create a data structure just to use it > for one method? I have the same opinion as the people answered before me. A method taking 10 parameters sounds as if the structure of the classes is not well done. But if you really need to do that you could structure these parameter in feasible classes and pass them in > And there's the other case: The method has to return several parameters. > If all the elements have the same type, I could use an array - but the > user has to know what meaning a value has at a specific position. > Doesn't sound very good to me. So maybe return some type of collection, > eg. a HashMap? Isn't this a bit too much overhead for just returning > serveral values? And once again the caller has to know what he wants out > of the Map. I suggest to never use Collection until what you want to return is really a Collection *g*. Otherwise you confuse the user of your API and make is unnecessary complex. > Well, and there's the solution to create a simple inner > class with public values. Just to have all necessary values in one > structure. If the class is inner, nested or just a normal class does not matter really much in my eyes. I think this approach is much better than returning some collection/map. hth, Stefan ========================================================================== TOPIC: Applet and .jar files http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e2d57dc6d0a11bb3 ========================================================================== == 1 of 1 == Date: Wed, Sep 15 2004 6:38 am From: Thomas Fritsch <[EMAIL PROTECTED]> Thomas Fritsch wrote: > Marcin Siewiera wrote: > >> ... > >> applet's URL www.bescres.net/play_html.htm (U need JRE 1.42 to run >> applet correctly) >> ... > > > <angry> > Your silly applet did not allow me to close the modal pop-up dialog, > therefore I was not able to close my browser (or leave your web-page), > except by killing the browser with the task-manager. > </angry> > The problem above does not occur anymore. Thank you for fixing it. And sorry for my offence! -- Thomas<dot>Fritsch<squiggle>ops<dot>de ========================================================================== TOPIC: byte representation of a class http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/754ced8b07b9a2d3 ========================================================================== == 1 of 1 == Date: Wed, Sep 15 2004 6:22 am From: Lothar Kimmeringer <[EMAIL PROTECTED]> On 15 Sep 2004 05:07:07 -0700, Benjamin von Eicken wrote: >> ObjectOutputStream doesn't write the byte-code of the >> java-class, only the status of an instance of the >> specific class. The deserialization gets the information >> what kind of class to be initialized before setting the >> values coming from the stream. > > I know, but somehow it writes a signature. Whatever this > looks like, a class with more code ends up in more bytes > in the stream. Example please. The more members that are defined in the class, the more data will be on the ObjectOutputStream. In addition to this data, the complete name of the class will be written to the stream. This happens recursively with all data of the superclasses until reaching java.lang.Object. BTW: You can change the complete handling of serialization deserialization, so that it would be possible to generate much smaller amounts of data on the stream. I'd like to give you more help, but as long as I don't know what exactly you want to achieve it's hard to do. Bring more information about your problem you really want to solve and maybe there is a solution waiting for you much much more easy than you might think. Regards, Lothar -- Lothar Kimmeringer E-Mail: [EMAIL PROTECTED] PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81) Always remember: The answer is forty-two, there can only be wrong questions! ========================================================================== TOPIC: Thread synchronization http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/172837b7b0667fd1 ========================================================================== == 1 of 3 == Date: Wed, Sep 15 2004 6:29 am From: "Thomas G. Marshall" <[EMAIL PROTECTED]> Andrew Thompson coughed up: > On Wed, 15 Sep 2004 11:30:44 GMT, Thomas G. Marshall wrote: > .. >> ...[sniped out stupidity]... > > Is that the process of removing dumb people > from the population with the help of a > bell-tower and a high powered rifle? ;-) lol. OI. Somedays.... -- Onedoctortoanother:"Ifthisismyrectalthermometer,wherethehell'smypen???" == 2 of 3 == Date: Wed, Sep 15 2004 7:57 am From: "xarax" <[EMAIL PROTECTED]> "Thomas G. Marshall" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] /snip/ > As I pointed out already, I too am worried about the potential lack of > documentation concerning the locking details within an object. > > But your interface expansion notion does not hold for existing classes > beyond your control. Say you need to pull something out of a collection or > even a GUI table in one section and move it to another? This operation: > > Entry entry = thang.grab(someplace); > thang.set(entry, elsewhere); > > Is hugely thread unsafe. If you don't do this: > > synchronized(thang) > { > Entry entry = thang.grab(someplace); > thang.set(entry, elsewhere); > } > > then you might wish to make sure that all access goes through another method > of your own construction elsewhere... > > //unified control to Things > public class SafeThingMutator > { > // you prefer synced methods, so ok, I'll use a general > // operation sync supplied by another poster... > public static synchronized > void modify(Runnable operation) > { > operation.run(); > } > } > > ...but what if the Thing is part of a larger Swing GUI element that makes > its /own/ modifications to Thing on its own. /That/ wouldn't go through > your protection routine. > > These are common issues. What would you do? The "correct" solution is to put the "smarts" into the object itself so that the client only tells the object *what* to do, not *how* to do it. Your "thang" object should have a separate method that accepts the "someplace" and "elsewhere" parameters, and performs the entire movement without the client knowing the details of synchronization. Encapsulation is a *good* thing. When the client is forced to specify *how* to do something, that is procedural programming, rather than object-oriented programming. It also runs the risk of breaking subclasses or general contracts between the client and the class. In most cases, when the class does not provide a method to do the new procedural task, the class can be extended to a subclass that can perform the procedural task. Or a new class can be written that encapsulates the other class with composition. Knowledge of the implementation details of the class are centralized in one place, and the client can then use the new method calls in many places. If the implementation needs changing, it's only changed in one place and the client's method calls are unaffected. OTOH, if the client was forced to sprinkle those "synchronized(thang){}" blocks everywhere, it would be a major headache to fix all those blocks when the implementation details change sufficiently to break the client's view of that implementation. A simple-minded example is a client that has an ArrayList and wants to create an array of the elements. The client knows that all of elements are a subtype of "Fubar". { Fubar[] fubars; synchronized(arrayList) { final int kk; kk = arrayList.size(); fubars = new Fubar[kk]; arrayList.toArray(fubars); } } In the above code-snippet, the "arrayList" variable refers to an ArrayList that is shared by multiple threads. The client code is forced to synchronize the list before extracting the size and then extracting the elements. A better solution is to extend the ArrayList class to add a new method: public class MyArrayList extends ArrayList { public Fubar[] getFubars() { Fubar[] result; synchronized(this) { final int kk; kk = size(); result = new Fubar[kk]; toArray(result); } return result; } } Now, the client application can use an instance reference type of MyArrayList, instead of an ArrayList. Instead of a hard-coding synchronized(arrayList){} blocks everywhere, the client simply calls the getFubars() method, which performs the necessary synchronization and returns the array. The client must use the MyArrayList type, instead of a plain ArrayList type. btw: The MyArrayList class should probably use the generics extension "extends ArrayList<Fubar>" to ensure that the client only uses subtypes of Fubar for the array elements. But that's another topic...;) == 3 of 3 == Date: Wed, Sep 15 2004 8:11 am From: "Thomas G. Marshall" <[EMAIL PROTECTED]> xarax coughed up: > "Thomas G. Marshall" > <[EMAIL PROTECTED]> wrote in > message news:[EMAIL PROTECTED] /snip/ >> As I pointed out already, I too am worried about the potential lack >> of documentation concerning the locking details within an object. >> >> But your interface expansion notion does not hold for existing >> classes beyond your control. Say you need to pull something out of >> a collection or even a GUI table in one section and move it to >> another? This operation: >> >> Entry entry = thang.grab(someplace); >> thang.set(entry, elsewhere); >> >> Is hugely thread unsafe. If you don't do this: >> >> synchronized(thang) >> { >> Entry entry = thang.grab(someplace); >> thang.set(entry, elsewhere); >> } >> >> then you might wish to make sure that all access goes through >> another method of your own construction elsewhere... >> >> //unified control to Things >> public class SafeThingMutator >> { >> // you prefer synced methods, so ok, I'll use a >> general // operation sync supplied by another >> poster... public static synchronized >> void modify(Runnable operation) >> { >> operation.run(); >> } >> } >> >> ...but what if the Thing is part of a larger Swing GUI element that >> makes its /own/ modifications to Thing on its own. /That/ wouldn't >> go through your protection routine. >> >> These are common issues. What would you do? > > The "correct" solution is to put the "smarts" into > the object itself so that the client only tells > the object *what* to do, not *how* to do it. Believe me, I prefer that utterly. But you simply cannot always do that. What if you are dealing with a GUI object that needs to update a collection behind the scenes, and the code is not in your control? And the multiple array list issue you point out here is flawed: ...[rip]... > A better solution is to extend the ArrayList > class to add a new method: > > public class MyArrayList > extends ArrayList > { > public Fubar[] getFubars() > { > Fubar[] result; > > synchronized(this) > { > final int kk; > > kk = size(); > result = new Fubar[kk]; > toArray(result); > } > return result; > } > } > > Now, the client application can use an instance > reference type of MyArrayList, instead of an ArrayList. Flawed because the user can still use the ArrayList (superclass) accessor/mutator methods behind your back. That would be very bad design. Instead of extending ArrayList, do you mean extending some sort of synchronized arraylist class (one that sync's on /this/ already)? ...[rip]... -- It'salwaysbeenmygoalinlifetocreateasignaturethatendedwiththeword"blarphoogy" . ========================================================================== TOPIC: J2ME: The Complete Reference http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/29dde018c381d116 ========================================================================== == 1 of 1 == Date: Wed, Sep 15 2004 7:02 am From: "Jeff" <[EMAIL PROTECTED]> That's it, I've also searched Amazon.co.uk, Amazon.com + google. But cannot find info telling that the book covers those topics, or if it doesn't covers them... Thanks anyway for your respond! "Andrew Thompson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Wed, 15 Sep 2004 07:42:57 -0400, Darryl L. Pierce wrote: > >> Jeff wrote: > .. >>> Does this book "J2ME: The Complete Reference" (ISBN: 0072227109 ) cover >>> MIDP 2.0 and CDLC 1.1 API features?? > .. >> The back of the book should tell you what version(s) of the specification >> are covered. > > I went hunting at amazon, and while I found this.. > <http://www.amazon.com/exec/obidos/tg/detail/-/0072227109/ref=sib_rdr_dp/103-4155585-8239062?%5Fencoding=UTF8&no=283155&me=ATVPDKIKX0DER&st=books> > ..it fails to mention the CDLC/MIDP versions, > and the only 'example page' offered is the > front cover. :-( > > -- > 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 ========================================================================== TOPIC: Looking for open source Asteroids game http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6113c3e5f8b103b6 ========================================================================== == 1 of 1 == Date: Wed, Sep 15 2004 7:03 am From: [EMAIL PROTECTED] (Christian Hvid) This one is good: http://jfdoue.free.fr/index.html But it is J2ME which might not be what you want. <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > I appreciate any help that I can find on this. I am looking for an open > source Asteroids / Blasteroids game. If anyone knows where I can find one or > can point me into a better direction as to where I should look that would be > great. > > Thanks, > -J ========================================================================== TOPIC: Getting Exception info in commons.log http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8706074408a502ad ========================================================================== == 1 of 1 == Date: Wed, Sep 15 2004 7:07 am From: "WJ" <[EMAIL PROTECTED]> In log4j 1.2.8 I was able to write a custom appender that extended appenderSkeleton. I was able to pull location information such as the Class, method, and line number of the exception from the LoggingEvent. Is there a way to access this from the log or LogFactory without creating a custom appender? ========================================================================== TOPIC: Literature on boolean naming/usage conventions? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/dabf0085d6427c15 ========================================================================== == 1 of 5 == Date: Wed, Sep 15 2004 7:13 am From: [EMAIL PROTECTED] (Andre Anneck) Hi there, lately I have been involved in a discussion that ended unsatisfactory from my point of view... I couldn't argue against: "Common literature discusses the same problem and the majority of the resources come to the conclusion that the "==" comparator should be avoided if you compare with a boolean." Example: if ( on ) <--// Supposedly literatur say's so. if ( on == true ) <--// Supposedly literatur say's NOT to use this. As you can see this drills down to readablity and maintainability. My Problem is that IMHO having the "==" in place makes code more readable and robust against change-bugs. Sadly the other guy is in charge, but could'nt name any books to enlighten me :-/. Now since I would like to understand his argument before I decompile it :-)... Can anyone of you point me to literature reference that discuss this topic AND give out the rule-of-thumb to avoid using "==" with booleans? Take care, André P.S.: And yes, it's only about Java not C/C++/*any* Naming-Conventions. == 2 of 5 == Date: Wed, Sep 15 2004 7:27 am From: Andrew Thompson <[EMAIL PROTECTED]> On 15 Sep 2004 07:13:34 -0700, Andre Anneck wrote: > if ( on ) <--// Supposedly literatur say's so. Stuff literature, use common sense. > if ( on == true ) <--// Supposedly literatur say's NOT to use this. So, for the opposite, you could write.. if ( on != true ) if ( on == false ) if ( on == !true ) ..or if ( !on == true ) ..depending upon the time of day and your own inclination. > As you can see this drills down to readablity and maintainability. Indeed! And since the first is both more maintainable (shorter) and easier to read, it makes perfect sense to use it. [ The literature was right. ] -- 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 == 3 of 5 == Date: Wed, Sep 15 2004 7:33 am From: Michael Borgwardt <[EMAIL PROTECTED]> Andre Anneck wrote: > if ( on ) <--// Supposedly literatur say's so. > if ( on == true ) <--// Supposedly literatur say's NOT to use this. Dunno about literature, but the second is *definitely* considered bad style by anyone I've ever seen discussing the topic. Usually, it comes up as a typical example of newbie code, written by people who don't understand how expressions are evaluated, or what expressions are. Often, it's even compunded to: if( condition = true) { return true; } else { return false; } > > As you can see this drills down to readablity and maintainability. > > My Problem is that IMHO having the "==" in place makes code more > readable and robust against change-bugs. How so? It's completely redundant. And the clarity should be offered by well-chosen names, not redundant code. Anything expressed by "==true" can be just as well (or better) expressed by giving the variable a meaningful name, one that makes the sequence "if (<condition>) doStuff();" read like an English sentence. Often this can easily be done by including "is" or "has" in the name. == 4 of 5 == Date: Wed, Sep 15 2004 7:36 am From: Michael Borgwardt <[EMAIL PROTECTED]> Michael Borgwardt wrote: > if( condition = true) Of course that should be "==". And provides yet another reason why it should be avoided bad: without the comparison, this common typo and the bugs it causes cannot occur. == 5 of 5 == Date: Wed, Sep 15 2004 8:36 am From: Andrew Thompson <[EMAIL PROTECTED]> On Wed, 15 Sep 2004 16:36:17 +0200, Michael Borgwardt wrote: > Michael Borgwardt wrote: >> if( condition = true) > > Of course that should be "==". LOL.. I thought that *was* your point! (And a good one at that) Now I'll have to go back and reread it, armed with my new understanding that '=' was simply a typo. ;-) -- 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 ========================================================================== TOPIC: JSP CeWolf JFreeChart JSP wrapper - how to set data series colors? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4019ec9a156ad5be ========================================================================== == 1 of 1 == Date: Wed, Sep 15 2004 8:32 am From: "davout" <[EMAIL PROTECTED]> I'm using the CeWolf taglib wrapper around the JFreeChart charting library in my JSP pages. Does anybody know how to set the line colors for XY time series charts? I can see how its done in JFreeChart - but there's no instruction on how this is achieved via CeWolf. ========================================================================== TOPIC: Browser Back Button (IE) Caching Problem in Struts Land http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2661162f4dfe878 ========================================================================== == 1 of 1 == Date: Wed, Sep 15 2004 8:09 am From: [EMAIL PROTECTED] (praveen) Andrew: I have implemented a "Cancel" and a "Back" button within the scope of the page-flow too, but apparently, the end-users are so fond of that darned "Back" button which I am sure users will love, but programmers hate! :) As for testing, I haven't done behavioral testing per se to verify the bug in IE, largely due to the fact that I ran out of time trying to salvage an older code base by a "renegade" consultant [:)] and refactor it into a robust and a performance oriented J2EE/Struts app. To top it off, Internet Explorer is the standard across the client-site! David: I can't agree with you more! Apparently, there is a "battle of apps" in the making since the App I am building is supposed to be a new release of an older JSP & Servlets based App (Model 1 per se!). Nonetheless, I am certain that there should be a way, since multiple/duplicate form submission due to cache problems can easily be controlled by using the Synchronizer pattern! Clients rarely care about technology constraints and look forward to an easy and a navigable GUI! On a serious note [:)], If I can't make it happen, I can't sleep soundly without knowing why I couldn't make it happen! Thank you both for your comments! Hope you guys have a wonderful day.. Praveen ======================================================================= You received this message because you are subscribed to the Google Groups "comp.lang.java.programmer". comp.lang.java.programmer [EMAIL PROTECTED] Change your subscription type & other preferences: * click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe Report abuse: * send email explaining the problem to [EMAIL PROTECTED] Unsubscribe: * click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe ======================================================================= Google Groups: http://groups-beta.google.com ------------------------ Yahoo! Groups Sponsor --------------------~--> Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar. Now with Pop-Up Blocker. Get it for free! http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/BCfwlB/TM --------------------------------------------------------------------~-> <a href=http://English-12948197573.SpamPoison.com>Fight Spam! Click Here!</a> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/kumpulan/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
