The Artima Developer Community
Sponsored Link

Java Answers Forum
Concurrent Singleton usage - Limitations ?

16 replies on 2 pages. Most recent reply: Jul 4, 2004 10:57 PM by Shashank D. Jha

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 16 replies on 2 pages [ « | 1 2 ]
Kishori Sharan

Posts: 211
Nickname: kishori
Registered: Feb, 2002

Re: Concurrent Singleton usage - Limitations ? Posted: Jul 4, 2004 5:07 PM
Reply to this message Reply
Advertisement
A philosopher doesn't want to cross a bridge. Reason: A bridge may collapse any time. Is he wrong? Theoretically not, practically yes. Millions of people cross bridges every minute. Some of them do die because it collapses. Is it a limitation of crossing a bridge that the bridge collapses sometimes?

When you talk about overheads, bottlenecks and single point of access, then you are talking about excecution of a few (in the range of 5 to 100) instructions. With the given fast processors and cheap memory in current market, these overheads are only theoretical. Let us say some program has to execute 100 more instructions. How much time it takes for processor to execute 100 instructions? It is nano seconds. So, one request will take some nano seconds more. I and any practical programmer will not consider a few nano-seconds as an overhead. But, theoretically, yes, it is overhead. Of course, I am not talking about real-time apps here.

When COBOL programmers used just two digits to represent a year, it was justified. Because, memory was two expensive and everyone's intention was to save memory. However, if someone talks about advantages and disadvantages of using short vs int in a Java program as a local variable then I will call him the philosopher not willing to cross the bridge.

At the same time, I do agree that memory and overhead considerations are fine (in fact, necessary) as far as mission-critical application developement or a kind of generic server developments are concerned. But, as far as end-user app developements are concerned, thinking about a few bits and a executing a few more instructions are not worth.

As far as those articles at Sun and IBM sites are concerned, I will advise just read them and use your brain when you are wrting your own programs. Those guys are paid to write those articles. When you write an article about something, you are told to have some advantages as well as some disavantages. If you don't mention some disadvantages, then editor will send that article back to you for review and ask you to consider some disadvantages whatsoever, just for the sake completeness. So, the writer has to come up with some disadvantages, however impractical it may be. If you are interested, I will send you some links where one article is saying double-checking is not the proper solution, in case, you don't make getInstance() method synchronized and go for lazy initialization. It may result in problems. Other article is saying, if you don't want to make getInstance() synchronized and want to go for lazy initialization then double-checking is the solution. I read both articles on net. Both of them are very famous and respected sites for Java articles. What should I do? I just use my brain instead of taking those articles word-by-word. All theory you learn by reading these articles are good if you have to present a topic for 30 minutes to your audience. However, when you have your fingers are on keyboard then only the practical aspects will bear fruits.

I will leave it up to the programmer to decide whether he wants to be called a philosopher or a programmer.

Thanks
Kishori

Shashank D. Jha

Posts: 68
Nickname: shashankd
Registered: May, 2004

Re: Concurrent Singleton usage - Limitations ? Posted: Jul 4, 2004 10:57 PM
Reply to this message Reply
Hi Kishori,

Your quote:
A philosopher doesn't want to cross a bridge. Reason: A bridge may collapse any time. Is he wrong? Theoretically not, practically yes. Millions of people cross bridges every minute. Some of them do die because it collapses. Is it a limitation of crossing a bridge that the bridge collapses sometimes?

My reply:
This is what I am also saying, that bridge itself is not providing any limitation its the context (lots of load if you put onto it..) that leads to its collapse.

Your quote:
When you talk about overheads, bottlenecks and single point of access, then you are talking about excecution of a few (in the range of 5 to 100) instructions. With the given fast processors and cheap memory in current market, these overheads are only theoretical. Let us say some program has to execute 100 more instructions. How much time it takes for processor to execute 100 instructions? It is nano seconds. So, one request will take some nano seconds more. I and any practical programmer will not consider a few nano-seconds as an overhead. But, theoretically, yes, it is overhead. Of course, I am not talking about real-time apps here.

My quote:
I am not sure if you are aware that growth in software requrement in terms of performance etc. is more then what has been provided by growth in harware. Ask Java guys!!

Moreover growth in harware or processing sped doesnt mean we should go and arbitrarily go on using variables and do unnecessary assignments etc. There is also soemthing badly done, wrong decisions, could have been avoided kind of thing that comes from our experience. Independent of hardware development. In software we are following some architecture, design principals that we do independent of most of the cpu/hardware architecture where we going to deploy our application. And these software decisions, there is still soemthing called good design and something bad. Choice a develoer has to make.

Your quote:
At the same time, I do agree that memory and overhead considerations are fine (in fact, necessary) as far as mission-critical application developement or a kind of generic server developments are concerned. But, as far as end-user app developements are concerned, thinking about a few bits and a executing a few more instructions are not worth.

My quote:
I mission critical applications you dont have a choice to take wrong decision. But in general purpose you should not take wrong design decisions that mars its longevity, maintenance. You must be aware that most of the software spends more of its time in maintainence then development. And wrong design/selection of singleton makes it difficult to maintain/change the object behaviour without affecting its users. As users are aware that object is singleton!!

Your quote:
As far as those articles at Sun and IBM sites are concerned, I will advise just read them and use your brain when you are wrting your own programs. Those guys are paid to write those articles. When you write an article about something, you are told to have some advantages as well as some disavantages. If you don't mention some disadvantages, then editor will send that article back to you for review and ask you to consider some disadvantages whatsoever, just for the sake completeness. So, the writer has to come up with some disadvantages, however impractical it may be. If you are interested, I will send you some links where one article is saying double-checking is not the proper solution, in case, you don't make getInstance() method synchronized and go for lazy initialization. It may result in problems. Other article is saying, if you don't want to make getInstance() synchronized and want to go for lazy initialization then double-checking is the solution. I read both articles on net. Both of them are very famous and respected sites for Java articles. What should I do?
My quote:
This is what my point is, you should and must analyze the reasons (whether for advantages or limitations) and take your decision depending on your context of usage.

Your quote:
I just use my brain instead of taking those articles word-by-word. All theory you learn by reading these articles are good if you have to present a topic for 30 minutes to your audience.
My Quote:
you are here sounding like some naive/un-experienced guy.
I am not sure of this. We depend a lot on the knowledge created by others and so should take advantages of the knowledge already existing. That saves a lot in terms of possible limitations as well as opens our eyes to immense possibilites of its usage as well.

I believe reading article, reding whitepapers, do enhance our own understanding of problem and solution.

This is not to say we close our eyes and accept whatever is suggested. The suggestion is always with respect to context it is talked about.

Your Quote:
However, when you have your fingers are on keyboard then only the practical aspects will bear fruits.
My Quote:
This is problem with most of the softwares developed. Instead of spending more time in analysis and design we do everything with code as and when it comes to out mind.
Thats why most of code/softare spend most of there time in getting debugged. That is maintainence becomes a nightmare. Small changes are difficult to make and list is on..


I will suggest to everyone, whether new to development or veternas, do spend considerable time in analysis, design phase then merely implementing some design as it comes to mind.


regards,
Shashank

Flat View: This topic has 16 replies on 2 pages [ « | 1  2 ]
Topic: how to get executable file in netbeans ide 3.5? Previous Topic   Next Topic Topic: Java not working at the library?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use