Would experienced programmers agree?

I was looking at Javaranch, and found the following stated:
3.1 - Constructs to Avoid
Never use do..while. (examples and reasoning)
Never use return in the middle of a method. (reasoning)
Never use continue. (reasoning)
Never use break other than in a switch statement. (reasoning)
3.2 - Do Not Compound Increment Or Decrement Operators
Use a separate line for an increment or decrement. (examples and reasoning)
Never use pre-increment or pre-decrement (examples and reasoning)
3.3 - Initialization
Declare variables as close as possible to where they are used. (examples)
3.4 - Access
All fields must be private, except for some constants.
The reasonings are pretty good. But I have never come across any textbook that gives the same tips as that at Javaranch? Why is that? Does anyones company also follow the same principles as this Javaranch page?

I was looking at Javaranch, and found the following
stated:MIght help to post the link.
>
3.1 - Constructs to Avoid
Never use do..while. (examples and reasoning)
Never use return in the middle of a method.
(reasoning)
Never use continue. (reasoning)
Never use break other than in a switch statement.
(reasoning)
I disagree.
I do however seldom use any of those.
3.2 - Do Not Compound Increment Or Decrement
Operators
Use a separate line for an increment or decrement.
(examples and reasoning)
Presumably this means something like "doSomething(i++)"
I disagree.
I use syntax like the following (pseudo code) to extract stuff from result sets.
       int i=0;
       string customer = rs.getString(i++);
       string addr1 = rs.getString(i++);
       string addr2 = rs.getString(i++);
Breaking the above into seperate lines would not only make it harder to read it would make it more prone to mistakes when adding or removing a field.
Never use pre-increment or pre-decrement (examples
and reasoning)
3.3 - Initialization
Declare variables as close as possible to where they
are used. (examples)Yes.
3.4 - Access
All fields must be private, except for some
constants.
Nope.
See DTO in the java blueprints.
The reasonings are pretty good. But I have never come
across any textbook that gives the same tips as that
at Javaranch? Why is that? Does anyones company also
follow the same principles as this Javaranch page?Companies? Probably.
Of course there are many companies that think coding guidelines make the code "better" and yet completely ignore process control. Formal process control has been shown to improve in numerous studies to improve code quality while I have never seen a single study that demonstrated that coding guidelines do.

Similar Messages

  • HT6439 This is probably the most useful article I have seen here. Would anyone else agree?

    This is probably the most useful article I have seen here. Would anyone else agree? 10/10

    No. I enjoyed the album.

  • Finding Experienced Labview Programmers

    I have repeatedly run into the same problem with labview development, a lack of experienced programmers.  Over the last several years I have seen an unreal growth is the market for labview applications but it doesnt appear that the developer community is keeping up with this demand.  Where can I find Labview programmers to fill this demand.  The job postings outnumber the seekers and there are many great positions unfilled.  What a crazy thing.  I find labview programming is very fulfilling and a great career.  Are there any Experienced programmers looking for jobs or is this a lost cause?
    Paul Falkenstein
    Coleman Technologies Inc.
    CLA, CPI, AIA-Vision
    Labview 4.0- 2013, RT, Vision, FPGA

    Are you offering a job?
    Based on what I've seen over the past 13 years, there seems to be a number of reasons for this:
    Market share. Let's face it: LabVIEW isn't as widely used as other, more traditional languages. There was an article I had seen a while ago that compared the market share of LabVIEW vs other programming languages. Let's just say that LabVIEW aficionados needed to turn away.
    Most placement firms simply don't know about the language, so they (a) don't know who's working with it, and (b) don't know about the job offerings, so they can't tie the possibilities to the ones looking for work. I can't tell you the number of times I've talked to recruiters who've called me and when I told them I used LabVIEW their response is "Lab-what?".
    Another is simply that LabVIEW programming requires a different mindset, so it's not readily taught in schools. Not taught = no graduates who know the language = no potential workers. Why isn't it taught in schools? Well, that can start a whole debate, and I'm not going there.
    Yet another reason, it seems to me, is that LabVIEW isn't as flexible in terms of the kinds of programs you can write. I say this not to disparage LabVIEW, or start a flame war, but simply as a realistic assessment based purely on my own experience. There's just some stuff that you cannot do in LabVIEW, but can easily do in C/VB/C#/Java/whatever. Heck, I recently coded up a large .NET app in C# that would have been impossible in LabVIEW.
    Money. And by this I mean how much people are paid. LabVIEW jobs tend to start as test engineer jobs, which are nowhere near as highly paid as a C or C/database programmer. There are exceptions, obviously.
    Corollary to (2) and (5): Sometimes LabVIEW jobs are found in test engineer positions on job boards, as opposed to "programming" jobs. This sometimes makes it difficult to find jobs.
    Is it a lost cause? Hardly. Have you gotten no responses posting on the LabVIEW openings board here?

  • Experienced SP Admin but new to DEV

    I'm not sure if this is the right area to ask this but i'm an experienced SharePoint Administrator and i would like to get into the world of .net and C# development for SharePoint.  I'd like to expand my expertise but i'm not sure where to start.  Most
    of the SharePoint coding books i've seen are for experienced programmers that are new to SP, not the other way around.
    I have all the tools needed to get started, ie. test environment with Visual Studio.  I just want to make sure i'm being productive and not just floundering with it.
    Does anyone have suggestions?  Books?  Classes?

    Hi Matt,
    There are plenty of book available in market for beginners e.g.
    https://www.google.co.uk/?gfe_rd=cr&ei=F-JbVMfvO-rH8gefq4GIAQ&gws_rd=ssl#tbm=bks&q=Beginning+SharePoint+development
    Regards,
    Brij K

  • MacBook Pro almost frooze, would like to know why

    Hey
    About a half hour ago I came back to my computer and it was extremely sluggish. I began shutting applications down but only with the Activity Monitor running the Active RAM was 1.15 GBs. I tried to open up my console but it would not respond. I eventually had to do a hard shut down since it was taking way too long to restart.
    It booted up just fine and is now working well. When I went to check the System.Log in the Console, the last log was at 12:20 am, before jumping to 12:56 when I rebooted.
    Does anyone know why this may have happened?
    Here is a sample of the log. The entire log for 12:20 is insanely long, so I am only posting the last bit of it before I shut down.
    Nov 6 00:20:27 BETA kernel[0]: 0 [Level 3] [ReadUID 0] [Facility com.apple.system.fs] [DevNode devfs] [MountPt /dev] [Path /dev/disk3s2] [FSLogMsgID 1155533442] [FSLogMsgOrder Last]
    Nov 6 00:20:27 BETA kernel[0]: s] [ErrType IO] [ErrNo 5] [IOType Read] [PBlkNum 35797] [LBlkNum 35797] [FSLogMsgID 185284135] [FSLogMsgOrder First]
    Nov 6 00:20:27 BETA kernel[0]: l: disk3s2: replay_journal: from: 3119616 to: 3309056 (joffset 0xe81000)
    Nov 6 00:20:27 BETA kernel[0]: disk3s2: 0x5 (UNDEFINED).
    Nov 6 00:20:27 BETA kernel[0]: : disk3s2: dojnlio: strategy err 0x5
    Nov 6 00:20:27 BETA kernel[0]: ck @ 0x2f9a00!
    Nov 6 00:20:27 BETA kernel[0]: jnl: disk3s2: restarting journal replay (3119616 - 3309056)!
    Nov 6 00:20:27 BETA kernel[0]: s] [DevNode devfs] [MountPt /dev] [Path /dev/disk3s2] [FSLogMsgID 1396361971] [FSLogMsgOrder Last]
    Nov 6 00:20:27 BETA kernel[0]: jnl: disk3s2: dojnlio: strategy err 0x5
    Nov 6 00:20:27 BETA kernel[0]: BlkNum 35797] [LBlkNum 35797] [FSLogMsgID 1742336863] [FSLogMsgOrder First]
    Nov 6 00:20:27 BETA kernel[0]: : disk3s2: replay_journal: from: 3119616 to: 3309056 (joffset 0xe81000)
    Nov 6 00:20:27 BETA kernel[0]: disk3s2: 0x5 (UNDEFINED).
    Nov 6 00:20:27 BETA kernel[0]:
    Nov 6 00:20:27 BETA kernel[0]: jnl: disk3s2: restarting journal replay (3119616 - 3309056)!
    Nov 6 00:20:27 BETA kernel[0]: jnl: disk3s2: replay_journal: from: 3119616 to:] [FSLogMsgID 536802349] [FSLogMsgOrder Last]
    Nov 6 00:20:27 BETA kernel[0]: jnl: disk3s2: dojnlio: strategy err 0x5
    Nov 6 00:20:27 BETA kernel[0]: jnl: 7] [LBlkNum 35797] [FSLogMsgID 1642322114] [FSLogMsgOrder First]
    Nov 6 00:20:27 BETA kernel[0]:
    Nov 6 00:20:27 BETA kernel[0]: isk3s2: replay_journal: from: 3119616 to: 3309056 (joffset 0xe81000)
    Nov 6 00:20:27 BETA kernel[0]: diLogMsgOrder Last]
    Nov 6 00:20:27 BETA kernel[0]: jnl: disk3s2: dojnlio: strategy err 0x5
    Nov 6 00:20:27 BETA kernel[0]: jnl: disk3s2: replay_journal: Could not read block list header block @ 0x2f9a00!
    Nov 6 00:20:27 BETA kernel[0]: 0 [Level 3] [ReadUID 0] [Facility com.apple.system.fs] [DevNode devfs] [MountPt /dev] [Path /dev/disk3s2] [FSLogMsgID 1143077769] [FSLogMsgOrdersystem.fs] [ErrType IO] [ErrNo 5] [IOType Read] [PBlkNum 35797] [LBlkNum 35797] [FSLogMsgID 919859420] [FSLogMsgOrder First]
    Nov 6 00:20:27 BETA kernel[0]: l: disk3s2: replay_journal: from: 3119616 to: 3309056 (joffset 0xe81000)
    Nov 6 00:20:27 BETA kernel[0]: disk3s2: 0x5 (UNDEFINED).
    Nov 6 00:20:27 BETA kernel[0]:
    Nov 6 00:20:27 BETA kernel[0]: jnl: disk3s2: restarting journal replay (m.apple.system.fs] [DevNode devfs] [MountPt /dev]NED).
    Nov 6 00:20:27 BETA kernel[0]: jnl: disk3s2: replay_journal: from: 3119616 to: 3309056 (joffset 0xe81000)
    Nov 6 00:20:27 BETA kernel[0]: FSLogMsgOrder Last]
    Nov 6 00:20:27 BETA kernel[0]: jnl: disk3s2: dojnlio: strategy err 0x5
    Nov 6 00:20:27 BETA kernel[0]: jnl: disk3s2: replay_journal: Could not read block list header block @ 0x2f9a00!
    Nov 6 00:20:27 BETA kernel[0]: 0 [Level 3] [ReadUID 0] [Facility com.apple.system.fs] [DevNode devfs] [MountPt /dev] [Path /dev/disk3s2] [FSLogMsgID 1820291850] [FSLogMsgOrder Last]
    Nov 6 00:20:27 BETA kernel[0]: jnl: disk3s2: dojnlio: strategy err 0x5
    Nov 6 00:20:27 BETA kernel[0]: jnl: disk3s2: replay_journal: Could not readD 143431717] [FSLogMsgOrder First]
    Nov 6 00:20:27 BETA kernel[0]:
    Nov 6 00:20:27 BETA kernel[0]: jnl: disk3s2: replay_journal: from: 3119616 to: 3309056 (joffset08059340] [FSLogMsgOrder Last]
    Nov 6 00:20:27 BETA kernel[0]: jnl: disk3s2: dojnlio: strategy err 0x5
    Nov 6 00:20:27 BETA kernel[0]: jnl: disk3s2: replay_journal: Could not read block list header block @ 0x2f9a00!
    Nov 6 00:20:27 BETA kernel[0]: 0 [Level 3] [ReadUID 0] [Facility com.apple.system.fs] [DevNode devfs] [MountPt /dev] [Path /dev/disk3s2] [FSLogMsgID 511161763] [FSLogMsgOrder Last]
    Nov 6 00:20:27 BETA kernel[0]: em.fs] [ErrType IO] [ErrNo 5] [IOType Read] [PBlkNum 35797] [LBlkNum 35797] [FSLogMsgID 521653519] [FSLogMsgOrder First]
    Nov 6 00:20:27 BETA kernel[0]: l: disk3s2: replay_journal: from: 3119616 to: 3309056 (joffset 0xe81000)
    Nov 6 00:20:27 BETA kernel[0]: disk3s2: 0x5 (UNDEFINED).
    Nov 6 00:20:27 BETA kernel[0]: disk3s2: dojnlio: strategy err 0x5
    Nov 6 00:20:27 BETA kernel[0]: jnl: disk3s2: replay_journal: Could not read block list header block @ 0x
    Nov 6 00:20:27 BETA kernel[0]:
    Nov 6 00:20:27 BETA kernel[0]: jnl: disk3s2: replay_journal: from: 3119616 to: 3309056 (joffset 0xe8 [FSLogMsgOrder Last]
    Nov 6 00:20:27 BETA kernel[0]: jnl: disk3s2: dojnlio: strategy err 0x5
    Nov 6 00:20:27 BETA kernel[0]: jnl: disk3s2: replay_journal: CouldLogMsgID 260772780] [FSLogMsgOrder First]
    Nov 6 00:20:27 BETA kernel[0]:
    Nov 6 00:20:27 BETA kernel[0]: disk3s2: 0x5 (UNDEFINED).
    Nov 6 00:20:27 BETA kernel[0]:
    Nov 6 00:20:27 BETA kernel[0]: jnl: disk3s2: replay_journal: from: 3119dev/disk3s2] [FSLogMsgID 237818421] [FSLogMsgOrder Last]
    Nov 6 00:20:27 BETA kernel[0]: jnl: disk3s2: dojnlio: strategy err 0x5
    Nov 6 00:20:27 BETA kernel[0]: [PBlkNum 35797] [LBlkNum 35797] [FSLogMsgID 1266575621] [FSLogMsgOrder First]
    Nov 6 00:20:28 BETA kernel[0]: vel 3] [ReadUID 0] [Facility com.apple.system.fs] [ErrType IO] [ErrNo 5] [IOType Read] [PBlkNum 35797] [LBlkNum 35797] [FSLogMsgID 1745538543] [FSLogMsgOrde309056)!
    Nov 6 00:20:28 BETA kernel[0]: jnl: disk3s2: replay_journal: [Path /dev/disk3s2] [FSLogMsgID 1347691822] [FSLogMsgOrder Last]
    Nov 6 00:20:28 BETA kernel[0]: jnl: disk3s2: dojnlio: strategy err 0x5
    Nov 6 00:20:28 BETA kernel[0]: um 35797] [LBlkNum 35797] [FSLogMsgID 761623095] [FSLogMsgOrder First]
    Nov 6 00:20:28 BETA kernel[0]:
    Nov 6 00:20:28: --- last message repeated 1 time ---
    Nov 6 00:20:28 BETA kernel[0]: jnl: disk3s2: restarting journal replay (3119616tem.fs] [DevNode devfs] [MountPt /dev] [Path /dev/disk3s2] [FSLogMsgID 1808569263] [FSLogMsgOrder Last]
    Nov 6 00:20:28 BETA kernel[0]: jnl: disk3s2: do] [ErrNo 5] [IOType Read] [PBlkNum 35797] [LBlkNum 35797] [FSLogMsgID 1188814659] [FSLogMsgOrder First]
    Nov 6 00:20:28 BETA kernel[0]: k3s2: replay_journal: from: 3119616 to: 3309056 (joffset 0xe81000)
    Nov 6 00:20:28 BETA kernel[0]: disk3s2: 0x5 (UNDEFINED).
    Nov 6 00:20:28 BETA kernel[0]: 2: dojnlio: strategy err 0x5
    Nov 6 00:20:28 BETA kernel[0]: jnl: disk3s2: replay_journal: Could not read block list header block @ 0x2f9a00!
    Nov 6 00:20:28 BETA kernel[0]: jnl: disk3s2: restarting journal replay (3119616 - 3309056)!
    Nov 6 00:20:28 BETA kernel[0]: jnl: disk3s2: replay_journal: from: 3119616 to: 3309056 (joffset 0xe81000)
    Nov 6 00:20:28 BETA kernel[0]: disk3s2: 0x5 (UNDEFINED).
    Nov 6 00:20:28 BETA kernel[0]:
    Nov 6 00:20:28: --- last message repeated 1 time ---
    Nov 6 00:20:28 BETA kernel[0]: jnl: disk3s2: dojnlio: strategy err 0x5
    Nov 6 00:20:28 BETA kernel[0]: jnl: disk3s2: replay_journal: Could not read block list header block @ 0x2f9a00!
    Nov 6 00:20:28 BETA kernel[0]: jnl: disk3s2: restarting journal replay (3119616 - 3309056)!

    I would have to agree. ooks like your HDD may be failing. That will cause sluggishness, and long bouts of it trying to access the failing portions.
    I would recommend a backup of your data, and running the apple diagnostics.
    Geoff

  • Does Scheduling agreement controls limits with its line&delivery items?

    We would like Scheduling agreement to control total target value with its line items and delivery items like contracts.
    Is it possible to do that?
    thanks for your co-operations..

    Hello Cemal Parlak,
    Pl correct me if my understanding is incorrect, you want to control the total target value and Total target quantity of the Schedule Agreement and Contracts,
    In above case, you can make message controls to achive this,
    SPRO-> Materials Management -> Purchasing -> Environment Data -> Define attributes of system
    Make the following messages as Error message instead of warning based on the business requirement.
    00 - 06 - 042 (Target value of contract & exceeded by &&)
    00 - 06 - 067 (Scheduled quantity & & greater than target quantity & &)
    00 - 06 - 078 (Target quantity exceeded by  & &)
    00 - 06 - 155 (Contract target value & reached)
    These settings are at client level so please check with other business entity for the requirement and alternatively you can also define the message for particualr user group .
    Hope this helps.
    Regards
    Arif Mansuri

  • Refund my $90 early contract cancellation fee... I do not remember agreeing to it!

    I was told that I agreed to a $90 early termination fee when I was re-negotiating my lost discounts on February 4th.  I'm old.  I do not remember that, nor would I have agreed to it...I would have switched to Cox.  This is a case where you say I agreed and I'm not going to dispute it... don't bore me with restating that.  I don't remember it and I'm the customer...remember?  After 1 1/2 hour of my life, that I won't get back, on the phone trying to credit that amount back to my account, and refusing at all levels, they hung up on me.  I think Verizon is the worst vendor my wife and I have to deal with.  Deception and bait and switch is your business model.  All we want is for them to match another provider in our area, give us a 10 year contract, and leave us alone.  I can't even look at the company logo without getting sick.  For now, we just want that $90 credited to our account and I'll deal with you again next year.  If you don't do it, we'll spend whatever life energy we have left going viral with your deception of these two old AARP members.  Hell, we may not live 10 more years.  Are you listening and hearing us???????????

    Couple of comments:
    1) This is mainly a user supported board.
    2) No provider will give a 10 year contract.
    3) Just about every provider is going to have an early cancellation fee in exchange for a contract. It happens for TV, cell phone even alternate electrical or natural gas contracts.
    4) You should have received info on Terms and Conditions when you signed up again. No one ever reads them yet they complain when they don't like them.
    5) I thought you typically get 30 days to cancel a contract from Verizon. Not sure how long it has been for you.
    If a forum member gives an answer you like, give them the Kudos they deserve. If a member gives you the answer to your question, mark the answer as Accepted Solution so others can see the solution to the problem.

  • Disable image preview in your stream Twitter 10.2.2.14

    I just updated to the lates version and now images show by default in your Twitter stream. Previously it was only a link which was much better.
    I couldn’t find any setting option to disable the preview like you can in the Android App. Has anyone seen the option?

    it's alot to cover in 5 days! especially if you are
    new to programmingI'd agree. If each course covers five days, this is probably geared towards experienced programmers who are already familiar with the concepts but in a different language. For example, a "senior" dot-NET programmer who got offered a job doing the same thing but in Java, would simply have to learn the new syntax and yes, he can do this in five days.
    But if you're new to programming, it easily takes at least a full day just to learn how the collections package works (stacks, linked lists, hash tables, trees and so forth), but the nice thing is that once you understand what they do, you can create whichever package you need in whatever programming language you want - which is probably what they have in mind.
    At a conventional university, the first course is easily a year's worth of material although it can be squeezed down to just one term if the instructor is really really good or the students have prior programming experience.
    The second course is definitely an additional term on top of that. At my college, it takes about 33 weeks (1.5 American semesters) to cover the second course in any depth.

  • Help! PL/SQL Programming standards

    Hello,
    I need help from experienced developers urgently.
    I am in process of applying for new job and I have received two documents from my potential employer (software company).
    One document represents design and programming standards and other documents represents test PL/SQL package that is written according to those rules.
    My task is to analyze programming standards and send my opinion about correctness of those standards, whether they are according to current best practices or not, whether they represent current industrial standards in programming in general and specifically in PL/SQL programming and so on. I have already sent them my answer and I wish to estimate my chances of getting that job.
    Abstract from standard:
    1.     All variables and objects should be named according to their type (integer, varchar, character...etc) (sufix Hungarian notation)
    2.     All variables in PL/SQL should be prefixed with “v_” and written in camel case
    3.     SQL and PL/SQL built in functions should all be written in lower case.
    4.     All procedures should be prefixed with “pr_”
    5.     All functions should be prefixed with “fn_”
    6.     All packages should be sufixed with “_pkg”
    7.     View names should be prefixed with “v_”
    8.     All tables in Oracle schema should be prefixed with that schema name
    9.     Variables declared in package specification should be prefixed with “pksv_“
    10.     Variables declared in package body should be prefixed with “pkbv_“
    11.     Embeded SQL query in FOR LOOP statements should never be used because programm code is „dirty“ and unreadable.
    example:
    instead of : FOR v_User_Rec in (select * from all_users) LOOP...
    use:          FOR v_User_Rec in cursor_name LOOP...
    12.     Every query that retrieves more than 1000 rows should be optimized.
    13.     Font for writing code in PL/SQL Developer editor should be Arial and tabs should be used.
    I would appreciate replies from experienced PL/SQL developers especially those that have also experience in other programming languages.
    I have sent my answer to employer that programming standard is according to best practices and according to industry standard.
    I am worried a little about that Hungarian notation, is it still being used?
    If not when it was stopped being used?
    What are my chances of getting job?
    Would you hire a programmer that works according to those standards?
    Thanks.

    Hi,
    Welcome to the forum!
    924589 wrote:
    Hello,
    I need help from experienced developers urgently.
    I am in process of applying for new job and I have received two documents from my potential employer (software company).
    One document represents design and programming standards and other documents represents test PL/SQL package that is written according to those rules.
    My task is to analyze programming standards and send my opinion about correctness of those standards, whether they are according to current best practices or not, whether they represent current industrial standards in programming in general and specifically in PL/SQL programming and so on. I have already sent them my answer and I wish to estimate my chances of getting that job.There is no agreement about what the "best practice" is. I'm sure you'll see that as soon as you have 2 replies. I'll tell you what I use and how strictly I do it, what I find useful, and what other experienced programmers seem to do, in my experience.
    Abstract from standard:
    1.     All variables and objects should be named according to their type (integer, varchar, character...etc) (sufix Hungarian notation)I use suffixes that show, not only the data type, but how the variable is being used. Fo example, abbr means an abbreviation (something that reminds you of the full spelling), cd means a code (something that does not necessarily resemble its meaning), name is a complete name (not abbreviated or coded).  These are all VARCHAR2 types.  (Actually, cd may be a NUMBER.) I do this for maybe 25% of the variables I use in production code, when I think confusion with other variables, or doubts about the meaning, would be likely. For column names in tables, I might do it more than 50% of the time. Many people don't bother at all.
    2.     All variables in PL/SQL should be prefixed with “v_” and written in camel caseI don't know of any experieced programmers who always use v_. Maybe 1 out of 4 programmers use CamelCase. I use lower case myself in PL/SQL. In languages where names are case-sensitive, this is much more important. I use CamelCase all the time when I program in PostScript.
    3.     SQL and PL/SQL built in functions should all be written in lower case.I do almost exactly the opposite: I put keywords and built-in funtions in UPPER case, and I find it very helpful. A lot of experienced programmers do the same, though some use lower case, and a few don't follow any pattern.
    4.     All procedures should be prefixed with “pr_”
    5.     All functions should be prefixed with “fn_”I don't know anybody who does 4 or 5, or anything like them.
    6.     All packages should be sufixed with “_pkg”
    7.     View names should be prefixed with “v_”Some people do 6 and 7, or something similar.
    8.     All tables in Oracle schema should be prefixed with that schema nameI never seen this. If you want to clarify who owns a table, you can explictly give the owner name, e.g. scott.emp.
    9.     Variables declared in package specification should be prefixed with “pksv_“
    10.     Variables declared in package body should be prefixed with “pkbv_“I've never seen 9 or 10 done, but I can see why somebody might find it helpful.
    11.     Embeded SQL query in FOR LOOP statements should never be used because programm code is „dirty“ and unreadable.
    example:
    instead of : FOR v_User_Rec in (select * from all_users) LOOP...
    use:          FOR v_User_Rec in cursor_name LOOP...It's often unnecessary, and it can be more efficient to combine them. Sometimes it simply isn't possible.
    If code gets difficult to read, it's often because it's not being modularized properly.
    12.     Every query that retrieves more than 1000 rows should be optimized.Every query (and other statement) should be optimized, regardless of how many rows it retrieves. How much time you spend optimizing any one query depends on several factors. How often the query is done, and the table sizes are more important than how many rows will be returned.
    13.     Font for writing code in PL/SQL Developer editor should be Arial and tabs should be used.I find a fixed-width font, such as Courier, is much more convenient.
    Whitespace, including tabs, should definitely be used.
    I would appreciate replies from experienced PL/SQL developers especially those that have also experience in other programming languages.
    I have sent my answer to employer that programming standard is according to best practices and according to industry standard.
    I am worried a little about that Hungarian notation, is it still being used?
    If not when it was stopped being used?
    What are my chances of getting job? Either I'm on the committee that's deciding, and therefore can't tell you, or I'm not, and therefore I don't know.
    Would you hire a programmer that works according to those standards?Sure. I'd also hire programmers who preferred other standards, or didn't care about some of the items above.

  • Converting Array to ArrayList not working

    Dear Members :
    Following line fails to convert my array to arraylist:
    List myArrayList = Arrays.asList(myArray);
    bcoz when I do
    System.out.println("ArrayList: "+myArrayList);
    it returns [[I@3e25a5]. The array is just a standard array: int[] myArray.
    I even tried with: List myArrayList = new ArrayList(Arrays.asList(myArray)); but same.
    Could you please suggest a solution to this ?
    Thanks in advance.
    Atanu

    YoungWinston wrote:
    Darryl Burke wrote:
    YoungWinston wrote:
    I agree, although experienced programmers would probably realize it already.Varargs existed in Java before I ever started learning it. Today for the first time, I'm beginning to understand why some programming veterans hate the feature.I think it has more to do with the <T> .... (T... array) {in the method signature. Generic types can only be references.Agreed. But it's the varargs that obscure the fact that an <tt>int[]</tt> may be treated as a single <tt>T</tt> parameter while an <tt>Object[]</tt> is treated as a <tt>T...</tt>. Which probably has something to do with the attitude of some veteran programmers to autoboxing as well.
    db

  • New to AS and stuck on IF statements

    I am trying to make a currency converter and Im using IFs to determine the from and to currency and then make the appropriate calculation. So far, I cant get anything to work. Here is the original code that I was using (but didnt work):
                   var a:String=String (OriginCurrenyCode.text)
                   var b:String=String (DestinationCurrencyCode.text)
                   var c:Number=Number (AmountToBeConverted.text)
                   if (a == "USD"){
                        if (b == "GBP"){
                             var ab:Number=Number (c*0.60)
                             ConvertedAmount.text = String(ab)
                        else if (b == "EUR"){
                             var ac:Number=Number (c*0.71)
                             ConvertedAmount.text = String(ac)
    Obviously there is much more, and the conversion rates arent completely accurate but thats the basis. I've tried every possible change I can think of but have no idea how to make this work.
    I am new to Actionscript and dont have any programming experience so any help is much appreciated.
    Thanks!!!
    Dave

    I agree that the switch statement would make the code easier - and perhaps faster as well. But, I personally never use switch statements in any code I write ever. When I first began programming, an experienced programmer told me that switch statements are frowned upon.
    Here's why (from wikipedia): "When implemented with fall-through as the default path, switch/case statements are a frequent source of bugs among even experienced programmers, given that, in practice, the "break" is almost always the desired path, but not the default behavior of the switch/case construct (at least in C and Java)."
    So, I've always stuck with if, then, else type statements even though they are harder to read and can be more painful to write and have serveral other disadvantages.

  • Horrible Customer Service!  And a 33 month old BB problem continues to exist!

    I have been a Verizon Wireless Customer for over 7 years.  I have been a Blackberry user for even longer.  In November of 2008, I switched my Blackberry World phone for the then new, Blackberry Storm.  I kept my same phone number, had no previous problems with the World phone or any calling issues, etc.  I just thought I might like the latest and greatest.  Almost immediately after getting the Storm, I started getting these strange 1 way audio problems.  When I say 1 way audio, I mean, I could here the other person on the end of the line, but they could no longer here me.  It was strange and it happened infrequently.  After about two weeks of having the storm, I decided that I really did hate not having the qwerty keyboard and so I took the storm back and got the BB Curve.  Again, noticed that I had the same 1 way audio problems and contacted VZW customer service.  After sending me out a new phone and several customer service calls, VZW opened a trouble tickets.  It was never resolved and conveniently closed, with Verizon saying they could not duplicate the problem.  I was not experiencing dropped calls.  I still had full bars, was still connected to the party on the other end of the line and it was happening in a bunch of different places.  I went thru this with the Storm, the Curve, the Tour and the Bold, all with this same sporadic one way audio, all with multiple different Blackberries being sent out to me, because Verizon was sure it was the Blackberry and not them!   Customer service suggested, on many occasions, that I switch my phone number.  WHY???  It didn't happen the first 3 years I had the phone number.  They also, had the audacity to suggest that I switch to a different platform.  HUH???  All of the sudden, I'm the only one in the neighborhood, who cannot have a blackberry phone, because it just no longer works for me????  Numerous tickets were open and no one would ever get back to me.  I couldn't get a VZW Tech to call me back if my life depended on it.  Call with one way audio were hounding me and VZW told me to mark my calls, where this happened.  Did all of that and they still couldn't find the problem.  The one way audio even happened when I was on one of the many calls to a Verizon Tech....yet they still could not "duplicate" my problem.  To this very day, they still have not found a solution.  After many months of dealing with Verizon (or not dealing with them, because they wouldn't call back) and researching new phones, I decided today, to try out an Android platform phone, just to stop the madness.  I called VZW and told them which phone I wanted (I needed something that would have a long battery life, had good reviews, etc) and they told me that I could NOT have the Motorola Android 3, but I would have to take a reconditioned Droid Pro instead.  I explained to them in no uncertain terms, that I was unwilling to pay for this change, as it's been an ongoing issue, that Verizon failed to ever fix or even acknowledge.  While I was getting stuck with a phone that I really don't want, I was completely tired of dealing with these issues, Verizon and my understandably irritated customers.  After the phone order was placed, the Verizon Customer Service guy, tells me that I have to return my Blackberry, within 10 business days or I would be charged for it.  WAIT!!!!  I don't even really want to change to an Android phone, I just want to try one out and see if this is going to give me the same issues as the BB.  Why do I have to return the Blackberry?  And why did Customer Service wait until we were almost finished with the conversation to unleash that little bit of information??  I would have never agreed to getting an Android, should I have known they were going to make me give up my BB too.  No, I don't want the Android phone just to have an Android.  I want Verizon to figure out what is wrong with my phone in the first place, but it's not going to happen!!!!  So, I was really left with no alternative, but to try another phone.  I have never gotten any compensation, in the almost 3 years this problem has been going on.  I have not asked for anything, except for Verizon to fix an issue that is clearly their problem.  We have another Verizon phone in our house and another line somewhere else and we have no problems with the other phones.  I have had at least 10 different blackberries in the last 33 months and all have had the same issue.  Quit blaming the phone VERIZON.  Don't ask your customers to give up their phone numbers and change platforms, all because of your incompetence.  I NEVER write reviews or go into any kind of forums, etc., but I've had it!!  Customer Service ignores the issues.  I didn't even know that any of the tickets were closed, until I called back with a ticket number, only to find out that the issue was unresolved and because of this, they had closed yet another ticket.  To me, the fact they are making me return my Blackberry, just to try out another phone, is beyond comprehension.  To top it all off, at the end of each of the conversations, the guy had the nerve to ask me if all of my needs were met, due to the issue.  Lol!  Yeah, they were all met!  Why ask that question to someone you know that is completely ticked off at you????    

    Pepsio07 wrote:
    I'm sorry, but when does swaping from a Blackberry Bold to an Droid Pro (certified pre-owned) qualify as an upgrade?
    Secondly, I've had my phone number for over 7 years.  It worked just fine for over 3 of those years.  Why should I have to give up my phone number?  It's not only a personal number, but a business number as well.  I have more than worked with Verizon to figure out this problem.  Done way more than my share and for anyone to say that I'm unwilling to work with them is beyond belief.  I have marked every single call that has gone bad.  I have turned off my phone for a period, to see if it was the network.  I have switched Blackberry's numerious times.  Why does everyone just jump to changing a phone number?  Say I did this.  What are they going to do with that phone number?  It goes right back out there for someone else to have.  That's what Verizon told me.  If that's the case and the next person who picks it up has no problem, then it wasn't the phone, or me, or the number.  
    Oh, and Verizon has spent a lot of money trying to fix my problem??  Well, I've spent a ton of money myself, paying for a phone that doesn't work, time and energy switching from Blackberry to Blackberry, and not even mentioning the amount of time I've spent trying to figure out this problem, to no avail!
    If something didn't work for 4 years I would be willing to try something else. Then again I don't run a business from a cell phone..

  • Optimizing a program (experts with a lot of time)

    The following code is most of the code for a sale program. This is something i have been working on for a while now and it's almost finished. It does work, and with no errors that I have found so far, but it seems too complicated and long. I am asking that some of you more experienced programmers take a look at it and give me some advice or tips. It's quite a bit of code, so you don't have to look at all of it, just whatever you see.
    This is the super class. It will soon be a full Log In for cashiers but right now it is just has two buttons for running the other two classes. It contains the open and save file methods that the others use to open the inventory file.
    /** Java core packages*/
    import java.util.*;
    import java.text.*;
    import java.awt.*;
    import java.awt.event.*;
    /** Java extension packages*/
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.event.*;
    import java.io.*;
    /** This program is used to calculate the sale price
    * of selected items and update the inventory with
    * each sale. It opens and saves into a file "inventory.dat".
    * @author Davin Green
    public class LogIn extends JFrame
        /** JTextField objects for the text fields that are used in these programs.*/
        public JTextField jTextField1, jTextField2, jTextField3,
                           jTextField4, jTextField5, jTextField6;
        /** JButton objects for the buttons that are used in these programs.*/
        public JButton jButton1, jButton2, jButton3, jButton4,
                        jButton5, jButton6, jButton7;
        /** JScrollPane object for the scrolling pane that is used in this program.*/
        public JScrollPane jScrollPane1, jScrollPane2;
        /** Label objects for the labels that are used in these programs.*/
        public Label label1, label2, label3, label4,
                      label5, label6, label7;
        /** Vector objects for the three vectors that are used in these programs.*/
        public Vector id, qty, price, saleItems, saleItemsQty;
        /** JList object for the list of Items from vector id used in this program.*/
        public JList jList1;
        private double salePrice;
        /** Document objects for the three text fields that are used in this program.*/
        public Document jText1, jText2, jText3;
        /** DeciamlFormat object used to format display of money.*/
        private DecimalFormat toMoney;
        /** ObjectInputStream object for later inputing a stream.*/
        private ObjectInputStream objectInput;
        /** ObjectOutputStream object for later outputing a stream.*/
        private ObjectOutputStream objectOutput;
        private static LogIn window;
        public static void main( String args[] )
          window = new LogIn();
          window.setSize(450, 400);
          window.show();
        public LogIn()
            /** Get JFrames content pane and set layout to null.*/
            Container container = getContentPane();
            container.setLayout( new FlowLayout() );
            jButton1 = new JButton();
            jButton1.setText("Inventory Editor");
            container.add(jButton1);
            jButton2 = new JButton();
            jButton2.setText("Make Sale");
            container.add(jButton2);
          jButton1.addActionListener(
           new ActionListener()
             public void actionPerformed( ActionEvent event )
               Inventory inventory = new Inventory();
               inventory.runInventory();
               window.hide();
               window = null;
          jButton2.addActionListener(
           new ActionListener()
             public void actionPerformed( ActionEvent event )
               Computer computer = new Computer();
               computer.runComputer();
               window.hide();
               window = null;
        public LogIn( String title )
          super( title );
        /** The openFile() method opens inventory.dat and saves it's information into three vectors.*/
        public void openFile() throws IOException, ClassNotFoundException
          Item item;
          toMoney = new DecimalFormat( "0.00" );
          id = new Vector();
          qty = new Vector();
          price = new Vector();
         try {
              int i = 0;
              /** Opens file inventory.dat and saves data into buffer.*/
              try {
                objectInput = new ObjectInputStream( new FileInputStream( "C:/inventory.dat" ) );
              catch ( FileNotFoundException fnfException )
                objectOutput = new ObjectOutputStream( new FileOutputStream( "C:/inventory.dat" ) );
                objectOutput.close();
                objectInput = new ObjectInputStream( new FileInputStream( "C:/inventory.dat" ) );
                JOptionPane.showMessageDialog( null, "Inventory file has been created.", "File Created", JOptionPane.INFORMATION_MESSAGE );
              while ( true )
                /** Reads one item object from inventory.dat.*/
                item = ( Item ) objectInput.readObject();
                String idString = item.getID();
                String qtyString = "" + item.getQty();
                String priceString = "" + toMoney.format (item.getPrice());
                id.add( i, idString );
                qty.add( i, qtyString );
                price.add( i, priceString );
                i++;
          /** Closes file when end of file is reached.*/
          catch ( EOFException eofException )
             objectInput.close();
        /** The Method exitForm() sets what to do when window is closed.*/
        public void saveFile() throws IOException
         /** Makes file inventory.dat.*/
         objectOutput = new ObjectOutputStream( new FileOutputStream( "C:/inventory.dat" ));
         /** Saves three vectors as objects of the Item class into inventory.dat.*/
         for ( int i = 0; i < id.size(); i++ )
         String idString = (String)id.get(i);
         int qtyInt = Integer.parseInt( (String)qty.get(i) );
         double priceDouble = Double.parseDouble( (String)price.get(i) );
         Item item = new Item( idString, qtyInt, priceDouble );
         objectOutput.writeObject( item );
         /** Closes inventory.dat.*/
         objectOutput.close();
    }This is the computer class. It is used to calculate sale prices and print the reciept for each sale. It does everything it's supposed to except update the inventory, which I just haven't written the code for yet.
    /** Java core packages*/
    import java.util.*;
    import java.text.*;
    import java.awt.*;
    import java.awt.event.*;
    /** Java extension packages*/
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.event.*;
    import java.io.*;
    /** This program is used to calculate the sale price
    * of selected items and update the inventory with
    * each sale. It opens and saves into a file "inventory.dat".
    * @author Davin Green
    public class Computer extends LogIn
        private double salePrice;
        private JTextArea jTextArea1;
        private Choice choice1;
        private JSeparator jSeparator1;
        private static Computer window;
        /** Default constructor.*/
        public Computer()
          super("Sale Program");
          try{
            try {
              openFile();
              createGUI();
              registerCompEventHandlers();
              salePrice = 0.0;
            catch ( ClassNotFoundException e )
          catch ( IOException e )
        /** The createGUI() methods creates and displays GUI components in the JFrame.*/
        private void createGUI()
            jList1 = new JList();
            saleItems = new Vector();
            saleItemsQty = new Vector();
            /** Get JFrames content pane and set layout to null.*/
            Container container = getContentPane();
            container.setLayout(null);
            choice1 = new Choice();
            makeChoiceMenu();
            container.add(choice1);
            choice1.setBounds(40, 50, 130, 20);
            jButton1 = new JButton();
            jButton1.setText("Add Item");
            container.add(jButton1);
            jButton1.setBounds(270, 50, 130, 20);
            jButton2 = new JButton();
            jButton2.setText("Remove Item");
            container.add(jButton2);
            jButton2.setBounds(270, 80, 130, 20);
            jButton2.setEnabled( false );
            jButton3 = new JButton();
            jButton3.setText("Print Reciept");
            container.add(jButton3);
            jButton3.setBounds(270, 110, 130, 20);
            jButton3.setEnabled( false );
            jButton4 = new JButton();
            jButton4.setText("New Sale");
            container.add(jButton4);
            jButton4.setBounds(270, 140, 130, 20);
            jButton4.setEnabled( false );
            jButton5 = new JButton();
            jButton5.setText("Change Cashier");
            container.add(jButton5);
            jButton5.setBounds(410, 240, 130, 20);
            jButton6 = new JButton();
            jButton6.setText("Edit Inventory");
            container.add(jButton6);
            jButton6.setBounds(410, 270, 130, 20);
            jButton7 = new JButton();
            jButton7.setText("Edit Qty");
            container.add(jButton7);
            jButton7.setBounds(100, 80, 100, 20);
            jButton7.setEnabled( false );
            jScrollPane1 = new JScrollPane();
            jTextArea1 = new JTextArea();
            container.add(jScrollPane1);
            jScrollPane1.setBounds(10, 190, 390, 100);
            jScrollPane2 = new JScrollPane();
            jScrollPane2.getViewport().add( jList1 );
            container.add(jScrollPane2);
            jScrollPane2.setBounds(410, 40, 130, 190);
            jSeparator1 = new JSeparator();
            container.add(jSeparator1);
            jSeparator1.setBounds(10, 40, 390, 10);
            jTextField1 = new JTextField();
            jTextField1.setEditable(false);
            jTextField1.setText("Cashier Name");
            container.add(jTextField1);
            jTextField1.setBounds(60, 10, 170, 20);
            jTextField2 = new JTextField();
            jTextField2.setEditable(false);
            jTextField2.setBounds(240, 10, 80, 20);
            jTextField3 = new JTextField();
            jTextField3.setEditable(false);
            DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
            jTextField3.setText(dateFormat.format(new Date()));
            container.add(jTextField3);
            jTextField3.setBounds(330, 10, 70, 20);
            jTextField4 = new JTextField();
            jTextField4.setText("");
            container.add(jTextField4);
            jTextField4.setBounds(60, 80, 30, 20);
            jText1 = jTextField4.getDocument();
            jTextField5 = new JTextField();
            jTextField5.setText("$0.00");
            container.add(jTextField5);
            jTextField5.setBounds(100, 140, 100, 20);
            jTextField6 = new JTextField();
            jTextField6.setEditable(false);
            jTextField6.setText("$0.00");
            container.add(jTextField6);
            jTextField6.setBounds(100, 110, 100, 20);
            label1 = new Label();
            label1.setText("Cashier");
            container.add(label1);
            label1.setBounds(10, 10, 48, 20);
            label2 = new Label();
            label2.setText("Item");
            container.add(label2);
            label2.setBounds(10, 50, 28, 20);
            label3 = new Label();
            label3.setText("Selected Item");
            container.add(label3);
            label3.setBounds(410, 20, 90, 20);
            label4 = new Label();
            label4.setText("Reciept");
            container.add(label4);
            label4.setBounds(10, 170, 50, 20);
            label5 = new Label();
            label5.setText("Quantity");
            container.add(label5);
            label5.setBounds(10, 80, 50, 20);
            label6 = new Label();
            label6.setText("Amount Paid");
            container.add(label6);
            label6.setBounds(10, 140, 80, 20);
            label7 = new Label();
            label7.setText("Sale Price");
            container.add(label7);
            label7.setBounds(10, 110, 60, 20);
            pack();
        /** The method registerEventHandlers() sets what each GUI object does.*/
        private void registerCompEventHandlers()
          ActionListener al = new ActionListener(){
                DateFormat fmt = DateFormat.getTimeInstance(DateFormat.SHORT);
                public void actionPerformed(ActionEvent evt) {
                    jTextField2.setText(fmt.format(new Date()));
            new javax.swing.Timer(1000, al).start();
            getContentPane().add(jTextField2);
            SwingUtilities.invokeLater(new Runnable(){
                public void run() {
          /** Sets program to call method exitForm() when window is closed.*/
          addWindowListener( new WindowAdapter()
                               public void windowClosing(WindowEvent evt)
                                 try {
                                   saveFile();
                                   System.exit(0);
                                 catch ( IOException ioException )
          /** Tells what to do when an item is selected on the drop down menu.*/
          final ItemListener choiceListener;
          choice1.addItemListener(
           choiceListener = new ItemListener()
             public void itemStateChanged( ItemEvent event )
               boolean itemNotExist = true;
               for ( int i = 0; i < saleItems.size(); i++ )
                 if ( choice1.getSelectedItem() == (String)saleItems.get( i ) )
                   itemNotExist = false;
                   jList1.setSelectedIndex( i );
                   jTextField4.setText( (String)saleItemsQty.get( i ) );
               if ( itemNotExist == true )
                 jTextField4.setText( "" );
               jButton1.setEnabled( itemNotExist );
               jButton7.setEnabled( false );
          /** When an item is selected, the items information is
           * displayed in the corresponding text field.*/
          jList1.addListSelectionListener(
           new ListSelectionListener()
             public void valueChanged( ListSelectionEvent event )
              if ( event.getSource() == jList1 && !event.getValueIsAdjusting() )
               int selection = 0;
               String selectionQty;
               try {
                 for ( int i = 0; i < choice1.getItemCount(); i++ )
                   if ( choice1.getItem(i) == jList1.getSelectedValue() )
                     selection = i;
                 selectionQty = (String)saleItemsQty.get( jList1.getSelectedIndex() );
                 choice1.select( selection );
               catch ( ArrayIndexOutOfBoundsException aoobException )
                selectionQty = "";
               jTextField4.setText( selectionQty );
               jButton1.setEnabled( false );
               jButton2.setEnabled( true );
               jButton3.setEnabled( true );
               jButton4.setEnabled( true );
               jButton7.setEnabled( false );
          /** Listens to jTextField and detects changes. */
          jText1.addDocumentListener(
            new DocumentListener()
              public void changedUpdate(DocumentEvent e)
                if ( saleItems.size() > 0 )
                  for ( int i = 0; i < saleItems.size(); i++ )
                    if ( choice1.getSelectedItem() == (String)saleItems.get( i ) )
                      jButton1.setEnabled( false );
                      if ( jTextField4.getText() != saleItemsQty.get( i ) )
                        jButton7.setEnabled( true );
                      else
                        jButton7.setEnabled( false );
                else
                  jButton1.setEnabled( true );
                  jButton7.setEnabled( false );
              public void insertUpdate(DocumentEvent e)
                if ( saleItems.size() > 0 )
                  for ( int i = 0; i < saleItems.size(); i++ )
                    if ( choice1.getSelectedItem() == (String)saleItems.get( i ) )
                      jButton1.setEnabled( false );
                      if ( jTextField4.getText() != saleItemsQty.get( i ) )
                        jButton7.setEnabled( true );
                      else
                        jButton7.setEnabled( false );
                else
                  jButton1.setEnabled( true );
                  jButton7.setEnabled( false );
              public void removeUpdate(DocumentEvent e)
                if ( saleItems.size() > 0 )
                  for ( int i = 0; i < saleItems.size(); i++ )
                    if ( choice1.getSelectedItem() == (String)saleItems.get( i ) )
                      jButton1.setEnabled( false );
                      if ( jTextField4.getText() != saleItemsQty.get( i ) )
                        jButton7.setEnabled( true );
                      else
                        jButton7.setEnabled( false );
                else
                  jButton1.setEnabled( true );
                  jButton7.setEnabled( false );
          /** When "Add Item" button is clicked, a new element
           *  is added to each vector.*/
          jButton1.addActionListener(
           new ActionListener()
             public void actionPerformed( ActionEvent event )
               String quantity = jTextField4.getText();
               jTextField4.setText( "" );
                try{
                 for ( int i = 0; i < id.size(); i++ )
                  if ( (String)id.get(i) == choice1.getSelectedItem() )
                    salePrice += ( Double.parseDouble( (String)price.get(i) ) * Double.parseDouble( quantity ) );
                 String newPrice = "$" + salePrice;
                 saleItems.add( choice1.getSelectedItem() );
                 saleItemsQty.add( quantity );
                 jList1.setListData( saleItems );
                 jScrollPane2.revalidate();
                 jScrollPane2.repaint();
                 jTextField6.setText( newPrice );
                 jButton1.setEnabled( false );
                catch ( NumberFormatException num )
                  JOptionPane.showMessageDialog( null, "Please enter a valid quantity!", "Error", JOptionPane.ERROR_MESSAGE );
                jList1.setSelectedIndex( saleItems.size() - 1 );
          /** When "Remove" button is clicked, the selected item is removed
           * from all vectors.*/
          jButton2.addActionListener(
           new ActionListener()
             public void actionPerformed( ActionEvent event )
               try {
               int selection = jList1.getSelectedIndex();
                 for ( int i = 0; i < id.size(); i++ )
                  if ( (String)id.get(i) == choice1.getSelectedItem() )
                   salePrice -= ( Double.parseDouble( (String)price.get(i) ) * Double.parseDouble( (String)saleItemsQty.get( selection )  ) );
                 String newPrice = "$" + salePrice;
                 saleItems.removeElementAt( selection );
                 saleItemsQty.removeElementAt( selection );
                 jList1.setListData( saleItems );
                 jScrollPane2.revalidate();
                 jScrollPane2.repaint();
                 jTextField6.setText( newPrice );
                 if( selection >= id.size() )
                  selection = id.size() - 1;
                 jList1.setSelectedIndex( selection );
               catch ( ArrayIndexOutOfBoundsException exception )
                 JOptionPane.showMessageDialog( null, "Please select an item to remove!", "Error", JOptionPane.ERROR_MESSAGE );
               if ( saleItems.size() == 0 )
                 jButton2.setEnabled( false );
               else
                 jButton2.setEnabled( true );
          /** When "Set Qty" button is clicked, the quantity of
           * the selected item is changed to the integer in
           * the qty text field.*/
          jButton7.addActionListener(
           new ActionListener()
             public void actionPerformed( ActionEvent event )
               int selection = jList1.getSelectedIndex();
               String newQty = jTextField4.getText();
               try {
                 int numbertest = Integer.parseInt( newQty );
                 for ( int i = 0; i < id.size(); i++ )
                  if ( (String)id.get(i) == choice1.getSelectedItem() )
                   salePrice -= ( Double.parseDouble( (String)price.get(i) ) * Double.parseDouble( (String)saleItemsQty.get( selection )  ) );
                   salePrice += ( Double.parseDouble( (String)price.get(i) ) * Double.parseDouble( newQty ) );
                 String newPrice = "$" + salePrice;
                 saleItems.set( selection, choice1.getSelectedItem() );
                 saleItemsQty.set( selection, newQty );
                 jScrollPane2.revalidate();
                 jScrollPane2.repaint();
                 jTextField6.setText( newPrice );
                 jButton7.setEnabled( false );
               catch ( NumberFormatException badinput )
                 JOptionPane.showMessageDialog( null, "Please enter an integer!", "Error", JOptionPane.ERROR_MESSAGE );
          /** When "Print Reciept" button is clicked, the price of
           * the selected item is changed to the double in
           * the price text field.*/
          jButton3.addActionListener(
           new ActionListener()
             public void actionPerformed( ActionEvent event )
               try{
               String reciept = "\tStore Name";
               String items = "";
               String temp = jTextField5.getText();
               String amountPaidString = "";
               double amountPaid = 0.0;
               double change;
               for ( int i = 1; i < temp.length(); i++ )
                 char a = temp.charAt(0);
                 char b = temp.charAt(i);
                 if ( a == '$' )
                   amountPaidString += b;
                 else
                   amountPaidString = "Error";
               amountPaid = Double.parseDouble( amountPaidString );
               if (amountPaid >= salePrice)
               change = amountPaid - salePrice;
               reciept += "\nDate: " + jTextField3.getText()
                 + "\t\tTime: " + jTextField2.getText()
                 + "\nCashier: " + jTextField1.getText()
                 + "\n\n\tItems:";
               for ( int i = 0; i < saleItems.size(); i++ )
                 items += "\n" + saleItems.get( i ) + "\t\t$";
                 for ( int h = 0; h < id.size(); h++ )
                  if ( (String)id.get(h) == (String)saleItems.get( i ) )
                    items += ( Double.parseDouble( (String)price.get(h) ) * Double.parseDouble( (String)saleItemsQty.get(h) ) );
               reciept += items + "\n\nTOTAL:\t$" + salePrice
                 + "\nAmount Paid:\t$" + amountPaid
                 + "\nChange:\t$" + change; 
                 jTextArea1.setText( reciept );
                 jScrollPane1.getViewport().add( jTextArea1 );
                 jScrollPane1.revalidate();
                 jScrollPane1.repaint();
                 jButton1.setEnabled( false );
                 jButton2.setEnabled( false );
                 jButton3.setEnabled( false );
                 jButton7.setEnabled( false );
                 jTextField4.setEditable( false );
                 jTextField5.setEditable( false );
                 choice1.removeItemListener( choiceListener );
               else
                 JOptionPane.showMessageDialog( null, "Amount Paid is not enough!", "Error", JOptionPane.ERROR_MESSAGE );
               catch ( NumberFormatException badinput )
                 JOptionPane.showMessageDialog( null, "Please enter a valid amount paid!", "Error", JOptionPane.ERROR_MESSAGE );
          jButton4.addActionListener(
           new ActionListener()
             public void actionPerformed( ActionEvent event )
               int select = 3;
               select = JOptionPane.showConfirmDialog( null, "Are you sure you want quit this sale?" );
               if (select == 0)
                 String[] run = {"xxx","yyy"};
                 window.hide();
                 main( run );
          jButton5.addActionListener(
           new ActionListener()
             public void actionPerformed( ActionEvent event )
               /* Code for what to do when "Change Cashier" button is clicked*/ /*
          jButton6.addActionListener(
           new ActionListener()
             public void actionPerformed( ActionEvent event )
               Inventory inventory = new Inventory();
               try{
               saveFile();
               catch ( IOException e )
               window.hide();
               inventory.runInventory();
               window = null;
        private void makeChoiceMenu()
          for ( int i = 0; i < id.size(); i++ )
            choice1.add( (String)id.get( i ) );
        /** The main method.*/
        public static void runComputer()
            window = new Computer();
            window.setSize(555, 335);
            window.show();
    }This is the inventory class. It's used to make and edit the items in the inventory and then save them into the inventory file.
    /** Java core packages*/
    import java.util.*;
    import java.text.*;
    import java.awt.*;
    import java.awt.event.*;
    /** Java extension packages*/
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.event.*;
    import java.io.*;
    /** This program displays the inventory of a store and
    * allows user to edit each items name, quantity, and
    * price. It opens and saves into a file "inventory.dat".
    * @author Davin Green
    public class Inventory extends LogIn
        private static Inventory window;
        /** Default constructor.*/
        public Inventory()
          super("Inventory Editor");
          try{
            try{
            openFile();
            createInvGUI();
            registerInvEventHandlers();
            catch ( IOException e )
          catch ( ClassNotFoundException e )
        /** The createGUI() methods creates and displays GUI components in the JFrame.*/
        private void createInvGUI() throws IOException
            /** Get JFrames content pane and set layout to null.*/
            Container container = getContentPane();
            container.setLayout(null);
            /** List of items displayed in scrolling pane.*/
            jList1 = new JList( id );
            /** Put JList into the scrolling pane, add scrolling pane
             * to content pane, and set position and size.*/
            jScrollPane1 = new JScrollPane();
            jScrollPane1.getViewport().add( jList1 );
            container.add(jScrollPane1);
            jScrollPane1.setBounds(0, 0, 210, 370);
            /** Button for adding a new item.*/
            jButton1 = new JButton();
            jButton1.setText("Add Item");
            container.add(jButton1);
            jButton1.setBounds(240, 10, 90, 30);
            /** Button for deleting a selected item.*/
            jButton2 = new JButton();
            jButton2.setText("Delete");
            container.add(jButton2);
            jButton2.setBounds(290, 50, 90, 30);
            /** Button for setting the quantity of an item.*/
            jButton3 = new JButton();
            jButton3.setText("Set Qty");
            container.add(jButton3);
            jButton3.setBounds(240, 100, 90, 30);
            /** Button for setting the price of an item.*/
            jButton4 = new JButton();
            jButton4.setText("Set Price");
            container.add(jButton4);
            jButton4.setBounds(240, 150, 90, 30);
            /** Text field for inputing and displaying the id (name) of an item.*/
            jTextField1 = new JTextField();
            container.add(jTextField1);
            jTextField1.setBounds(340, 10, 93, 30);
            jText1 = jTextField1.getDocument();
            /** Text field for inputing and displaying the quantity of an item.*/
            jTextField2 = new JTextField();
            container.add(jTextField2);
            jTextField2.setBounds(370, 100, 43, 30);
            jText2 = jTextField2.getDocument();
            /** Text field for inputing and displaying the price of an item.*/
            jTextField3 = new JTextField();
            container.add(jTextField3);
            jTextField3.setBounds(370, 150, 43, 30);
            jText3 = jTextField3.getDocument();
            /** Displays "Qty" before the quantity text field.*/
            label1 = new Label();
            label1.setText("Qty");
            container.add(label1);
            label1.setBounds(350, 100, 20, 20);
            /** Displays "Price" before the price text field.*/
            label2 = new Label();
            label2.setText("Price");
            container.add(label2);
            label2.setBounds(340, 150, 30, 20);
            /** Button to change cashier (return to cashier log-in panel).*/
            jButton5 = new JButton();
            jButton5.setText("Change Cashier");
            container.add(jButton5);
            jButton5.setBounds(260, 270, 130, 30);
            /** Button to make sell (open make sell panel).*/
            jButton6 = new JButton();
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    

    /** JTextField objects for the text fields that are used in these programs.*/
    public JTextField jTextField1, jTextField2, jTextField3,
                    jTextField4, jTextField5, jTextField6;Your variable names don't mean anything.
    So the person who has to maintain this program when you leave has a difficult task.
    If there was some indication that the operator would key in (say) a quantity, that would
    make it easier. You might name it "quantityText" in that case, or something like that.

  • Point me in the right direction: want to resize image & store in mysql db

    I finally accomplished one of my tasks! Which was trying to upload a jpeg image into my mysql database, and then display it in a jsp page via a servlet. I extend my thanks to the java forums greatly:)
    Now my next task I find is going to be trickier to accomplish, because I do not have enough experience working with images.
    I would like to make my first task above more efficient.
    When the user selects a jpeg file to send, I want to check the size of the image and resize it as well, before finally storing it in my Mysql database.
    I do not want to lose the resolution, nor do I want it to look distorted after it is resized. I want to keep the same proportions as the original image (I hope that proportion is the proper term). After the image is stored successfully, it will be read out of the database and displayed within a jsp page via a servlet.
    After poking around in the forums, I realized I need to get down the basics with regards to getting the properties of an image and trying to resize it. It doesn't look like it will be an easy task.
    Does anyone know of any sites that provide a good, easy to understand tutorial? Or are there any books you would recommend I read? What Java classes should I be looking into to accomplish my task?
    There are so many far more experienced programmers out there among the forums, that when I look at their code, I'm lost. I just want to understand this process better, by taking it one step at a time.
    Any help is appreciated, as always:)
    Thank You,
    Love2Java

    Load image with ImageIO
    Call getWidth() and getHeight()
    Create a BufferedImage with width and height scaled accordingly
    Get the image's Graphics2D object
    Call drawImage(), passing an AffineTransform to scale accordingly
    Output the image via ImageIO
    That should be it - you just need to read the APIs for the classes I've mentioned, and tack on whatever input/output streams you need at either end (see the java.io package).
    The only thing is:
    I do not want to lose the resolution
    Not totally sure what you mean: if you're scaling the image down to a thumbnail then by definition you're losing resolution. If you mean you want to keep the DPI resolution metadata in the image then you'll have to Google for it, the information is there but it hasn't remained in my head :o)
    But then I can't imagine why you'd need DPI metadata in a thumbnail anyway, so you can probably ignore it.

  • Footnotes at the bottom of the page

    For anyone interested – putting the above title in the search window didn't produce anything I mean. And I welcome better ideas. I work with a Dutch language version, so I hope I use the right terms.
    Working on juridical textbooks with hundreds of sometimes long footnotes, I sometimes come to the next problem. It is possible to automatically let long footnotes break over two pages (see other threads to get explained how). But suppose there is another footnote marker a little after the 'long' one. This seems a bit too much for Indesign. Both markers and both footnotes go to the next page, leaving a big white gap, in mid-paragraph, at the bottom of the preceeding page.
    My solution:
    - cut the second footnote marker;
    - add the right footnote number as normal text (probably in superscript) at that spot;
    - paste the footnote marker at the end of the top paragraph on the next page;
    - make a text style with text color set to paper (white);
    - apply this text style to the pasted footnote marker.
    Now it looks like the footnote marker is on the first page, and the entire footnote is on the second page (the real footnote marker is invisible). If in a later stage footnotes are added or text overruns, you can easily look for the 'white' text style to adapt things.
    You can also use this trick when there is either space for the marker or for the footnote text at the bottom of a page but not for both, leaving at least one white line (although to the most of us, that will sound less urgent).
    But of course it would be nice if Adobe solves this in a future version (I already suggested them to do so.)

    An 8 line footnote will not normally take 8 lines of text: usually, the
    type size is smaller and so is the leading in footnotes.
    Personally, I don't mind a gap of up to 4 text lines or so if necessary
    to keep the footnote indicator and the start of the footnote on the same
    page (obviously, once the footnote starts on the page, it can flow on to
    the next page; and this InDesign can cope with!). Although I would never
    have such a gap in the middle of paragraph normally, in this case,
    because there is also a footnote at the bottom of the page, it does not
    stand out so much to my eye.
    I didn't know that Word allows what you say. I'm surprised that it does.
    This is what the Chicago Manual of Style (15th ed.) has to say about
    your problem: "In a work containing many long footnotes, it may be
    difficult to fit them onto the pages they pertain to, especially in an
    illustrated work. A basic requirement for all footnotes is that they at
    least begin on the page on which they are referenced. Several long
    footnotes with their references falling close together toward the end of
    a page present a major problem in page makeup. There is also the matter
    of appearance; a page consisting almost exclusively of footnotes is
    daunting. For some remedies, see 16.36–40."
    And the first remedy (16.36): "Avoiding overlong footnotes: Lengthy,
    discursive notes should be reduced or integrated into the text..."
    Obviously, nobody can force you to take this advice. But you're asking
    the InDesign team to spend days and or months of programming to
    accommodate your editor or publisher's bad practice in allowing such
    long footnotes in the first place, despite what I think is a consensus
    that apart from the "daunting look," this will also cause "a major
    problem in page makeup." And your solution is to have the footnote begin
    on a different page from its text indicator, whereas Chicago says "A
    basic requirement for all footnotes is that they at least begin on the
    page on which they are referenced." Many readers would, I think, agree
    with that assertion!
    Anyway, the more flexibility the better, as far as I'm concerned. But I
    seems to me that it's wrong to expect the InDesign team to offer a
    solution to a problem that is caused by bad editorial practice. Fix the
    editors, not the programmers!
    Ariel

Maybe you are looking for