Thursday, July 21, 2011

Effective Eclipse, part 3


 Don't write the code, generate it. I always wanted to develop a project in minutes, or at least a module in just 10 to 15 minutes. All I wanted is to be a very perfect coder. Who doesn't leave any work for testers. I wanna be a nightmare of every tester. If we developers could code perfectly, what will be left to testers? Except counting the floors. AS a first step . . .

I hope that we will never be able to generate applications. I would be without a job then and you probably too. But what we can generate are various repetitive and boring pieces of code.

The first thing that can be generated is class file. You are using it, but you have probably never realized how much time does it save you. If there was no class skeleton generation, you would have to: create new file in the proper directory (with respect to package (and create the folders too)) and place the package statement at the beginning of a class.

I will make a short stop here.

I noticed that all people generate their classes, but not all of them specify implemented interfaces and extended class. Surely, you can generate the class and write the extends and implements part afterwards, but it involves moving the cursor, writing and eventually generating abstract or implemented methods. I found it much easier to press ALT + E (extend) to add extended class and ALT + A (add interface) to add interfaces in the new class wizard. My class will then come out with empty overridden methods and correct imports.

If you look at the Source menu you can find more "Generate" commands. But none of them is so valuable and useful as Eclipse templates. They are the true gem in my daily work and it is pity they are hidden out of sight. And they are hidden well.

What are they and how to get them?

Templates serve as a shorthand for a snippet of code. You type in the magical word and it will be transformed into the snippet.

Some examples:

Type sysout and press CTRL + SPACE (the autocompletion) and it will be automagically changed to System.out.println(); with the caret waiting right in the middle between the parenthesizes.


sysout template
sysout template expanded


While we are here, let's explore the next interesting feature. Type "for" and press CTRL + SPACE to change it to a skeleton of a for loop.


for loop template expanded

 
The for template is a showcase of templates' power.

Notice the blue boxes around some of the commands. They represent the caret stop and you can move between them using the TAB key. Now, with the caret on "iterator", type the name of the variable representing the iterator. Its name will be changed in the whole loop as you type (the occurrences are marked with a light blue background). Now just two more TABs to change the collection variable and the type. Noticed the green line waiting in the empty line? It marks the position where the caret will jump when Enter key is pressed. So after changing the variable type you can just press Enter and the caret will jump to the empty line. When you use autocompletion the green marker is always somewhere around, waiting for you to press Enter.

Every particular template is closely bound to editor. Each editor has its own defined set of templates, which are applicable only in that editor type. It is quite logical that the sysout template will not work in JSP editor. Furthermore, each template is applicable only within the specified context of the particular editor. There are two contexts in the Java editor for example, Java and Javadoc.
To see list of all templates open Window -> Preferences and type templates into the search box.


list of all available templates


You will get a list of all editors and their respective template settings. Your list may vary from my list, because it depends on installed plugins.


I encourage you to walk through the list to see what predefined templates are available. Not all of them are useful, but you need to see it, because what does not work for me might work for you.
The true and real power of templates lies in custom templates, but I will leave this topic for the next week article.


Apart from the fact, that it can expand templates, CTR + SPACE has few more interesting uses. It is an autocompletion shortcut and it can complete the names of variables or methods and in fact, it is its most obligate and the most famous usage. But it has some more surprises to offer. If you get used to it, you will be hitting it often, even in situations where there is obviously nothing to autocomplete. Or is it?


variable name suggestion


Guess what is on the picture above? It is eclipse trying to autocomplete the name of a variable.

It is pity it cannot read my mind. I often find myself hitting the shortcut in the middle of the string ever wondering why it doesn't complete the word.
Never can remember the signature of a method you want to override? Never mind, hit CTRL + SPACE and you will get a list.


override suggestions


It can assist you in private method creation,


method stub


 and it can guess what to complete even from the upper case letters.


OOME suggestion


Warning: Using autocompletion and templates can lead to uncontrolled ctrl + space hitting, surprises and productivity boost.

Effective Eclipse, Part 2

Man, I’m such an impatient girl. I cringe whenever I see somebody squint and frown, looking for a JSP file in Eclipse by browsing painfully through the gazillion JSPs in multiple folders in the Package Explorer. I squirm whenever I see somebody looking for a Java class by clicking through packages, one by one, backtracking if it’s the wrong package, and so on, until he sees the correct Java class.

I mean, any resource in the workspace is literally seconds away. Ditto to classes (and interfaces, and members, and so on). Why waste time and brain cycles to wade through countless lines in countless files? I thought that every Eclipse user knows this, in fact, if you’re reading this, most probably you already know this too. But thousands of Eclipse JDT users who never bother to read tech blogs in all probability will also never bother to find out what Eclipse can do for them. And it’s a pity, really, because they’re really missing out a lot. So maybe if you know one, you can forward this to them or something. Make them more productive or something, ya know. 30 seconds saved for every file can add up to really a lot!
So without further ado, let’s say you want to:
  • Open any file quickly without browsing for it in the Package Explorer: Ctrl + Shift + R. This shortcut opens a dialog box that accepts the name of the file you’re looking for. It even accepts wildcard characters, yo. Typing *-conversion.properties will give you the list of all files that ends with -conversion.properties. So everytime you want to open a file–stop that hand from going to the mouse, and press Ctrl + Shift + R instead!

Opening a resource in Eclipse

  • Open a type (e.g.: a class, an interface) without clicking through interminable list of packages: Ctrl + Shift + T. If what you want is a Java type, this shortcut will do the trick. Unlike the previous shortcut, this even works when you don’t have the Java source file in your workspace (e.g.: when you’re opening a type from the JDK).

Opening a type in Eclipse

  • Go directly to a member (method, variable) of a huge class file, especially when a lot of methods are named similarly: Ctrl + O. Say, you’re browsing through a file which has 500+ lines of code. How do you look for a method? Don’t use Ctrl + F and then type the method name. Use Ctrl + O, which gives you a list of candidates that match what you’ve typed so far. Select the member you want using the arrow keys, and press Enter. (Alternatively, if you just want to jump from one member to the next (or previous), you can use Ctrl + Shift + ↓ or Ctrl + Shift + ↑, respectively.) UPDATE: As Nick pointed out in the comments section, pressing Ctrl + O again shows the inherited members. Thanks Nick! :) 

Browse Member
ctrl_o_2.jpg 

  • Go to line number N in the source file: Ctrl + L, enter line number. Of course if the stack trace is in the Eclipse console, you can just click the hyperlink. But if it’s in a log file or something, just use this shortcut to go to the line in a jiffy.

Go to a line number

  • Go to the last edit location: Ctrl + Q for . If you have a big file, it’s annoying to jump from one location in line 1000+ to 2000+ only to realize after looking at line 2017 that you’ve made a mistake in that location near line 1000+ just now. This shortcut brings you right to where you last edited a file. Very handy in a big file. Gone are the days of “let’s see… where did I edit it again… nope, nope… ah there it is”. (This even works when you’re already looking at a different file.)
  • Go to a supertype/subtype: Ctrl + T. Before I found this, if I want to go to the superclass of a class, I’d go the the very top of the file, hover my mouse over its superclass, hold Ctrl, and click. Disgusting. Now I just press Ctrl + T and I get this dialog below, which toggles between supertypes and subtypes when you press Ctrl + T again.

Subtype hierarchy view
Supertype hierarchy view

  • Go to other open editors: Ctrl + E. I know you can cycle through the editors using Ctrl + F6 as well, but I prefer Ctrl + E because Ctrl + F6 has this annoying behaviour of requiring you to keep the Ctrl key down, and the distance between Ctrl and F6 is so far I have to twist my left hand to do that. Just press Ctrl + E, and either use the arrow buttons, or type the name of the file you’re editing.

Open editor

  • Move to one problem (i.e.: error, warning) to the next (or previous) in a file: Ctrl + . for next, and Ctrl + , for previous problem. No need to lift your hands off the keyboard to click on that red or yellow stripe.
  • Hop back and forth through the files you have visited: Alt + ← and Alt + →, respectively. I have to admit I don’t find myself using these two often, though.
  • Go to a type declaration: F3. Alternatively, you can hold Ctrl down and click the hyperlinked variable or class or whatever it is the declaration of which you want to see–but why lift your hand off the keyboard? Just press F3 and Eclipse will bring you to the declaration of whatever is at the cursor at that moment.
OK, that’s it for this post. There are tons of other Eclipse shortcuts not covered by this article. To see the whole list, just open up your Eclipse (I’m assuming Eclipse 3.2 here–in older or more recent versions this may differ slightly), go to Help → Help Contents → Java Development User Guide → Reference → Menus and Actions. The whole motherload is there, from generating comments, correcting indentations, surrounding with, and so on.

The point I’m trying to get across is: Eclipse has a LOT of shortcuts to make things real easy for you. Java (or heck, any software) development is hard. We shouldn’t make it harder on ourselves by fighting our tools! Let our tools help us as much as possible, so we all can go back on the dot and spend more time with our family, lovers, or whatever it is we want to spend more time on. There’s no honour in working hard inefficiently. Only disgrace.

source: rayfd

Effective Eclipse, Part 1

You should try to keep your hands on keyboard. The less you touch the mouse, the more code you can write. I am trying to keep the mouse laying still and control the IDE completely using keyboard. What do you think is faster: pressing ALT + C or right clicking the project, selecting Team -> Commit?

It is said, that if a function does not have a key binding, it is useless. Below you will find a set of essential keyboard shortcuts that I love. These shortcuts are set up by default, they should all work.
CTRL + D

Delete row. Try it! You no more need to grab the mouse and select the line, no more Home, Shift + End, Delete. Quick and clean.
ALT + Up/Down Arrow

Move the row (or the entire selection) up or down. Very useful when rearranging code. You can even select more rows and move them all. Notice, that it will be always correctly indented.





ALT + Left/Right Arrow

Move to the last location you edited. Imagine you just created a class Foo, and now you are working on a class Boo. Now, if you need to look at the Foo class, just press Alt+Left Arrow. Alt+Right Arrow brings you back to Boo.

CTRL+SHIFT+O

Organize imports. What happens when you first use a class you have not yet imported? You will see an error. But when you press this magical combination, all your missing classes will be imported, and the unused imports will vanish.

CTRL+1

Probably the most useful one. It activates the quick fix. Imagine you create a class, which implements some interface. You will get an error, because the inherited methods are not yet implemented. While you are on line where the error occurs, press this combination to activate the quick fix. Now, select the "Add unimplemented methods" option. You can use the quick fix at every error you ever receive.
Quick fix comes handy in other situations too. My favorite is the "Split variable declaration". Sometimes I need to broaden the scope of a variable. I activate the quick fix, split declaration, and use alt + arrow to put it where it belongs. You can find even more usages: Convert local variable to field, rename in file, Inline local variable..





You could use the "Split variable declaration" on the bar variable, and then move it with Alt+Arrows above the try block..




Or you could use the "Add unimplemented methods" fix here.
The best thing you can do if you see an error is to use the quick fix.
CTRL+SHIFT+T

Open Type. Imagine, that you need to have a look at the Foo class. But, where is the Foo class? Is it in the Boo project and in the foo.bar package? Or somewhere else? With this shortcut, you don't need to know. Just press it, type Foo and you are in.





CTRL+E

Shows you a list of all open editors.



CTRL+F6

Use to move between open editors. This is an slower alternative to Ctrl + E. Comes handy in a situation when you want to periodically switch between two editors, something, what is nearly impossible with Ctrl+E as it sorts entries quite randomly. Or you might just use Alt+Arrows..

CTRL+F7

Move between views. When in editor, press Ctrl+F7 to switch to the Package Explorer, or hold Ctrl and press F7 multiple times to switch to other views.
CTRL+F8
Move between perspectives. The same as previous.




 

CTRL + F11

Runs the application. What gets launched depends on your settings. It will either launch the last launched class (my preffered way) or it will launch currently selected resource (the default way). If you want to change its behavior read the previous post.

CTL + N


Open new type wizard. This is not very quick because you have to select the wizard type (weather you want to create new class, jsp, xml or something else) in the next step. Much faster way would be if you could just hit the shortcut and invoke the particular wizard. It is possible, just keep reading..

CTRL + M

Maximize or umaximize current tab.

CTRL + I


Corrects indentation.

CTRL + SHIFT + F

Formats code. You can make a beautiful looking code out of a mess with this. It requires a bit of setup, but it is well worth it. You can find its settings under Window->Preferences->Java->Code style->Formatter

CTRL + J


Incremental search. Similar to the search in firefox. It shows you results as you type. Don't be surprised, if you hit this combination, nothing happens - at the first glance. Just start typing and eclipse will move your cursor to the first ocurence.

CTRL + SHIFT + L

Shows you a list of your currently defined shortcut keys.

I don't like your shortcuts

Such is life nowadays. Remember, you can always change those bindings to match your preferences. Open Windows->Preferences->General->Keys. Now you can use the filter to find your shortcut and change its binding.

The real fun begins when you cannot find the command you are looking for. The key here, is to have the "Include unbounds commands" checkbox checked. It will show you all commands, even those, which have no keys bound.



While you are here, I recommend to add the following bindings:

CTRL+SHIFT+G

Bind this to "Generate getters and setters". This is a "must have".

ALT+C

Bind this to SVN/CVS "Commit".

ALT+U


Bind this to SVN/CVS "Update".

Now, type "new" (without quotes) in the filter text. You should see a list of all new type wizards. Choose the most frequently used and assign them a shortcut. For example, the most used wizard for me is the new class wizard. Thus I assigned it the CTRL+SHIFT+N keys.

Let me demonstrate a quick way to create new class now.

Hit CTRL + SHIFT + N (or the combination you assigned in the previous step). This should bring up new class wizard. Type in the name and press ALT+E. You can now select a class which will be a superclass for the newly created class. Hit ALT+A and select all implemented interfaces . Now hit ALT+F and your class will be generated. Eclipse will also provide the default implementation for all abstract and interface methods you inherited.

Did you notice the weird underscores everywhere in the dialog? They give you a hint about the shortcut key. Hit ALT and the underlined letter to press the button, check the checkbox or get focus for a textfield.





Did you notice the underscores?

I think that using shortcut keys is the fastest way to productivity and if not, then at least your wrists will say you a silent thanks. Now, don't wait, go on and assign keys to the features you use most.
One final tip from Andriy:

The problem is that there are so many keyboard shortcuts. I used to keep a printout with all the shortcuts I wanted to use. Finally I wrote an Eclipse plugin MouseFeed, which reminds the keyboard shortcuts for the actions called with mouse. You can even tell it to enforce some shortcuts - the action will run only if called with a keyboard shortcut.

So if you are struggling with yourself, if you want to use shortcuts, but always subconsciously touch the mouse, install the plugin and let it enforce the shortcuts - the mouse will be useless and you will be forced to use keyboard.

What shortcuts do you use?

Source: eclipse.dzone

Tuesday, July 12, 2011

Hitchhiker Guide to Cloud Computing

Cloud computing is where resources are shared as services over the internet without requiring them to be installed or downloaded over the local system. User’s who have anything to do with Information technology ranging from individuals to big companies/corporate houses can use cloud services and pay only for what they use.

Below are the points that need to be thought through while migrating to Cloud or using cloud services:

Vendor Selection

Selecting the right vendor who understands the needs and business requirements of the customers offering the best possible solution at an affordable price is important. Quality, data security, cost, SLA and post sales support should be the criteria for selecting a vendor. One should not go after big names making towering claims.

Service Level Agreement 

Service level agreement (SLA) offered by the vendor should fit into your organizational policies. There are many questions that should be answered by the provider e.g.  Uptime and availability of the services, process of switching from one provider to another and any extra charges for this, ensuring that associated data is removed after quitting the service and downtime in moving between providers.

Evaluate Infrastructure

It sounds very tempting that software and hardware costs will drastically come down once the applications are moved to cloud. But assuming that cloud computing can solve all your problems can be a bit misleading. Many enterprises and corporate houses will have highly sensitive data which they might not want to share or migrate to the cloud, so local infrastructure cannot be removed completely. Internet connection, routers, firewall, Wi-Fi points, local backup server and printers are some constituents of infrastructure which will still be needed. Careful evaluation of the infrastructure is needed when using cloud services.

Migrating application to Cloud 

Migrating application to cloud could potentially be very quick, straightforward and cost effective, but there is a significant cost if data needs to be transferred outside cloud, between cloud and some other public resource. Cloud platform does not support enterprise security schemes (though there might be some exceptions like allowing cloud machines to be joined with enterprise domain), in such scenarios enterprise single sign on will not work and might require creating separate logins for the application users or some sort of identity federation will be required. So there are many areas which need to be taken care of before making a migration decision.

The Cost

An important question that comes in mind while migrating applications to cloud or using cloud services is the cost involved. Though you have to pay only for what you use, there might be other charges like setup fee, effort in migrating the application to cloud, purchasing subscriptions (charged only once) etc. that needs to be paid. One needs to fully understand the cost model of the service provider and ask the service provider to declare any hidden costs that may be there – some of which may include charges for going over storage limits, the number of help desk calls and the amount of bandwidth you utilize.

Performance

Applications running remotely do not have a smooth user experience; this is because of the intermittent internet connection. Data has to travel around the internet and it goes through many processes as it works its way around various routers, data centers, servers, and other infrastructure. Issues like high network latency, congestion, and slow network speed can become a routine problem and affect the overall work and timeline of deliverables. A solution to this problem is utilizing the geographically located content delivery networks setup by cloud providers; this would decrease the data travelling time and prevent congestion thereby increasing the performance.

Safety Issues/Data Security

Security can be a big concern, especially if there is legally sensitive information to be stored. It is necessary to evaluate the providers security by finding out whether the service provider is a regular target of hacking attempts or how often have his systems been compromised, confidentiality of information, ensuring that information flow is not shared, ensuring that the data stored on the cloud is as safe as any other solution on the local system, data encryption not only while traveling to and from the cloud solution but also when being stored and backed up, trusting the service provider for updating/ backing up records, finding whether regular audits are conducted for the provider. It is important to address all these issues as your decision to move to cloud might do you more harm than solving your problem.

Application Support

It is useful to know out the level of control that you have over the application on cloud. One needs to lookout for the impact of service provider’s average issue resolution time.

Technical Integration

Many enterprise applications cannot be completely migrated to cloud either due to cloud restrictions or due to data dependecies with other on-premise applications. In such scenerios only a part of the application can be migrated to cloud and other part remains on-premise which poses integration challenges and might require additional effort and costing. So it is important to analyze these challenges that one might face and then decide as to how and which applications need to be moved to cloud.

Rollback & migrating to another cloud

There can be a situation where an application is migrated to cloud but later the application needs to be migrated to other cloud, there is a risk here as migration costs could be significant and some cloud service providers require a long-term contract to avoid setup fees.

So, the cost and benefits of moving an application to cloud should be analysed properly before actual application migration.

Like any new technology cloud computing has its own set of challenges. Careful handling and good understanding of the above mentioned points can not only reduce the risks but can prove as a cost effective solution to your business needs

By Mudit Malhotra
He is a Software Engineer in HCL Technologies. He has a profound experience in Cloud Computing.

Here are the some valid points that I thought worth mentioning it:


+2
 by Brian Zhu, Jayashree Pandu
Did I Piss You Off's profile photo
Did I Piss You Off - Bla Bla Bla....Its a another, and less interesting way of say network resourses...or Networked. Cloud...haha someone has been playing with the Visio icons to much! lol I think they are trying to get stupid people up to speed with the rest of society that already understands simple networking! lol

Jul 12, 2011   
Olivia Cassandrae's profile photo
Olivia Cassandrae - No you did not piss me. Come on, you can comment what ever you want to . . . ! Thank you.
Jul 12, 2011  -  Edit   
Did I Piss You Off's profile photo
Did I Piss You Off - Very beautiful and nice too! Are u impressed with g+ too?
Jul 12, 2011   
Adam Hirschfeld's profile photo
Adam Hirschfeld - Like you said earlier about being bound- it's all in the design, google+ is just more utilitarian. If this is a trial run, where is it going to be in a year? I see it replacing facebook...
Jul 12, 2011    
+1
   
Brian Durden's profile photo
Brian Durden - Cloud computing is quite a bit more complex than 'simple networking' or 'network resources'. MUCH more complex. Not only does the concept cover multiple network types for storage, but also for access.

Saying cloud computing is just 'networked resources' is like saying a modern automobile is just an engine. There's a lot more to cloud computing than 'just a network' much like there's a lot more to the Google search algorithm than string parsing.

Nice article, I've not seen most of that information put so well together.
Jul 12, 2011    
+1
   
Adam Hirschfeld's profile photo
Adam Hirschfeld - Yes Brian, exactly. This all started with professional video editers actually, as a way of rendering projects faster, people have been doing this as long as computers have existed, it's only now going mainstream, and it's only gotten more complex as people use various new networks and points of access and all that as you said.
Jul 12, 2011   
Olivia Cassandrae's profile photo
Olivia Cassandrae - Brian thank you. Cloud Computing gives a very good substrate to a developer. It is a powerful tool, if not use wisely it can be a disaster as well.

I was once failed to sell one my product to a client just because I did not heed the security of Cloud Computing.

This is my first failure in my IT field. Total disaster, when my client found a very big loop whole in our project that we were proudly presenting him. We were like total looser's.

But fine, it taught us a very good lesson. But still I believe it's a very portable network I ever encountered in my career . . .
Yesterday 12:07 AM  -  Edit   
Gary Cameron's profile photo
Gary Cameron - Everything old is new again. I remember more than 10 years ago when sun was trying to pitch diskless workstations where everything from the apps to the OS was in the cloud (read PXE boot of a big ass server) but it failed miserably because network bandwidth and latency couldn't be brought down to the level where replacing the disk made sense.

Nowadays, it all boils down to how well you trust your cloud provider as far as security and reliability goes. Think what is the worst that can happen if that trust is broken and the cloud goes down, goes bankrupt, gets hacked, is unscrupulous enough (or has unscrupulous employees) to sell your data to competitors or spammers.

But maybe the cloud's time has finally come. Proceed with caution...
Yesterday 7:50 AM   
Olivia Cassandrae's profile photo
Olivia Cassandrae - Cloud is the future now, no one can deny that part. I am looking forward to work in it. It's a hassle free.

Caution is an essential thing which cannot be over looked.

. . .
Yesterday 3:59 PM  -  Edit   
Did I Piss You Off's profile photo
Did I Piss You Off - How do you guarantee security with cloud computing?As the focus moves to more of this style setup, it breeds bottlenecking single point failures? A system hack will affect millions of computer systems not just one. Downtime, no scheduling for patch rework.....on and on...your at the mercy of what a large corporation wants you to do.
Yesterday 7:37 PM (edited Yesterday 7:44 PM)   
Did I Piss You Off's profile photo
Did I Piss You Off - Second issue...why make a system that everyone must pay for the services when you have them free now? I would think that it is taking away from what the Internet is all about and turning it into a large Corporate network!

Will this cloud be setup for all OS's. Will be the next question?
Yesterday 7:39 PM   
Did I Piss You Off's profile photo
Did I Piss You Off - The "Back End" of the internet will always be hidden to people who want to pay extreme prises for software and ride the bandwidth of the corporate money makers. There is a whole new world out there that you probably do not even know exists and its called Open Source! ...hehe..I sound like Morpheus.

Another question..who is going to pay for the US to come up to speed to the rest of the world....we rank what... 14 down the list in speed. We are turtles compared to most places.
Yesterday 7:47 PM   
Brian Durden's profile photo
Brian Durden - Security is the current hot-button issue with the cloud. And yes there IS a way for off-grid "cloud" setup. I use one at work. What does bottle-necking have anything to do with this? You're discussing a potential localized bandwidth issue? Do you really know how a cloud works or is it still 'simple networking'?

Why make a system that people have to pay services for? Because many companies don't like running their own internal IT division to maintain their cloud and connected client software/hardware, it complicates things greatly and can be quite expensive (especially when involving a non-tech company like a science R&D group). One of the things the Internet is about is remote access to shared files; cloud computing is an extension of that.

Clouds are generally OS independent regarding access. GMail is cloud-based email; are you required to use Microsoft Windows to use GMail? Of course not. Are you required to use Google Chrome to get at GMail? Of course not.
Yesterday 7:47 PM (edited Yesterday 7:48 PM)   
Did I Piss You Off's profile photo
Did I Piss You Off - Bottle-necking...lets say you resource is overseas from the US...and the main lines that bring this source into the US have been compromised...how will the use of it be utilized. Who will control he access point...will it be cloned as it is now by the Tempest style system so that it can be monitored?

This is just two simple HUGE problems for the US.

I have pushed cloud computing for many years and have heard every argument....I think the system is two young and needs BILLIONS of dollars of infrastructure changes to allow it to work...like it was designed to work.

@Brian....your thinking very low level...gmail really...There is not a real R&D firm that would ever use a public system like this. It is not secure and eyes are all over it.

Also, I disagree....let me put it on a level you can understand..... Lets say you company is using a Linux system and the only Cloud resource is Microsoft and some piss and .net language...how do you get around that problem?
Yesterday 8:04 PM   
Brian Durden's profile photo
Brian Durden - Why would the 'resource' be over seas? Cloud computing puts multiple copies of objects in multiple areas of the world (if needed). Google's GMail is a prime example, it isn't comprised of a single storage area; there are multiple copies of emails and other data sitting out there.

I don't see it as a huge problem at all; I think you're just rationalizing here.

I'm using GMail as an example of your inability to understand that Clouds are cross-platform, I'm not proposing other companies follow its model. Let's use reading comprehension!

Your posited problem is a farce. Windows and Linux are operating systems not cloud storage models/systems. "Linux" isn't a cloud-computing solution nor is "Microsoft". If the interface for access is there then it doesn't matter what client-side OS one uses (which is why I used the simple GMail example). I don't think you quite understand as much as you think you do; either that or English is not your primary language and you are having a difficult time understanding what I am saying (not a bad thing, just an observation).
Yesterday 8:27 PM   
Did I Piss You Off's profile photo
Did I Piss You Off - ┌∩┐(◣_◢)┌∩┐ sometimes some just have a week mind..mine included, but more so on yours!
Yesterday 8:52 PM   
Olivia Cassandrae's profile photo
Olivia Cassandrae - + Brain Durden, resource means the people hired to work on some product / project.

'Did I Piss You Off', how do I address you gentlemen? What's your name? DIPYO, let me know how I am supposed to address you.

Dipyo, I agree with him, he has a valid point Brain, you have lost in between, please once again read his comments, he raised very good set of points that has to be given a thought.

1. Security - which will blow the entire system,
2. Patch reworks,
3. Huge costs,
4. OS support,
5. Back ends and
6. Speed.

These six points are valid ones which has to be given a thought. Except for this point, "I would not think that it is taking away from what the Internet is all about and turning it into a large Corporate network!" I would concur with Dipyo.
Yesterday 9:17 PM  -  Edit   
Brian Durden's profile photo
Brian Durden - dipyo, so your rebuttal is a weak insult? Nice.

Olivia, dipyo's points are irrelevant. The word 'resource' in the sense of cloud computing does not pertain to people; it pertains to a piece of data or group of data. The original discussion involved him claiming cloud computing was 'simple networking' and just existed to help the uneducated public understand 'simple networks' better. After that dipyo is unable to offer any kind of argument outside of either twisting around what I say or insulting me.
Yesterday 10:22 PM   
Did I Piss You Off's profile photo
Did I Piss You Off - I can see where you might not understand the points, because your scope of reason is highly skewed with a lack of education or experience.

Do you want me to make it easier for you to understand...I have kids. I am good at it.
12:30 AM   
Olivia Cassandrae's profile photo
Olivia Cassandrae - Brain, I agree, resource is data; I meant by people means of course data. The outcome of this people is data and that has to be transported to the USA. And Dipyo asked here what if this data gets compromised? Who will control and what would be the access point.

I get that you are talking about the data centers, but that's the storage. It's not the topic. It is a point which he is not covering or even touched. He is talking of actual Cloud Computing. Means it's implementation.

How it is implemented into a organization? He is talking about the loop holes here. And while implementing Cloud Computing, CC, he gave those six points.

He is rude and insulting, it's his property. But he has valid points at his end. Give no attention to his mannerisms. You be at your own tone.

. . .
1:26 AM  -  Edit   

Wednesday, July 6, 2011

Playing with Strings and String Buffer

/*
* A palindromic number reads the same both ways.
* The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
* Find the largest palindrome made from the product of two 3-digit numbers.
*/

/*
* @author Jayashree P
* @date July 5th 2011
*/

public class  Palindrome3D
{
    public static void main(String[] args)
    {
        System.out.println("Plaindrome of 3 digit multiple!")  ;
        for(int firstNumber=99  ; firstNumber >= 10 ;  firstNumber--){
            for(int secondNumber=99; secondNumber >=10 ;  secondNumber--){
                StringBuffer checkPlain = new StringBuffer(secondNumber * firstNumber+"") ;
                StringBuffer reverseCheckPlain = new StringBuffer(checkPlain)  ;
                /* This is interesting, StringBuffers don't equate via equals method.
                    f (secondNumber==91){
                    System.out.println(checkPlain+" , "+firstNumber+" , "+reverseCheckPlain+" , " +reverseCheckPlain.toString().equals(checkPlain.toString()))  ;
                    System.exit(1)  ;
                }*/
                //StringBuffer reverseCheckPlain = checkPlain  ; // This will give you one value with two addresses.
                System.out.println(checkPlain+" , "+reverseCheckPlain.reverse()+" , "+reverseCheckPlain.equals(checkPlain)+" , "+checkPlain)  ;
                if(reverseCheckPlain.toString().equals(checkPlain.toString())){
                    System.out.println(checkPlain);
                    System.exit(0);
                }
            }
        }
    }
}

I have noticed two interesting points here:

                                1. StringBuffer's when trying to equate using equals() method don't not give you expected result, be careful with respect to this.


                                2. StringBuffer's will give you two address to one value you when you use, instantiation as the creation of the object.

The output of the program when the commented code is executed (for point numbered 2 in above list):

D:\MyPrograms\Standalones>java Palindrome3D
Plaindrome of 3 digit multiple!
9801 , 1089 , true , 1089
1089

As you can see the statement:

System.out.println(checkPlain+" , "+reverseCheckPlain.reverse()+" , "+reverseCheckPlain.equals(checkPlain)+" , "+checkPlain)  ;

Gives

9801 , 1089 , true , 1089

The output of the program when the commented code is executed (for point numbered 1 in above list):

D:\MyPrograms\Standalones>java Palindrome3D
Plaindrome of 3 digit multiple!
9009 , 9009 , false , 9009
1089
As you can see the statement:

if(reverseCheckPlain.equals(checkPlain))

Gives


9009 , 9009 , false , 9009

Minute fact, but very interesting.


Tuesday, July 5, 2011


Multithread Testing Challenges in Java


Christian at the Carbon Five Community recently published an interesting blog article on Multithreaded Testing. Christian showed how to use Java 5 built-in concurrency features to create a nice, clean multithreaded test for an article dispatcher. It’s a good example of using the Java concurrency features, but I wondered about the effectiveness of the test.

The implementation of Article class was not thread safe. This was acceptable because of the assumption that the ORM library would be creating the Article instances in the requestor’s thread. However, those types of assumptions can be dangerous over the long term. Let’s pretend that the performance of the ArticleService was not good and a developer was given the task to increase its performance. To simulate this scenario, I created an implementation of the ArticleService that stored Article instances in memory (as if they were cached or if a framework like Terracotta were being used). The Article class should be thread safe for this implementation, but it wasn’t modified. We hope the test case will fail with the incorrect code. However, the test succeeded almost every time on my dual core workstation. Why was that?

The primary reason the test passed was that it was too fast. Christian warns us about the slow speed of his testing technique, but the technique is not slow. The original code being tested accessed a relational database so it was slow for that reason, not because of the testing technique. With my ArticleService implementation, the test executed in 15-30 milliseconds. My theory is that the short execution time results is what caused the test to pass almost every time. The Hotspot JIT is probably not able to compile and reorder instructions and it’s possible the threads all ran on the same CPU core. When the test did fail it seemed to be when the machine was under a little more load and the execution time was 40 ms or greater. In another experiment, I increased the size of the Article collection to 250 to 2500 and the test failed every time. For a test like this, it might be useful to measure the execute time in the test and signal an error if it runs too fast. Of course, if we didn’t know the test effectiveness was a function of execution speed we’d never think of adding the timing check.

In general, we should be very skeptical about multithread test cases. Just because they pass doesn’t necessarily mean our code is correct. A nondeterministic test that passes 99% of the time will give us false confidence. How can we be sure that our test is worthy of our confidence? Other than advanced tools like ConTest or code reviews by engineers who are experts in the Java Memory Model and multithreading, I’m not sure. It’s a difficult problem with no easy answers.