For New Guys, Simpleton pattern revisited...

In the March 2004 issue of Java Patterns there is an article called "OO Patterns for Extensive Coding With OverTyping and Generic Exclamations". The article introduces the simpleton pattern, citing a similar pardigm in the C programming world. Using the simpleton pattern the following code,
* Test.java
* Created on May 14, 2004, 2:54 PM
package tmp;
* @author  awaddi
public class Test
     private int _pNumberOfFileWritesInt;
     private int _pNumberOfFileReadsInt;
     /** Creates a new instance of Test */
     public Test()
          _pNumberOfFileWritesInt = 0;
     public void write( Object data )
          // write the data
          set_pNumberOfFileWritesInt(  get_pNumberOfFileWritesInt() + 1  );
     public void read( Object data )
          // read the data
          set_pNumberOfFileReadsInt(  get_pNumberOfFileReadsInt() + 1  );
      * Getter for property _pNumberOfFileWritesInt.
      * @return Value of property _pNumberOfFileWritesInt.
     public int get_pNumberOfFileWritesInt()
          return _pNumberOfFileWritesInt;
      * Setter for property _pNumberOfFileWritesInt.
      * @param _pNumberOfFileWritesInt New value of property _pNumberOfFileWritesInt.
     public void set_pNumberOfFileWritesInt(int _pNumberOfFileWritesInt)
          this._pNumberOfFileWritesInt = _pNumberOfFileWritesInt;
      * Getter for property _pNumberOfFileReadsInt.
      * @return Value of property _pNumberOfFileReadsInt.
     public int get_pNumberOfFileReadsInt()
          return _pNumberOfFileReadsInt;
      * Setter for property _pNumberOfFileReadsInt.
      * @param _pNumberOfFileReadsInt New value of property _pNumberOfFileReadsInt.
     public void set_pNumberOfFileReadsInt(int _pNumberOfFileReadsInt)
          this._pNumberOfFileReadsInt = _pNumberOfFileReadsInt;
     public static void main(  String[] args  )
          Test aTest = new Test();
          // write twenty lines to a file
          while(  aTest.get_pNumberOfFileWritesInt() < 20  )
               aTest.write(  "a line"  );
               System.out.println("Reads: " + aTest.get_pNumberOfFileReadsInt()  );
               System.out.println("Writes: " + aTest.get_pNumberOfFileWritesInt()  );
          System.out.println("Done!");
          System.exit( 0 );
}could be replaced using the Simpleton Pattern. Though the article was complex, I believe it raised some salient points, particularly in regard to many current idioms that new programmers are faced with. While the above code example demonstrates several principles that are important for new programmers to adhere to, a la "Ultimate Java Coding Style and Superb Idioms for Defensive Programming", the Simpleton Pattern utilises a different approach:
class ReadWriteCounter
     public int reads = 0;
     public int writes = 0;
     public void write( Object data )
          // write the data
          writes++;
     public void read( Object data )
          // read the data
          reads++;
     public static void main(  String[] args  )
          ReadWriteCounter counter = new ReadWriteCounter();
          // write twenty lines to a file
          while(  counter.writes < 20  )
               counter.write(  "a line"  );
               System.out.println("Reads: " + counter.reads  );
               System.out.println("Writes: " + counter.writes  );
          System.out.println("Done!");
          System.exit( 0 );
}While the Simpleton pattern is useful, it has some disadvantages:
When you sell your programmes, other programmers will be able to modify the internal state of your classes.
Synchronisation of variable access can only be achieved by using volatile members, this is inherently error-prone as volatile variables are often guaranteed to provide semi-deterministic member access and may change the values of variables in common circumstances (never use the volatile keyword, it is dangerous).
The use of C-like structs is likely to cause many programming errors, contrary to popular belief, int[] z; (z[0]+4) = 22; will not assign the value of 22 to the second item in the z array. Java uses object references, NOT ADDRESS POINTERS.
So when is the Simpleton pattern a bad thing? In years of Java programming I have found that in 99% of the cases the Simpleton pattern is all that is needed, however, when referring to references of Objects that are shared between classes, the normal getter/setter is really useful. Consider:
class ResultCode
     String value;
     public ResultCode( String s )
          value = s;
class FileOperationA
     ResultCode code;
     public FileOperationA(  ResultCode c  )
          code = c;
     public void someOp()
          System.out.println("code:" + code.value );
class FileOperationB
     ResultCode code;
     public FileOperationB(  ResultCode c  )
          code = c;
     public void someOp()
          System.out.println("code:" + code.value );
class DirectoryOne
     FileOperationA a;
     FileOperationB b;
     public DirectoryOne()
          ResultCode c = new ResultCode( "OK" );
          a = new FileOperationA( c );
          b = new FileOperationB( c );
          // a and b share a reference to an underlaying object, not a primitive
     public void changeCodeString()
          a.code = new ResultCode(  "It's all good" ); // replaces OK as the message, but just for a
          // now a and b have different code values, wrong
     public void changeCodeString2()
          a.setCode( "It's all good" ); // replaces OK as the message, for a and b Yay!!
          // now a and b have (still) the same code values, right
}The getter/setter is necessary because we aren't using primitives in ResultCode, we have a shared reference through a and b that references a reference, and because we want operations through either a or b on a shared ResultCode object to be visible to both "copies" of the object (they aren't copies, its the same object, two referents).
Its a little complicated, but suffice it say that the jist of the article is to keep it simple unless you are really certain that you need the complexity.
Andrew

An object with just behaviour doesn't do much, in the
case of an object with static methods that modifies
data passed in via arguments (which, incidentally,
seems to be the model you are suggesting), the object
itself is simply a utility grouping and doesn't have
any state to behave with.
As I said an OO Object must have data and behavior.
If it doesn't have data it is not an Object. That is not to say that you can not create code that does that, but rather that it is not an OO Object.
Most objects have at least two kinds of values,
internal values that don't compose the behaviour of
the object, things like loop counters, computation
constants, or intermediate values; not really data is
it? There are also values that do compose state, alter
behaviour, or provide information; things like number
of logins, name of a data file, etc...Local variables are not Object data. Via the implementation code a java class (for example) might have member variables that are used to achieve some implementation goal yet are not actually part of the Object.
>
Then there is the actually interesting stuff, the
raison d'etre of the object, values that represent the
output of the object and, actually deserve to be
called data: total monthly bill, number of available
routes, installed packages, or whatever.
Let's say we have three kinds of values; temporary,
intermediate, and product or, perhaps, transient,
volatile, and final. It should be pretty clear that
any client or co-programmer shouldn't be concerned
with temporary or intermediate data and that it
shouldn't be exposed, however, it should also be
pretty clear that the resultant data, or product of an
object, should be (in fact, as I have been arguing)
must be exposed, why else have the object in the first
place?As I already said if most of the classes in the system expose their data then something is wrong with the design.
DTOs are an excellent example of classes that expose all of their data. Yet in the total system, a single DTO can normally be expected to have 4 or more classes for each DTO. And those classes do not expose their data.
>
My arguments also come out against under-exposing the
intermediate values in an object, certainly within a
package, exposing data to related co-objects is
probably not much of a fault, except where it concerns
someone who says, "Hey, those values in Class Z could
be modified by Class B!"
Exposing data is always dangerous for two reasons.
1. The original developer might not have know what they were doing and thus instead of creating an Object they created something else (like half an Object, or two Objects in one, etc.)
2. The maintainance programmer might not understand the original design. Exposed data allows them to avoid this lack of knowledge. Thus instead of figuring out that the intent of the design or figuring out that the design must be refactored (after understanding it the first place) they use a kludge that the exposed data allows for.
Of course, the proper response is, "Hey!! Don't modify
intermediate values in class Z from Class B!!",
problem solved. No patterns, programming paradigms, or
rules of practice (which generally come out as do this
or perish!) necessary. It is simpler, and because of
that I would argue that it is faster, less prone to
error, and more enjoyable for the programmer to work
with as a result.
If everyone was a perfect programmer there would be no problems.
Since they are not, one must use what is available and what is practical to prevent those problems that are likely to occur.
And given that the intent of most programmers is tomake money with their code (or expose it via the
public domain) all of those people should learn how to
write code in terms of other people.
So exposing data is wrong for most of the people here.Clearly not true just because you said so.
No not true because you disagree.
Hard to tell what you are disagreeing with here though. That most developers want to make money and/or acclaim for their work?
>
>
Nothing I have seen so far is even close tosuggesting that your hypothesis is correct. And there
is at least indirect evidence that it is incorrect.
This was a rebuttal to your original point that stated
that 90% of development time was spent refactoring and
bug-chasing, which I agreed with and pointed out that
reducing code size and complexity by avoiding
unnecessary code (designed to avoid data-exposure or
designed for policy-adherence) would reduce the number
of hours represented by "90%" by a corresponding
amount.Again that is a hypothesis of yours. And current known scientific studies do not seem to support it.
>
You say there is indirect evidence arguing against??
Yes. Goto's can make code more dense and yet harder to understand and maintain. Because of that gotos are no longer used. Your hypothesis would suggest that gotos should be a good thing in the language (because the code is shorter.)
>
That is non-sensical in terms of this discussion.
An Object in terms of OO has 'data' and 'behavior'.The 'data' should be 'encapsulated' and 'hidden' by
the Object.
See the top of this post. Hiding your data is like
saying we have your bill, we know what your monthly
statement is but we can't tell you and so we sent you
that blank one...
Part of the problem is that a class tends to have many
different types of "data". A local, temporary loop
counter would be really difficult to work with if it
was exposed and modified from outside the scope of an
object.
Again let me point out that your response is non-sensical.
A local member variable is not data for the Object.

Similar Messages

  • Hardware question for new guy (you got to start somewhere)

    Hi,
    As the title states I am a complete novice so please bare with me. I'm confused about the correct configuration of the equipment that I have. So I'll start with what i have:
    Live 4 vocal harmonizer,
    Mackie 1202 VLZ3 mixer
    M Audio Profire 610 Firewire Interface
    New iMac Computer w/ Garageband & Logic
    Adam A7 Monitors
    The Profire 610 is new and I'm not sure how it works into the mix. Currently, I have my guitars and microphone going into the vocalizer. Out from the vocalizer and into the mixer. Out from the mixer to the monitors. I know the 610 should be connected to the computer via the firewire cable. What I am unclear about is where it fits in the above mix. It makes sense to me that it would come last to allow any effects/control to be recorded by the computer. Is that right? If so, this would mean that I would go out from the mixer and into the 610 interface? If this is the case, I would disconnect the XLR cables going into my monitors and insert them into the interface, and then buy 1/4 in to XLR cables to go from the line output of the interface back to the monitors. Does all that sound right?
    Also, I have a slight hum coming from the monitors at higher volumes. Is that normal or is there a way to reduce/eliminate that?
    Thanks so much for your help, I hope to be much more adept at this in the coming months.
    Thanks again,
    Charlie

    For the hum, I would suggest unplugging the speakers first (take the cable out of the speaker and not the mixer). Turn up the volume- is the hum still there? If so, you power may be an issue- you might want to invest in a power line filter. If not, then plug the speakers into the mixer- do you get the hum? If so, make sure that you don't have all the 12 channels cranked up (zero everything and start going through each channel to see if you get the hum- it could be a bad slider/pot or a power issue on the mixer). Keep going through each piece until you find the culprit.

  • Road map for HRMS consultant for new oracle guy, please help

    road map for Oracle HRMS consultant for new oracle guy, please help

    Hi,
    If you go through the Oracle sites you will come to know that HRMS Suite has various modules like Core HR, SSHR, Performance Management, Learning Management, iRecruitment, Compensation workbench, Absence Management, Payroll, Advanced Benefits etc.
    You will have to start with understanding the Core HR concepts which is the base of the entire HRMS suite where you define the core structures like Organizations, Job, Position, Grade, Costing, Hierarchies, Employee data etc and which forms the base of the other modules.
    Post you are done with Core HR you can start understanding the Self Service functionality and Approval Management Engine.
    If you are clear with these two modules, then you can pick any other module as per your Job requirement demands.
    You can do this all if you have an instance to access where you can do hands-on. In absence of which learning will be not be easy. On apps2fusion site which I have already mentioned you can view the training calendar and check for any relevant courses if you want to under go training as the quality of training is very good.
    Training is not a mandate and you can learn it without training also if you have the dedication and time by understand each and every action which you are performing in application and the impact of it.
    Hope it helps.
    Thanks,
    Sanjay

  • How can I set iTunes to check for new podcasts at a specific time of day?

    Hi guys,
    Anybody know a work around for this? I thought it was just a matter of clicking the refresh button at the time I want iTunes to look for new podcasts, but it doesn't seem to be the case...
    I want iTunes to look for new podcasts at 2 am every day. So, at 2 am, I clicked the refresh button in the Podcasts section in iTunes. It would then say, in the settings, that iTunes last checked for podcasts at 2 am and will look again at 2 am the next day. Awesome, not. Every single time I try this, iTunes always resets itself and decides to look for podcasts at 2:49 pm. I can't work it out.
    So, if anyone has a solution, I would love to hear it! I'm on the latest version. 9.0.2. Thanks for reading.
    Regards,
    Daniel

    I'm looking for the solution to this issue too. Once or twice, a full system restart has seemed to solve the problem temporarily but it slips back to an afternoon refresh after a few days.
    Seems like it would be simple for Apple to allow us to specify a time of day for refreshes in the preferences section.

  • Suggestions for new Sci-Fi on Vision

    Hi Guys,
    The Vision Programming Team have asked for Sci-Fi TV suggestions from Vision users, that we would like to see available via On Demand.
    So, via an email from Mod DavidM, I was asked to start a new thread, because they want our feedback. And 'FRINGE' has now been added to the Sci-Fi category (via the 'Serious Lack of' thread). So they do listen!
    So to kick off...my last post on the other, main Sci-Fi thread...
    Sci-Fi I'd like to see on Vision...
    The DUNE and CHILDREN OF DUNE TV mini series (original novels by Frank Herbert).
    They are both donkey's years old (2000 & 2003) and so wouldn't cost that much to purchase.
    Both mini series won numerous Emmy awards and were also rated as two of the top three highest-rated programs ever to be broadcast on the Sci-Fi Channel. 
    Battlestar Galactica. Both the TV mini series and the full TV series (the highest ever rated show on the Sci-Fi Channel), which Sky aired between 2003 - 2009. Pure quality.
    Also, as another plus, none of the above have ever been aired on British terrestrial television. So lots of potential for new viewers.
    Anyone else with any gems you would like to see?
    Rank - Mostly Harmless.

    Hi
    I am loving Fringe and I really liked series one of The Legend of the Seeker so looking forward to Season 2 when its possible
    I am a total Sci Fi freak as is the rest of my family here are a list of some of the stuff we have watched over the years and lately that we like.
    Star Trek - any of the series ie Enterprise, any of the captains
    Earth Final conflice
    Buck Rogers
    Science fiction theatre - old fashioned stories
    V either the old or the New I have not seen the New actually
    space 1999 - loved this when I was a kid not sure how it would look now
    The bionic man / women used to be good
    The Avengers
    Lost in Space - probably not everyones cup of tea
    Alien Nation - I was 50 50 on this one
    Stargate any of the series watched them all and enjoyed them
    Tales from the Crypt
    Andromeda
    Firefly
    Quantum Leap
    Dark Angel - this story line was  different
    The Outer Limits
    Xena
    Hercules
    Sliders
    Dr Who
    Torchwood
    The Twilight Zone
    X Files
    Just some of the good stuff out there for Sci Fi fans would love to see more of it On Demand
    A successful man is one who makes more money than his wife can spend. A successful woman is one who can find such a man.
    Lana Turner

  • How to make "Get Mail" button work for new IMAP acct?

    Recently, I started new Internet service with Charter. I set up my new email mail account on my iMac, and everything is working perfectly.....except that Mail checks the Charter email account for new messages ONLY when Mail is first started or the first time I "Synchronize". There's no way to know that messages are waiting, and no other way to download messages.
    When I click the "get mail" button, the little wheel thing appears for all the accounts (I still have my ATT accounts active), except the Charter account. When Mail automatically checks for messages, it checks all the accounts except the Charter account.
    The messages sent to the Charter account show up right away on the web (looking at my account on Charter's web site). I have no trouble at all sending emails. I have the account set up with IMAP (although, I tried POP, with no change). I have this account set to "Include when automatically checking for messages". I've shut down and restarted multiple times.
    I've talked with Charter support, and they've checked their server and all my settings, and everything is OK. I'm inclined to agree it's not an issue on their end. It seems to be Mail.
    Any ideas on how to fix this?

    Yup. It was set to "every 5 minutes", and changing that made no difference. Mail completely ignores the charter account when doing the automated mail check and when I click "get mail".
    I went to the local Apple store, without my iMac but with screen shots of the email settings, plus settings info from charter, and we set up the account on one of the iMacs there. It worked perfectly. The guy helping me suggested deleteting the account and setting it up again.
    I did exactly that, but the behavior is the same. So.....the next thing to do is take the iMac in. (sigh.)

  • New Guy Question about Name Changes from Logical to Relational

    Sorry for the "New Guy" question. I am trying to do this the way I wished it worked rather than the way it does.
    Lets say I have an Entity named "Current Database" with an Attribute named "Current Database Name". All this is in plan english for the Logical Model. Now when I generate the Relational Model I would like the Table named "CDCD_CURRENT_DB" and the column named "CURRENT_DB_NAME".
    I have been working with a Glossary and some other features trying to get this to work. It kind of does but I do not fully get it and I think I am missing out on much of the power of the product. I have been forcing the Nickname "CDCD" (As we call it) and the "Database" to "DB" in the "Preferred Abbreviation" of the Entity.
    I am working with v3.3.0.734
    Thanks for the help.

    Hi Sky13,
    it can be done with glossary but it looks to me what you want is not that native to glossary approach.
    it's good to look here for basics http://www.oracle.com/technetwork/developer-tools/datamodeler/datamodelernamingstandards-167685.pdf
    Example here also could be useful if you want to go with glossary - Re: Data Modeler: Naming
    If you want to use preferred abbreviation then it should be CDCD_CURRENT_DB.
    For me CDCD_ is just a prefix - you can handle it separately in relational model - on whole model, on subview and in both cases classification types also can be used to determine how objects are prefixed.
    You don't want Current to be abbreviated then do not put it in glossary however you need to check "Incomplete modifiers" check box in glossary.
    Entity property "Short name" goes to table abbreviation during engineering. There is a transformation script which will prefix table columns with table abbreviation if you need it. And another one can remove the prefix.
    You can define plural name in glossary and if entity name is a single word then plural will be used during name translation.
    Philip

  • CS5.1 support for new DSLR cameras (D600)

    I would like to understand the business decission (if there is any) why Adobe decided that for new DSLR  cameras support they will update only the Camera Raw version for the current release CS6 and not respecting the legacy for the n-1 release (updating the Camera raw for CS5.1).  This is a serious concern and disapointment.  Does it means that each time Adrobe has a new release , if i chnage the DLSR i am FORCED to upgrade and pay 190$ eventhus I do not need the new release features?

    Ah, thanks guys - I am very very happy to eat crow on that one!
    The actual point of my post was to make me feel better, and boy did it work!    I did not expect any actual relief, so actually now the post is twice is good as I thought - I was actually wrong!
    Anyway, I might mention (I didn't get into all the details) that I actually canceled the order for the d800e (the "e" version was backordered until just recently), as the d600 was just announced as my order was about to process.
    So actually I am in the same bad situation as the previous poster, but maybe now I will go back to the d800 - saving a $450 upgrade to CS6 actually saves half the difference in price between the cameras.
    And sorry for the rant on the 2 analogies.  It was not a troll.  I vaguely remember in my research that Lightbox comes with ACR, is that true?  Lightbox doesn't come with CS5.5 MC, but I wonder if i were to buy it ($99??) that'll give me the latest ACR that supports the d600, and problem solved.  I assume once i have the latest ACR it'll let me open straight into PS and not make me go through Lightbox and then PS?
    Anyway, if that is correct, that would be a much better answer to the original poster (and it saves him $100).  Other good answers (if this Lightbox hack won't work), might be:
    "It's an incredible amount of work to support nearly every camera and lens ever made in ACR, so even though it comes free with your software, you don't get free updates once your software moves to a new version."
    or
    "The d600 began shipping nearly immediately upon announcement, and it takes a while to update the software."  (perhaps the responder didn't realize it, but this was the situation with the d600.)
    But the car-story and "if you can afford a new camera, you can afford to pay adobe" were pretty tragic answers - someone needed to call you on it, or you would have only served to upset the original poster.
    Ha, PEBKAC, that is pretty good.  Not very easy to pronounce, though.
    I must say my last dozen interactions with adobe have all been negative, except this one, so maybe things are turning a new leaf.  You're lucky I didn't get into the story of when my HD crashed, and I had to call Adobe to re-activate my old CS4 PS.  It's awesome getting literally laughed at by the activation help desk person.  (I had owned the software for 3 years at that point, and had only ever activated it once.)  ...who just assumed I was lying.  "here now let me tell you how to deactivate the old version" "the HD is dead, it ain't going to happen" "well let me show you again, because you need to do that..."
    Oops, I did get into that story, didn't I?
    Best,
    Inline

  • The error message "No more virtual tiles can be allocated" appears when I try to use the effects in the quick editing mode in my Elements 13. The baton OK has to be pressed several times for loading all effect patterns. The error returns when selecting th

    The error message "No more virtual tiles can be allocated" appears when I try to use the effects in the quick editing mode in my Elements 13. The baton OK has to be pressed several times for loading all effect patterns. The error returns when selecting the particular pattern.
    The problem does not appear, if PH Elements 13 is executed in the administrator mode.
    The available computer resources are rather  large enough: CPU INTEL i7 4 cores,  16GB RAM, 1TB HDD + 32GB SSD, Windows 8.1.
    Please, advice how to solve this problem? Maybe, there is patch or updating available?

    Dear n_pane,
    Thank you for the quick answer. In the meantime I found other way to pass by the problem. I increased the cache level up to the maximum value 8.
    The errors reported as "No more virtual tiles can be allocated" vanish, but I still do not understand, why PSE 13 cannot work properly by the lower cache levels, having available maximum resources it needed (10443 MB RAM and 26.53GB SSD space for scratches), or cannot collaborate with the fast SSDs properly.
    I wish you all the best in the New Year 2015!

  • Scan a folder on a different computer for new files

    Hi all,
    I need to scan a folder for new files. I already have a deamon that can do this without a problem. What i need to do, is to scan files on a different computer. The program is going to run on a windows PC and needs to get data from a machine using Unix. I was able to get this done between two windows PC by mapping the drive of the other computer, put i cant do this with Unix.
    I found on the net a class used to make an FTP client(edtftpj-1.5.4). This works fine to get the folder contents once, but it dosen't scan it to see if there are new files. I could of course just loop this FTP client, but this could get very slow if there are to many files in the folder.
    So do you guys know of a way that i could scan this Unix machine for new files?? anything to give me a hint on where to look would be apreciated.
    Thanks in advance
    Alex

    why should we help you make a program that can be used to spy on people, because that's what you're trying to make (even if it's not your current purpose for it, but then it wasn't the purpose of the person who wrote the Michaelangelo virus to write a virus...)?
    It doesn't work on Windows either. As you noted you need to create a drive mapping, which effectively makes the mapped drive available to the other machine as if it were a local drive (applications, including Java applications, don't notice the difference).
    You can install a daemon on Unix machines that allows you to expose drives on them for access over networks as well, similar to what you can do with Windows machines.
    That's your best bet.
    Alternatively you will need to create some sort of server running on the Unix machine which does the work for you and reports the results to your main application on demand through a network connection.

  • 10.4.11 no good anymore for new ipoda

    Hi guys
    I have a 2007 macbook which I am very happy with. I had no problems running 10.4.11 up to now.
    Now I see apple are making it harder for me to shop with them as all new products require 10.5. However if your a pc user you can hang onto windows xp! Why are us loyal mac users being punished. Its not as if the ipad or latest ipods have any mega requirements. One would have thought itunes 10 would do the job. I always keep this up to date. So now to continue using my mac and use new ipods I have to put my machine under pressure with 10.5 (plus the cost!). I hear this will keep the fan running alot as I only have 2gb. Does anyone else feel frustrated?

    I can think of another reason to still own a Tiger: cost.
    I have been completely satisfied with macs, until now. My computer (Mac OS X 10.4.11) works great, except that now apple is saying it's too old for new software! I just bought an 4G I pod to find out that I have to spend yet more money to buy Leopard just so I can get music on it! I'll just bring my songs to my friend with a 10 year old PC and have him update it, the next computer I'll buy is a PC, one that won't make me pay to update software every 3 years! I bought this for my college computer, to last me 4 years at least, it's been 3 1/2. When you buy a computer you expect it to be durable and last a decent amount of time. I don't have money to buy the most recent version, especially when my PC friends don't have to worry about it! Really, this is frustrating.

  • How to split a string for 2 different matching patterns?

    hey guys
    i'm trying to split a string, using .split(regular expression), if two different pattern matches but i don't know the exact syntax for it. I want to split the string from letters and punctuations.
    This is what i'm doing, obviously it's not working, i'm not too sure if syntax are correct.
    String inputDigit [] = input.split("([a-zA-Z]) (\\p{Punct})");Please help me with this, thank you!

    Can you describe in more detail what you're trying to
    accomplish?ok, basically if you have a string which consists of letters, digits and punctuations. All i'm trying to do or want to do is store all digist within that string into an array. Therefore, i'm using split method to split the string wherever you find a letter or a punctuation. But i don't know what is syntax for using two different patterns at the same time.
    // For example if you have a string "Eeyore 61 2.986PoohPiglet007Kanga-23"
    // i only want: 61 2 986 007 23. I know i can use substring // but that would be a slightly long process

  • Gmail continuously checking for new mail!

    this is a very perplexing problem and i have searched forums for how to fix it but as i don't quite know what to call the problem, i haven't found any solutions yet!
    i just got a new iMac and proceeded to set up my two gmail accounts with mac mail. one works perfectly fine, the other, for some reason unbeknown to me seeing as both were set up in the exact same way, the second gmail account is stuck continuously checking for new mail with the loading circle next to it.
    i have tried deleting the account and adding it again several times, as well as restarting my computer and mail. i have tried taking the account offline and then connecting again but nothing has worked so far.
    the settings are EXACTLY the same as the first gmail account that works fine. both are set to IMAP and as i didnt get the option to manually set up an account when i added them, they were both set up automatically by the mac mail app.
    it might be helpful to note that i have the same two accounts set up on my macbook with mail 3.6 and they both work fine, so it is not a problem with my gmail account. (however on the macbook they are set up as POP not IMAP.. but i dont see an option to change that in mail 4.2)
    PLEASE HELP! as i am very frustrated i cannot work this out on my own. not sure what other information you need but please just let me know if you need to see a screencap or something.
    many thanks in advance for any help that can be provided.

    FWIW:
    Apple Mail 4.0 and Snow Leopard seem to have multiple issues, rather long threads that follow (see links), but some users with multiple Gmail accounts have tried different solutions: best of luck.
    http://www.google.com/support/forum/p/gmail/thread?tid=15f2852996dedf1f&hl=en
    Also:
    http://forums.macrumors.com/showthread.php?t=776735
    One guy notes:
    +Possible Solution Found+
    +Ok, I think I may have figured something out here....+
    +I use IMAP as stated earlier.+
    +I started from scratch with my gmail accounts in mail 4.0.+
    +I hit Mailbox > Take all accounts offline.+
    +Then created my 2 gmail accounts, following gmail's support page I unchecked all the options on the Mailbox Behaviors tab.+
    +I used [email protected] for the username, not just the first part of my email, i.e. [email protected] This is also suggested in the gmail help guide, but mail doesn't set it up this way.+
    +I forced my SMTP port to 587 in mail's setting instead of just having it use "standard ports 25, 465, 587"+
    +I created both accounts, set those options, and hit take all mailboxes online. Mail seems to be downloading my messages from gmail smoothly so far for both accounts at the same time.+

  • Any compensation for new buyers?

    I was ready to buy an iMac after Leopard came out. However, it has been delayed until October after being scheduled for the Spring. I hate to wait, but I also hate to pay rather quickly for an upgrade. So will Apple do any kind of compensation for new buyers?

    I don't think I can see your point. They will roll out the new OS when it's really ready (at least we should all hope so). If you've been using any particular product for a while, you should realize that the manufacturer can't guarantee when they will have a viable new product. I get your frustration and the fact that you don't want to put out good money for a product that will be better in a couple weeks, months, or maybe even days. The fact is, Apple will hopefully put out a new OS when it is ready, and there's no way they can know it's ready until it's ready.
    I harassed the guy who sold me my first computer with the same sort of reasoning. He responded by saying that there's always a new product around the corner. Looking back, he wanted to sell something that day, but he was also telling the truth.
    Bottom line:
    Nobody can predict when the next OS will be released. Sure, folks who are developing the next release and reporting to the head honchos will have a better idea than most, but, the head honchos are just paying the guys that write the code who can't say when they will be done.
    You want to buy a new computer, buy one. You want the latest and greatest hardware/software, you're just going to have to pay. Even if you buy a Mac tomorrow and get a free 10.5 upgrade 4 months from now, there will be a better mac to run it on.
    I understand your question/complaint, but the testing of new technology does not bear out an answer you will want to hear. We don't want Apple to put out an OS that's not ready just because they said it should be reasy on a particular date.

  • Mail constantly checks for new mail; downloads same emails repeatedly HELP!

    For the last three days (since 19th), Mail has been downloading the same emails over and over again. I first noticed a problem when about 20 spam emails that usually route to my Junk folder appeared in my Inbox. I thought I had just moved it incorrectly and deleted them, then they appeared again later.
    The mail jogger cycle (next to Inbox) keeps turning and turning like it can't stop checking for new mail. How do I get it to stop?? The emails are multiplying like gremlins in my Inbox and driving me nuts!
    Also, it only downloads new emails when I first open the app. I have to force-quit out of Mail, then reopen, and I will get a couple of new emails, and then ALL THE EMAILS FOR THE LAST THREE DAYS AGAIN.
    Mail was working fine for me until three days ago. The only thing I've changed recently is a Software Update on the 15th for QuickTime and iTunes.
    Please help! I tried to Repair Permissions and it didn't do anything. I also tried removing all messages from the server and that did nothing either.
    Mail Version 2.1
    THANK YOU ANYONE WHO CAN HELP ME!!
    iMac G5   Mac OS X (10.4.7)   2.1 GHz, 512 MB Memory

    UPDATE: I think I got it to stop checking mail. I have Yahoo mail and I checked my email through online Yahoo. I was able to delete a bunch of emails and it suddenly stopped checking for email in the Mail app.
    HOWEVER, it will NOT remove some of my junk emails. I was able to delete over 100+ of them. But one specific message (which I now have 8 copies of) will not go away. It is one of those 'Delivery Status Notification' emails. Is this a virus??
    I've tried Erasing Deleted Messages and Erasing Junk Mail. Neither helps. These emails won't go away.
    Help please! I would be very grateful.

Maybe you are looking for