Friday, July 26, 2013

Avoiding Mistakes in Java

The only people who never make mistakes are the people who never do anything at all. But careful planning can help you avoid some of the most common Java goofs, such as the following.

Putting capital letters where they belong

Java is a case-sensitive language, so you really have to mind your Ps and Qs — along with every other letter of the alphabet. Here are some things to keep in mind as you create Java programs:
·                   Java's keywords are all completely lowercase. For instance, in a Java if statement, the word ifcan't be If or IF.
·                   When you use names from the Java API (Application Programming Interface), the case of the names has to match what appears in the API.
·                   You also need to make sure that the names you make up yourself are capitalized the same way throughout your entire program. If you declare a myAccount variable, you can't refer to it as MyAccount, myaccount, or Myaccount. If you capitalize the variable name two different ways, Java thinks you're referring to two completely different variables.

Breaking out of a switch statement

If you don't break out of a switch statement, you get fall-through. For instance, if the value of verse is 3, the following code prints all three lines — Last refrain, He's a pain, and Has no brain.
switch (verse) {
case 3:
out.print("Last refrain, ");
out.println("last refrain,");
case 2:
out.print("He's a pain, ");
out.println("he's a pain,");
case 1:
out.print("Has no brain, ");
out.println("has no brain,");
}

Comparing values with a double equal sign

When you compare two values with one another, you use a double equal sign. The line
if (inputNumber == randomNumber)
is correct, but the line
if (inputNumber = randomNumber)
is not correct.

Adding components to a GUI

Here's a constructor for a Java frame:
public SimpleFrame() {
JButton button = new JButton("Thank you...");
setTitle("...Katie Feltman and Heidi Unger");
setLayout(new FlowLayout());
add(button);
button.addActionListener(this);
setSize(300, 100);
setVisible(true);
}
Whatever you do, don't forget the call to the add method. Without this call, you go to all the work of creating a button, but the button doesn't show up on your frame.

Adding listeners to handle events

Look again at the previous section's code to construct a SimpleFrame. If you forget the call to addActionListener, nothing happens when you click the button. Clicking the button harder a second time doesn't help.

Defining the required constructors

When you define a constructor with parameters, as in
public Temperature(double number)
then the computer no longer creates a default parameterless constructor for you. In other words, you can no longer call
Temperature roomTemp = new Temperature();
unless you explicitly define your own parameterless Temperature constructor.

Fixing non-static references

If you try to compile the following code, you get an error message:
class WillNotWork {
String greeting = "Hello";
public static void main(String args[]) {
System.out.println(greeting);
}
}
You get an error message because main is static, but greeting isn't static.

Staying within bounds in an array

When you declare an array with ten components, the components have indices 0 through 9. In other words, if you declare
int guests[] = new int[10];
then you can refer to the guests array's components by writing guests[0], guests[1], and so on, all the way up to guests[9]. You can't write guests[10], because the guests array has no component with index 10.

Anticipating null pointers

In real-life Java programming, you see that exception all the time. A NullPointerException comes about when you call a method that's supposed to return an object, but instead the method returns nothing. Here's a cheap example:
import static java.lang.System.out;
import java.io.File;
class ListMyFiles {
public static void main(String args[]) {
File myFile = new File("\\windows");
String dir[] = myFile.list();
for (String fileName : dir) {
out.println(fileName);
}
}
}
This program displays a list of all the files in the windows directory.
But what happens if you change \\windows to something else — something that doesn't represent the name of a directory?
File myFile = new File("#*%$!!");
Then the new File call returns null (a special Java word meaning nothing), so the variable myFile has nothing in it. Later in the code, the variable dir refers to nothing, and the attempt to loop through all the dir values fails miserably. You get a big NullPointerException, and the program comes crashing down around you.
To avoid this kind of calamity, check Java's API documentation. If you're calling a method that can return null, add exception-handling code to your program.

Helping Java find its files

You're compiling Java code, minding your own business, when the computer gives you a NoClassDefFoundError. All kinds of things can be going wrong, but chances are that the computer can't find a particular Java file. To fix this, you must align all the planets correctly.
·                   Your project directory has to contain all the Java files whose names are used in your code.
·                   If you use named packages, your project directory has to have appropriately named subdirectories.
·                   Your CLASSPATH must be set properly.


Monday, July 22, 2013

The Ten Most Common C++ Mistakes

Although many C++ programmers take measures to prevent bugs, mistakes still slip through. This list of the ten most common mistakes while writing C++ code can help both new and veteran programmers:
  1. You forgot to declare the variable.
  2. You used the wrong uppercase and lowercase letters; for example, you typed Main when you meant main.
  3. You used one equal sign (=) when you were supposed to use two (==), either in an ifstatement or in a for loop.
  4. You forgot #include  or using namespace std;.
  5. You dropped the laptop in the swimming pool.
  6. You forgot to call new and just started using the pointer anyway.
  7. You forgot the word public: in your classes so everything turned up private.
  8. You let the dog eat the remote.
  9. You forgot to type the parentheses when calling a function that takes no parameters.
  10. You forgot a semicolon, probably at the end of a class declaration.

Wednesday, July 17, 2013

Preparing a videoconference: Five important steps


How good are you at running a webinar or videoconference?  Has your training prepared you for this rapidly growing aspect of business and teaching? Does your preparation include you?
Everyone is doing it!  Businesses, teachers of all kinds, doctors, those in the arts, sciences, business and medicine are communicating more and more via some kind of Internet or video conferencing.  If you are one of these people, how much time do you devote to personal preparation not including the notes and slides? Preparing your written materials is only the beginning. If you are good at presentation, you will need to be even better in the video situation.  If you presentation is wordy, highly technical, mediocre or dull, you run the risk of being exceptionally boring in this situation. What can you do to improve?
Your energy is what leads and holds the group’s attention. Therefore your preparation and how you conduct yourself is vitally important—and often neglected by devoting excess attention to the text and slides.

Ask yourself the following questions:
§                     Do you want to be perceived as a leader?
§                     Do you command authority?
§                     Do you want effective group participation?
Preparation is everything.  So say all the experts.  How do you prepare?  Almost everyone spends a huge percentage of their preparation time on ideas, text, deliverables, and visual materials.  However, even the best ideas can fall flat when the presenter has not prepared himself. No sports person walks out for a match without out a complete set of skills that include physical and mental techniques.  Too many presenters are satisfied with only working with the intellectual aspects of the material and forget that they themselves are the critical catalyst for conveying the message.  Here are five easy steps to include in your preparation that take you less than 30 seconds to achieve.
One: Ground yourself
The simple act of grounding yourself can change your voice, your feeling of confidence and the perception others have of you.  It is easy to do.
1.  Make sure your feet are solidly on the floor with the toes pointed straight ahead.  Martial artists have long known that your energy is strong with toes pointing forward and weak with toes turned out.  Don’t begin a meeting with weak energy.
2.  As you are likely to be sitting, make sure your tailbone is pointing straight down to the floor and that an imaginary line from the middle of the upper back is pointing straight up to the ceiling.  There is nothing rigid about this; it is a matter of balance and alignment.  It is very important as to how you are perceived and how centered you feel within yourself.  When there is fear or anxiety, the first thing that happens is we lose grounding and it is perceptible. You want to look and sound dynamic and responsive.
Two: Center yourself with breath
It is surprising how many people actually hold their breath when thinking, or when giving a presentation.  While you are grounding, include this breathing exercise as part of your preparation. It is not necessary to take a big or audible breath.  This can be your secret.
1.  Think of a loop of breath that goes around the back and front of your spinal cord.
2.  Imagine you are breathing in from the bottom of the back of your spine to the top of your head.
3.  Imagine you are breathing out from the top of your head down the front of your spine to the tailbone.
4.  Do this three times or any time you feel the need to center.
Three: Pull yourself together and be present
It is all too easy to think that because you are not giving a formal presentation that you can be a bit lax and come across as too casual.  Make sure you are alert, aware, and energetic.
The feeling of being “together” is more energising than constantly reminding yourself to relax.  The common perceptions of relaxing tend to be more akin to collapsing.  The first two exercises will help you feel together and cantered.  However, sometimes we are thinking of many things at once before a meeting and it scatters our focus. Consciously see yourself as together and ready for the meeting. Do this before you log on or before participants arrive. When you are in a state of readiness, the participants will sense this and will begin to do the same. Most importantly, you have to want to be there; your group/audience knows when your mind is not there.
Four:  Focus on the outcome(s) you and your group want
1.  What is the one thing you want to achieve?
2.  Ask the same of each member in attendance. In the case of a large group, you can solicit this answer by email before the session.
 Focussing, visualising, and imagining yourself in the situation with positive outcomes are vital to any public appearance.  Good performers, from athletes to actors know the importance of this. Interestingly, your brain does not know the difference between your imagination and reality.  Knowing that body and mind respond to thoughts and visualisations makes it vital that you choose appropriate, positive visualisation and thoughts.  Avoid contaminating your meeting with negative energy.
Five:  Warmly greet each person who attends as if they were entering your home
A friendly acknowledgement of each person will make him or her feel welcome and ready to participate. No matter what the purpose of conference, a meeting that begins with a positive energy will accomplish more and create eager participants.
Summary: Enjoy the process (If you don’t, neither will anyone else)
When you are aware, grounded, centered and focused, the quality and authority of your voice and presence will become part of a coherent image of a leader. The result will be a meeting that has the necessary positive energy to achieve your goals. All parts of a presentation are important, the ideas, materials and especially you.  It is delivered through you and you owe it to yourself and the participants to be the best you can be in front of your audience.  Never allow the conference/meeting/workshop to become a chore!
While this article has been directed toward video presentations, it is equally important to include the five steps anytime you are in front of an audience.

Sunday, July 14, 2013

How to Study in Six Simple Steps




Space

Make room, mentally and physically, for studying. Usually you’re studying for something specific, such as an exam. This can seem daunting, like a mountain to climb. If this sounds familiar, take a deep breath and pause for a moment before you start.
Think of how you make yourself comfortable when you do something you really enjoy, like watching a favorite television program. How do you settle in for the show? Do you sprawl or curl up? Do you have favourite relaxing clothes? Do you choose a particular drink or something to nibble? Borrow all these favorite things to make your studying a better experience. If you’re in a good space physically, you can improve your mental space.

Place

Create your own personal work zone. It doesn’t have to look like a work-space — that’s what many students find off-putting. Building on what you did in the previous paragraph, make the place your own and somewhere you enjoy.

Pace

Find the right pace for your work. Sprinters work hard and fast in a burst of energy while marathon runners spread the load and build slowly towards the climax. There’s no right or wrong way to pace your studying, except what works for you. Notice the way you like to work, and adjust your pace accordingly. (Just remember, if you study at a slow pace, you'll need to set aside more time for the task.)
Whether you have bags of time or a brief study period, remember that breaks are just as important as active study (10 minutes off for every 30 minutes of study works for many people), and use those breaks to reward yourself with a small treat.

Memory

It helps to know how your memory works. Here is the key to memory: in any sequence, people remember the first and last things best. Whatever you try to remember, you’ll find yourself recalling the beginning and the end, with less clear memories of the middle. You can’t change this — it’s wired in, it's how our brains work — so don’t fight it. Instead, use this fact to your advantage by organizing your study so the most important bits are at the beginning and end of your sessions.

Method

It’s always good to have a plan. However big or complex your task may look at first sight, with a feasible plan you can always find a way to manage it.
When studying, break your biggest goal into smaller chunks or tasks. It’s best if each of these chunks consists of a single topic. Often, you’ll discover one or two key elements that stand out and get fixed in your mind. You can then use those as building blocks.
Classic tricks used by memory professionals include ‘the house of memory’ where you place everything you want to remember in unique locations in the house. It’s also useful to use humor — play with your key-words and make them funny or outrageous. You’ll be surprised at how much easier they are to memorize.

Mind maps

A mind map is rough diagram that you can make to visually outline information. You can create a mind map by starting with the primary word or phrase of a topic in the center, with related, lesser categories branching out from it. Subcategories of these are on smaller branches, still. Your categories can consist of anything you think is important; they can be important terms, ideas, or tasks to complete — whatever you need to help you study or organize the information.
Mind maps are easy to master if you don’t use them already, and you’ll discover they help you remember masses of information much more efficiently than conventional lists. If you're not satisfied with your current note-taking skills, try building a mind map during your next class or lecture and see if you find it more helpful.

Readmore :http://www.dummies.com/how-to/content/how-to-study-in-six-simple-steps.pageCd-storyboard,pageNum-7.html#slideshow

Wednesday, July 10, 2013

Parents of children as young as six admit they don't monitor their child's phone use because they don't want to 'invade their privacy'

Parents of children as young as six fail to keep tabs on their mobile phone use for fear of 'invading their privacy', according to a new survey.
Almost 60 per cent of mothers and fathers questioned said they did not monitor their child's mobile phone activity. 
Of those, one in four said they chose not to check in order to respect their infant's privacy.
The majority of parents - 42 per cent - said they never got around to checking what their youngsters were using their phones for, while 13 per cent said they trusted their child with the device.
Over 2,000 parents of children aged 10 or younger who owned a mobile phone were questioned for the survey, which was carried out by mobileinsurance.co.uk.
The survey revealed there are children as young as six in possession of a mobile phone.
Nearly 80 per cent of parents whose child had a phone with a lock or pass-code on it admitted they would not know how to access it.
This is despite the fact that children could be using their smartphone to access the internet.
The firm behind the survey urged parents to ensure their child's access to online content was suitably restricted.
According to website director Jason Brockman, mothers and fathers should monitor children's mobile phone use as a means of 'keeping them safe'.

Parents must to more to ensure their children 'aren't talking to strangers or being bullied' via their smartphones, he said.

It's not a case of invading their privacy, but it should be seen as a way of keeping them safe,' he said.
'Parents should make sure that, if their children have access to the internet on their phones, adult content and websites are restricted, and it's also important to make sure they aren't talking to strangers or being bullied. 
He said it was 'pretty shocking' that children as young as six should have their own mobile phone.


Read more: http://www.dailymail.co.uk/news/article-2359249/Parents-admit-dont-monitor-childs-phone-use-dont-want-invade-privacy.html#ixzz2YeLycjQC

LinkWithin

Related Posts with Thumbnails