<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Microsonic Development &#187; Java</title>
	<atom:link href="http://microsonic.org/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://microsonic.org</link>
	<description></description>
	<lastBuildDate>Mon, 12 Jul 2010 01:55:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Importance of Structure and Coding Etiquette</title>
		<link>http://microsonic.org/2009/08/07/importance-of-structure-and-coding-etiquette/</link>
		<comments>http://microsonic.org/2009/08/07/importance-of-structure-and-coding-etiquette/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 16:11:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Other]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[etiquette]]></category>
		<category><![CDATA[how]]></category>
		<category><![CDATA[professional]]></category>
		<category><![CDATA[professionalism]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[structure]]></category>
		<category><![CDATA[to]]></category>

		<guid isPermaLink="false">http://microsonic.org/?p=185</guid>
		<description><![CDATA[Well, it&#8217;s been a very long time since I last updated and I&#8217;d like to apologize to all my subscribers for that. I&#8217;ve been very busy, but it seems the work load is going down and I&#8217;ll have more time to continue writing! Now, on with the article. So recently, I have just finished a [...]]]></description>
			<content:encoded><![CDATA[<p>Well, it&#8217;s been a very long time since I last updated and I&#8217;d like to apologize to all my subscribers for that. I&#8217;ve been very busy, but it seems the work load is going down and I&#8217;ll have more time to continue writing! Now, on with the article.</p>
<p>So recently, I have just finished a project where one developer had started and then decided he could not finish the work, so I was hired to finish it. The natural thought to one who is inexperienced is, &#8220;This will be a cakewalk. Most of the programming is already done!&#8221; &#8211; wrong. The first thing that went through my mind was, &#8220;I wonder how bad this really is.&#8221; So, I accept the project (as I had only a few projects at the time) and take a look.</p>
<p>The code was atrocious to say the least. I felt as if this other developer had never learned how to use comments or his tab key/space bar to format. Most of the time on the project was bent around figuring out what the original developer had tried to do. It was a nightmare.</p>
<p>As I started digging through files and files of unnecessary sloppy code, I thought to myself, &#8220;I need to write something about this. This kind of work needs to stop.&#8221; I was not upset because of the amateur programming, nor the fact that it was undocumented and poorly written. What bugs me is the fact that someone paid for that kind of work. It looked like the developer copy/pasted everything from snippets he or she found online. That being said, one must learn the importance of structure and coding etiquette. </p>
<p>Structure is important for general organization. It keeps code neat and clean looking and much easier for anyone, to include yourself, to go back and fix errors/security holes. Most people see structural formatting as a simple aesthetic quality when in reality it is like formatting a letter. The structure keeps things organized and understandable on a more universal level.</p>
<p>Coding etiquette, on the other hand, is something learned over a long period of time. No new developer can simply logon and expect to program to the standards set right now, but at the same time should begin mimicking the styles of major developers. Examining the work of others is one of the best ways for any developer to learn, so studying (yes, just like in school) the work of past developers, and prominent works of today, one can easily understand how to program professionally. A simple example would be to write functions rather than hardcode functions multiple times. Or rather than using raw MySQL functions, create an SQL wrapper to execute the functions.</p>
<p>There are many resources on learning how to program professionally, and be neat, but it&#8217;s up to developers to use the tools. The vast majority of developers, I would say, hold to the standards. However, for those who do not, they are just ripping off their client in the long-run.</p>
<p>Regards,<br />
Dennis M.</p>
]]></content:encoded>
			<wfw:commentRss>http://microsonic.org/2009/08/07/importance-of-structure-and-coding-etiquette/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Importance of a Portfolio</title>
		<link>http://microsonic.org/2009/06/10/importance-of-a-portfolio/</link>
		<comments>http://microsonic.org/2009/06/10/importance-of-a-portfolio/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 22:59:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[designers]]></category>
		<category><![CDATA[freelancers]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[portfolio]]></category>
		<category><![CDATA[programmers]]></category>
		<category><![CDATA[sellers]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[webmasters]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://microsonic.org/?p=173</guid>
		<description><![CDATA[Portfolio. The word sometimes lingers in one&#8217;s mind, but usually is associated with artwork, or a collection of works from your high school English class. But really, an online portfolio (whether it&#8217;s only artwork/graphics or programming) is very important when trying to find interested clients. Generally, most people can only establish their names by doing [...]]]></description>
			<content:encoded><![CDATA[<p>Portfolio. The word sometimes lingers in one&#8217;s mind, but usually is associated with artwork, or a collection of works from your high school English class. But really, an online portfolio (whether it&#8217;s only artwork/graphics or programming) is very important when trying to find interested clients.</p>
<p>Generally, most people can only establish their names by doing quality work at a great price (or in a few cases, great work and advertising at a high price pays off too &#8211; but those are the few giants of the web today). Word of mouth is good, but when you have a website, you should be showing off more than that to your potential clients. When a client visits your site (no matter which way &#8211; browsing, by accident, referal, etc.) their first opinion is your site itself. From there, they are looking for a giant link or button that says &#8220;Portfolio.&#8221;</p>
<p>When the user goes to this link, they don&#8217;t want to see just links, but they want a thumbnail shot of what to expect, a link to a working example, and a description of the purpose of the work. Now I know I do not have all of those things right now (just yet, anyway), but they are well worth it. Since most users see other works I&#8217;ve done (and after speaking to me on MSN) they are always satisfied with what I have to offer, but I am working on my designing skills and a portfolio script which I shall be launching very soon so I can practice what I preach.</p>
<p>So now that everyone understands that a portfolio should be more than just a collection of works you done, everyone can start really presenting themselves effectively. Like I said, soon I will be finishing my portfolio script and perhaps releasing it to the public, so if you are unsure about how to get yours started, that may be a great starting point for you!</p>
<p>Regards,<br />
Dennis M.</p>
]]></content:encoded>
			<wfw:commentRss>http://microsonic.org/2009/06/10/importance-of-a-portfolio/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The For(); Loop</title>
		<link>http://microsonic.org/2009/05/13/the-for-loop/</link>
		<comments>http://microsonic.org/2009/05/13/the-for-loop/#comments</comments>
		<pubDate>Thu, 14 May 2009 02:54:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Other]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cplusplus]]></category>
		<category><![CDATA[for]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://microsonic.org/?p=148</guid>
		<description><![CDATA[Many new programmers are perplexed by the &#8220;for&#8221; loop. However, it is one of the most essential and powerful tools in any developer&#8217;s arsenal. Without it, efficient and clean programming would not be as possible. Early on, most developers seem to stick to the while(); loop. I mean sure, while(); is great for some things, [...]]]></description>
			<content:encoded><![CDATA[<p>Many new programmers are perplexed by the &#8220;for&#8221; loop. However, it is one of the most essential and powerful tools in any developer&#8217;s arsenal. Without it, efficient and clean programming would not be as possible. Early on, most developers seem to stick to the while(); loop. I mean sure, while(); is great for some things, but may not exist in some programming languages and not to mention won&#8217;t work for everything you need.</p>
<p>Let&#8217;s begin by going into the basics about the for(); loop. Well really, a lot depends on the programming language (I will provide both PHP and C++ examples in the source file). But more or less, the for(); loop is simply iteration. It will run until its defined limit is hit providing whatever results you wish. We&#8217;re going to do this in more standard languages (e.g.: C/C++ and Java) instead of PHP for mass compatibility. Just note, if you&#8217;re looking to do this for php, you do not need to define the type of variable, and your variable will just start with the &#8220;$&#8221; symbol. So for example, PHP would be for($i=0;&#8230;;&#8230;){}. </p>
<p>Now we&#8217;re going to write a sample program and break it down:</p>
<blockquote><p><code>for(int i=0;i&lt;=5;i++){<br />
  std::cout&lt;&lt; "This is line number "&lt;&lt; i &lt;&lt; std::endl;<br />
}</code></p></blockquote>
<p>Now as most of you may have noticed, this is a C++ example, but will effectively explain how the loop works for ALL programming languages!</p>
<p><strong>int i=0;</strong> &#8211; This simply defines the variable and starting place (0 in this case). In PHP you would simply use $i=0; and so on for the rest of the statements.<br />
<strong>i<=5</strong> &#8211; This tells the loop when to stop (This <em><=</em> symbol means less than or equal to). When i>5, the loop will stop and proceed on to the rest of the code.<br />
<strong>i++</strong> &#8211; This tells what the loop should do after every time it is run. In this case, we&#8217;re using i++ which means to add 1 each time around.</p>
<p>Now those are the basics to the loop. What lies within is just simply the code to be executed, which could of course have conditionals and such within it as well (e.g.: if(), etc.). So now we&#8217;ll move on to a more complex example.</p>
<blockquote><p><code>unsigned int choices=5;<br />
char* choice = new char[choices];<br />
for(int i=0;i&lt;=choices;i++){<br />
  std::cout&lt;&lt;"Please enter a value: ";<br />
  std::cin&gt;&gt;choice[i];</p>
<p>  if(!choice[i]){<br />
    std::cout&lt;&lt;"No value for choice "&lt;&lt; i&lt;&lt; std::endl;<br />
  }<br />
}<br />
for(int i=0;i&lt;=choices;i++){<br />
  std::cout&lt;&lt;"Choice "&lt;&lt; i&lt;&lt;" was "&lt;&lt; choice[i] &lt;&lt; std::endl;<br />
}</code></p></blockquote>
<p>This will store an array of choices and then after entering them, they will be printed back!</p>
<p>In the source below, all working examples will be provided!<br />
<a href='http://microsonic.org/2009/05/13/the-for-loop/for_loop-tutorialtar/' rel='attachment wp-att-149'>For(); Loop Tutorial</a></p>
<p>So, that basically wraps everything up! If you need anymore clarification, just let me know.</p>
<p>Regards,<br />
Dennis M.</p>
]]></content:encoded>
			<wfw:commentRss>http://microsonic.org/2009/05/13/the-for-loop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Java Web Applet</title>
		<link>http://microsonic.org/2009/04/20/creating-a-java-web-applet/</link>
		<comments>http://microsonic.org/2009/04/20/creating-a-java-web-applet/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 01:37:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[applet]]></category>
		<category><![CDATA[archive]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[jar]]></category>
		<category><![CDATA[jarsigner]]></category>
		<category><![CDATA[javac]]></category>

		<guid isPermaLink="false">http://microsonic.org/?p=104</guid>
		<description><![CDATA[Today&#8217;s topic of discussion is Java. Ah yes, the programming language that sounds so familiar (and brings up feelings of dread) among high school programming students. There is no doubt that the language is very delicate, and in many ways very similar (yet different) than C++. But the steps to creating a program and the [...]]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s topic of discussion is Java. Ah yes, the programming language that sounds so familiar (and brings up feelings of dread) among high school programming students. There is no doubt that the language is very delicate, and in many ways very similar (yet different) than C++. But the steps to creating a program and the steps to creating a web are sometimes different.</p>
<p>Now, writing a Java applet is more or less the same as any other Java program; I will include examples later. But how should one go about packaging the applet? Packaging: the key word &#8211; no? In an applet, each class must be part of the package. We will go into depth on this later, but it&#8217;s important to keep in mind. Also, sometimes users just use the .class file, but this is not always the best for all programs. If you have many classes, you may wish to create a <em>.jar </em>archive which can load all of your files. So in this tutorial, we&#8217;ll explain all that as well as signing your jar file.</p>
<p>So let&#8217;s begin with a simple example. In fact, the most simple and infamous example known to man in all languages: the &#8220;Hello World.&#8221;</p>
<p><strong>HelloWorld.java</strong></p>
<pre>
/**
 * HelloWorld.java by Dennis M.
 *
 * Simple tutorial! <img src='http://microsonic.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
 *
 */

// Import all necessary files
import java.applet.*;
import java.awt.*;

// Start with our class
public class HelloWorld extends Applet {
  public void init(){
    // Just begins the program
  }
  public void stop(){
    // Stop the program when page is left or browser
    // closed
  }
  // Allowed to do this because of AWT library
  public void paint(Graphics g){
    g.drawString("Hello World!",20,20);
    g.drawString("Your name is: "+getParameter("YourName"),20,40);
  }
}
</pre>
<p>That code using this applet code:</p>
<pre><code>&lt;applet code="HelloWorld.class"&gt;
&lt;param name="YourName" value="John Doe" /&gt;
You must have java enabled to see this text!
&lt;/applet&gt;</code></pre>
<p>Now notice, I&#8217;ve left the code in just &#8220;class&#8221; form. Since we only have one class file, there is no real reason to compile file into a jar. This next example will be slightly more complex. We will have a few class files so we&#8217;ll archive it and sign the jar. Although signing the jar may not be absolutely necessary in this case (because we&#8217;re not requesting access to the user&#8217;s computer), it may be a necessary skill you&#8217;ll need later on. For instance, I just finished a project working on a simple Java Uploader script; I needed to archive it and sign it. If it was not signed, it could not access the user&#8217;s files to upload!</p>
<p><strong>test/testmain.java</strong></p>
<pre>/**
 * Simple Test Java Applet by Dennis M.
 *
 */
// Package should go according to structure!
package test;

// Imports
import java.applet.*;
import java.awt.*;
import test.dir1.test1; // We can import this because of "package"
			// and our structure!

public class testmain extends Applet{
  // Declare vars
  test1 test = new test1();

  // Start and stop functions.
  public void init(){
    System.out.println("init();");
  }
  public void stop(){
    System.out.println("stop();");
  }

  // Draw some text again
  public void paint(Graphics g){
    // This function included in dir1.test1
    if(test.randomTest() != 1){
      g.drawString("Did not load correctly!",20,20);
      System.out.println("Doh! bad load <img src='http://microsonic.org/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> ");
    } else {
      // Let's continue to give the params and values! <img src='http://microsonic.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
      g.drawString("Name:  "+getParameter("name"),20,20);
      g.drawString("Email: "+getParameter("email"),20,40);
      g.drawString("Sex:   "+getParameter("sex"),20,60);
      System.out.println("Success! <img src='http://microsonic.org/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> ");
    }
  }
}
</pre>
<p><strong>test/dir1/test1.java</strong></p>
<pre>/**
 * Simple Java Applet by Dennis M.
 *
 */
// Remember.. STRUCTURE STRUCTURE STRUCTURE!
package test.dir1;

public class test1{
  public int randomTest(){
    System.out.println("Successfully called to external file!");
    return 1;
  }
}</pre>
<p><strong>ArchivedApp.html</strong></p>
<pre><code>&lt;applet code="test.testmain" archive="bin/archivedapp.jar"&gt;
You must have a java-enabled browser to view this!
&lt;/applet&gt;</code></pre>
<p><em>Notice:</em> In this particular applet, since we are loading from an archive, the code base is the name of the first file. The code should always go: package.Mainfile_name. Now if you&#8217;re main file happens to be like &#8220;package test1.test2,&#8221; then you simply adjust the code line to &#8220;test1.test2.Mainfile_name&#8221;</p>
<p>To compile the code use the following command (in the src/test directory)</p>
<pre>javac testmain.java dir1/test1.java -d ../../bin</pre>
<p>Now that we have it compiled, go to the &#8220;bin&#8221; directory. In here run the following command to generate a key:</p>
<pre>keytool -genkey -keystore keystore -dname "CN=Default,OU=Default, O=Default, L=Default, ST=Illinois, C=US"</pre>
<p>Use password: <em>default</em></p>
<p>Now, to sign the jar file use this:</p>
<pre>jarsigner -keystore keystore archivedapp.jar mykey</pre>
<p>Enter the password you used earlier for the <em>mykey</em> certificate in the keystore. Your jar file has been successfully signed!</p>
<p>As usual, everything is in the archive below for you to download! All compiled classes/jars and sources are included. Enjoy!<br />
<a href='http://microsonic.org/2009/04/20/creating-a-java-web-applet/java_applet_tutorialtar/' rel='attachment wp-att-108'>Creating a Java Web Applet Tutorial Files</a></p>
<p>Regards,<br />
Dennis M.</p>
]]></content:encoded>
			<wfw:commentRss>http://microsonic.org/2009/04/20/creating-a-java-web-applet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
