Owner: Down Home Country Coding With Scott Selikoff URL:http://www.selikoff.net/blog/ Join Date: Fri, 22 Aug 2008 23:10:55 -0500 Rating:0 Site Description: A Java/J2EE coding blog Site statistics:Click here
J2EE: Why EJB2 CMP was Doomed to Failure 2008-08-22 00:29:18 For those in the J2EE world, one of the hottest, most contentious topics that has arisen is what went wrong with EJB, version 2. For those not familiar with the subject, I’ll try to provide a brief description. In 2001, Sun released a specification for connecting a Java object, called an Enterprise Java [...]
Computers as Infallible in Pulp Culture 2008-08-12 12:01:23 I was watching an old episode of Star Trek the original series the other day and was intrigued that they portrayed computers as infallible, pure logic devices. In the episode, Kirk’s on trial for his life/command because a computer record shows him making a mistake. Throughout the episode there are numerous comments such [...]
Question mark ‘?’ characters as text in JDBC 2008-08-04 16:02:05 Many people wonder how insert strings containing question mark characters into their database queries via JDBC. For those unfamiliar with the problem, ? is a reserved character in JDBC queries for parameterizing inputs. For example, if you have run the same query searching for a user but each time with a different name, [...] Read more:Question
Transferring Tivo episodes to your iPhone with a Mac and PC 2008-08-01 14:34:39 If you’re like me and you own a Tivo HD/Tivo Series3 and an Apple iPhone
/iTouch/iPod, you may be wondering, can I transfer shows from my Tivo to my portable device? The answer is yes, although the path you choose depends a lot about your home setup. For example, I have a MacBook and [...] Read more:episodes
, Transferring
Finally Closing of JDBC Resources 2008-07-30 16:00:58 I love reading Alex’s The Daily WTF and I noticed the recent Finally
WTF is relevant to JDBC in an important way. All *good* JDBC developers already know you should close your result sets, statements, and connections (in that order) in a finally block when you are done with them, but do you all [...] Read more:Resources
Because For loops are vastly superior to If statements 2008-07-25 21:00:51 Because For loops are vastly superior to If statements I give my own WTF for the day:
private boolean someMethod() {
int count = 0;
ResultSet rs = statement.executeQuery(
“select count(*) FROM …”);
for ( ; rs.next(); )
premature optimization 2008-09-06 13:45:20 Donald Knuth is often quoted as saying “premature optimization is the root of all evil.”
Often in the JavaRanch forums, we see questions like:
which is faster stringBuilder.append(’a') or “a” + “b”
(The answer is these two expressions are supposed to generate to the same byte code if used on the same line.)
My first thought when I see [...]
Database Key Generation in Java Applications 2008-09-03 01:11:16 All JDBC programmers at one time or another have had to deal with key generation for new records, or more precisely, how to retrieve keys for newly created records. This article discusses some of the techniques and limitations offered to Java JDBC programmers.
Unique Keys
Most (good) database systems assign a unique key, usually a large [...] Read more:Applications
, Database
, Generation
copy & paste 2008-08-30 10:13:12 Virtually all of us are guilty of copy and paste
“reuse.” There are different types of reuse though and each come with their own set of problems and gotchas.
Copy/paste a method or large code snippet
This is the kind of reuse that almost everyone will agree is bad. When all is said and done there are [...]
EJB3 - annotations vs xml 2008-08-24 08:34:10 Scott’s recent post on EJB3 got me thinking about annotations as a “replacement” for XML.
By now, we all know why shoving everything in XML isn’t the best of ideas. I think shoving everything in Java code is bad too. In particular deployment time concerns (like security) shouldn’t require a recompile.
JEE 5 offers the ability to [...]
Cablevision Hijacks DNS Error Pages 2008-09-30 01:31:51 I just noticed Cablevision’s Optimum Online service has begun hijacking DNS Error pages with, you guessed it, ad-sponsored results:
And apparently I’m not the only one that noticed: Justin Flood and Dan. As Justin Flood reported Cablevision has secretly adjusted their TOS to reflect this morally questionable service:
The preceding search results page is displayed to [...] Read more:Pages
“code sense” 2008-09-24 19:08:21 “Clean Code” by Robert C Martin uses the phrase “code sense” when describing a developer’s relationship with clean code. I like this phrase. It represents the intuition that goes with looking at code.
He writes about how most people can identify messy code. The problem comes in how to make it better. This “code sense” lets [...]
“total cost of owning a mess” 2008-09-22 22:07:26 When I wrote about defending the code, I described how we don’t want to meet a date at the expense of our ability to meet future dates. This applies to future projects as well. If we meet the production date for the first project my producing a shaky pile of code, what is going to [...]
“it’s your job to defend the code” 2008-09-20 11:08:48 As I read “Clean Code” by Robert C Martin, I was particular drawn to the passage about why unrealistic commitments should not be an excuse for writing bad code. He points out that while it is a manager’s job to “defend the schedule and requirements”, it is a developer’s “job to defend the code with [...]
Database Performance - Block Updates over the Internet 2008-09-14 16:49:20 When you run a website within a hosted web environment, you often do not have the luxury of direct or intranet access to your database anymore. With remoting tools such as phpMyAdmin becoming increasingly popular among web hosting providers, remote connections over the internet may be the only access a user has to their [...] Read more:Database
, Internet
, Performance
what to do for nulls 2008-10-17 12:10:38 A logical follow up to null checking in the extreme and Never return Null Arrays, is what we should be doing when a null does get returned.
The problem
Consider the following method:
public void method() {
StringBuilder builder = UnreliableCode.createBuilder();
if ( builder != null ) {
builder.append(“data”);
}
This time, a null check is
Never return Null Arrays! 2008-10-15 01:03:23 Continuing on Jeanne’s theme of nulls, its a pet peeve of mine when I come across code that returns null arrays instead of empty arrays. The purpose of this post is to discuss some of the reasons why its a good practice to return empty arrays over null arrays, including Collection objects or typed [...]
null checking in the extreme 2008-10-13 13:23:07 In Java, we’re told to check for nulls to avoid unexpected null pointer exceptions. This can be taken too far though. Consider the following code:
StringBuilder builder = new StringBuilder():
if ( builder != null ) {
builder.append(“data”);
}
When did builder have the opportunity to become null? By definition, a constructor creates an obje Read more:checking
Down Time: Register.com Down? 2008-10-04 16:38:27 As many of our readers may have noticed we went down for over an hour on Saturday, but in all my years of hosting this is the first time I’ve seen such a large outage caused by the domain registrar failing. Apparently, a number of Register
.com’s partner name servers went down (although Register.com itself [...]
how to view source code generated by dojo 2008-10-03 18:52:07 Dojo abstracts alot from you when creating widgets. So how do you see the real source? The source is important when testing certain types of requirements. Accessibility is one of those requirements.
Normal code
As an example, I wrote a simple line of code to display a Dojo widget for currency.
<input type=”text” id=”amount” name=”amt” dojoType=”d
the different levels of a question 2008-11-01 15:09:16 People with differentlevels
of experience approach tend to approach a question in different ways. This is something I see frequently on JavaRanch.
An example
The ideas apply to many questions, but I’ll use “how do I disable the browser back button” as a common example. Consider some answers to this:
1) In Internet Explorer, you do something [...]
what is mentoring? 2008-11-30 13:26:26 What is mentoring? Listening? Advising? Helping? I was looking for the definition of mentoring today and came across some interesting things.
dictionary.com lists two definitions:
1, a wise and trusted counselor or teacher.
2. an influential senior sponsor or supporter
These are both correct, but not very helpful to me. Sometime later I came across an article that really [...]
This Coupon Requires a Time Machine 2008-11-29 12:26:56 Hope everyone is enjoying the black-Friday/cyber-Monday sales. Personally, I haven’t seen many good ones this year but I did come across this gem in my inbox. It offers an impressive 20% off all their products if you happen to own a time machine:
Hope everyone had a nice Thanksgiving!
-Scott Read more:Coupon
, Machine
Denormalized Databases: A better example 2008-11-23 03:34:57 There were a number of comments about my recent article on the negative effects of too much database normalization so allow me to expand the topic a little more. The most consistent comment I saw was that while many of you agreed with me in principle that too much normalization can lead to poor [...] Read more:better
, Databases
Why too much Database Normalization can be a Bad Thing 2008-11-19 09:01:54 As someone with a long history in database optimization and who even did their Master’s project on Database
normalization, I’m probably the last person in the world to argue against database normalization. From a theoretical standpoint, database normalization is a wonderful thing, helping to organize your data into easy-to-manage and understandable parts. For [...] Read more:Thing
why do we violate law of demeter? 2008-11-15 14:48:39 I was watching a Google Tech Talk on Dependency Injection. Sixteen minutes in the speaker gave an interesting example of the Law of Demeter: If buying item for $25 in store, do you hand clerk $25 or give clerk your wallet and have him/her retrieve the $25.
This got me thinking about why we so frequently [...] Read more:violate