Path: csiph.com!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Lars Enderin Newsgroups: comp.lang.java.programmer Subject: Re: Updating code from jdk1.2 to recent jdk SE 1.6 Date: Thu, 12 Jul 2012 00:06:33 +0200 Organization: albasani.net Lines: 173 Message-ID: <4FFDF8E9.6090804@telia.com> References: <725fbc58-fab7-4e70-9f1a-b2e393fdeca9@googlegroups.com> <9e6d548c-2aec-400d-84ac-1ee21421264f@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net 77nZg+fZ6Cg4EwBLBS/RjvLb0vNK+1cnkV8OMnt/RgUbbHSNNiptQDs5kyfnF+DHylDAO3neHce4geXhDTp2sKqOh6z67BmcSmv0ED8MfiiTy/yuCiMsNYtQq6sqwXPR NNTP-Posting-Date: Wed, 11 Jul 2012 22:06:38 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="dCRUFf6P1Jd8V/SiyQ3YYpgcStzX3GGXhZ6HXZ9rECmUb+SNd1WrfVOz5EMvYpA4l87iInzfZFuZ+h4rJqjB0lGiwN58upDLDpppVu19wjTqaBTvr5y7yXFplOv38Q7o"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 In-Reply-To: <9e6d548c-2aec-400d-84ac-1ee21421264f@googlegroups.com> Cancel-Lock: sha1:c0USDN5iRKjJemrza7JbHoEB/lU= Xref: csiph.com comp.lang.java.programmer:15947 2012-07-11 23:02, Lew skrev: > On Wednesday, July 11, 2012 12:27:43 AM UTC-7, Sanny wrote: >> > &gt; Currently I put data in String. >> > >> > What do you mean by &quot;data&quot;? > > Please attribute your quotes. > >> Say I have employee data: Name, Tel, City, Salary. >> >> Either I can put them in a class or Comma Separated in single String. > > Creating a type is better. > >> Creating a class then sending that class to a function or database is not much efficient. > > It's extremely efficient, as Silvio and I have both pointed out. > >> But comma separated String you just have to send one string and each Value is separated in the String using "separator comma". > > Antipattern. > >> But addition and removing data from String is very inefficient. >> > ... [snip] ... >> >> If I use Classes I have to send Employee class to function > > No, you don't. You send a *reference* to an *instance* of that class. > >> 1. function changetelnum(EmployeeClass ss, long new_tel, long old_tel) >> { >> //STEPs LIST >> //Search Class with old tel number > > You don't search any class (let alone 'Class'). > >> //replace tel number by new_tel >> // return(ss); >> } >> >> What do you think which one is faster Sending String or Sending a Class? for changing tel number in an Emplyee data? > > It's not a question of what anyone thinks, but of what is true. > >> Is there any other data stricture that does it better? > > The data structure that matches the entity you're modeling. > > Either you have modeled your domain or you have not. > > This is objectively verifiable (i.e., disprovable). Look at the logical > description of any given entity in your model. Does your class definition > match the logical definition? Then it's the right structure, otherwise > not. > >> When I pass a parameter Class "EmployeeClass" Does the Java Compiler create a new Class ss "EmployeeClass". > > No. > > As you would know if you read the documentation. > > RTFM. > >> Is there any other way to change telnumber? > > The right way. > > E.g., > > public class Person > { > private String name; > private String telephone; > public String getName() > { > return name; > } > public void setName(String name) > { > this.name = name; > } > public void setTelephone(String telephone) > { > this.telephone = telephone; > } > public String getTelephone() > { > return telephone; > } > } > >> Is there something in new versions of Java that can do these things faster? > > What was wrong with earlier answers to this very question? > >> Other thing is How much memory does a class take and a String will take. > > That depends. > >> Say I have an array of 1 million Employees. >> >> String[1million] How many MB this array will take? > > That depends. > >> EmployeeClass[1million] How many MB this array will take? >> >> { >> Name: >> Tel: >> City: >> Salary: >> } > > That's not Java. > >> Is there a way to save memory for shorter Strings. Say having just 15 digit string? Or all strings are of 256 char size? > > 'String's are of varying length, and we don't call the characters > in a 'String' "digits". > > Read the Java tutorials. > > RTFM. > >> How much Max memory an Applet can take in an ordinary computer. > > That depends. > >> If a Computer has 1 GB RAM can my applet utilize all that RAM? or the Browser will only give a few > > No. > >> MB? Is there any way to request more memory by Applet from web-Browser if Available RAM in Computer is 2GB or 4GB? > > No. > >> How can my Applet know how much Memory is available to the applet? > > There are some calls in the API, but it smells like this is the wrong > approach. > > Your applet should not care. > >> How can an Applet know how many cores are present in System and assign each thread to a separate Core? > > It cannot. > > It should not. > > Some of what you're asking you already asked and got answers. > > Why are you asking again? > > Did you read the earlier answers? > > Why not? > For some reason, there is no text shown in Thunderbird for your (Lew's) message, which I am commenting on, but the text shows, quoted, when I compose the comment. It looks like Google Groups does not convert from HTML to text/plain correctly. My message window for Lew's reply shows the same header as Sanny's message, and no text. Some structural error in the mbox-formatted inbox for this group, it seems. -- Lars Enderin