<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-693951085906924382</id><updated>2008-10-16T08:19:28.416-04:00</updated><title type='text'>Mike D's Weblog</title><subtitle type='html'>Random Blurbs and Tutorials in development and business knowledge.</subtitle><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/693951085906924382/posts/default'/><link rel='alternate' type='text/html' href='http://www.michaelduvall.com/'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.michaelduvall.com/atom.xml'/><author><name>Michael Duvall</name><uri>http://www.blogger.com/profile/17353796491441756483</uri><email>michaelpduvall@gmail.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-693951085906924382.post-1515651136081019054</id><published>2008-09-08T15:45:00.022-04:00</published><updated>2008-10-16T08:19:28.439-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Patterns'/><title type='text'>Unwrapping the Decorator Pattern with Java</title><content type='html'>&lt;p&gt;&lt;strong&gt;Abstract &lt;/strong&gt;&lt;/p&gt;The following document purposes an object oriented design solution that can be applied to many common business scenarios. In this brief paper I describe how to implement the decorator design pattern using the Java Programming language. I will go over the main problems of using too many subclasses, provide the user with Unified Modeling Language (UML) diagrams to visually represent an application, provide the reader with a small application illustrating the decorator pattern and finally provide the reader with the pros and cons of using the decorator pattern. This document infers that the reader has a basic understanding of UML and how to use an object oriented programming language. While this paper uses Java for reader simplicity, the user can apply the Decorator pattern methodology to most object oriented scripting and programming languages such as C# and PHP. In addition I will provide definitions of the common object oriented programming terms presented in this document.&lt;p&gt;&lt;/p&gt;&lt;span style="font-weight: bold;"&gt;  Purpose&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In this brief tutorial I will attempt to solve a very common application development dilemma using a generic real world scenario; With this knowledge the developer will add a tidbit of knowledge to their "Mental Tool Kit" . In addition I will provide a few resources in which the programmer will be able to seek out other design pattern knowledge.&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Defined &lt;/strong&gt;&lt;/p&gt;In (Gamma, Helm, Johnson, &amp;amp; Vlissides, 1997) the decorator is defined as "Attach[ing] additional responsibilities to an object dynamically. Decorators provide a flexible alternative to sub classing for extending functionality". So what does this mean in basic programming terms? Fundamentally it means that we are going to "wrap" or "decorate" objects with other objects to produce the behavior we are looking for. It also provides us with a solution to a common subclassing nightmare that many programmers decide to use, inadvertently.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.michaelduvall.com/uploaded_images/objectsBeingWrapped-793775.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://www.michaelduvall.com/uploaded_images/objectsBeingWrapped-793772.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Figure 1&lt;/span&gt; Object Wrapping in this situation the objects call the methods of the wrapping objects to add to our final output.&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Scenario&lt;/strong&gt;&lt;/p&gt;You have a client that specializes in selling burgers. The client is relatively new in the market and his business is growing at an exponential rate. The client needs a program that is flexible enough to handle various sandwich combinations and adapt to there every changing needs. The current software that the client uses does not account for the new sandwich combinations they plan to introduce.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;The first programmer assigned to this task used basic programming techniques to give the client exactly what they needed- at the time. After looking at the source code you find that it is full of subclasses, all of which are extending the main class's methods and properties. You also find it very hard to make any changes to the program because there are just too many dependent relationships in the code, i.e. if you change something here..., it will break something else in the program. What do you do? Do you spend hours trying to figure out the huge programming "spaghetti" code or do you re-write the code and make it more developer friendly? In each case you may find yourself spending just as much time to produce the results you need. But if you decide to utilize the decorator pattern and refactor the code, the next time the client needs changes your time will be more wisely spent. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.michaelduvall.com/uploaded_images/SandwhichDiagramUMLSubclasses-797200.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://www.michaelduvall.com/uploaded_images/SandwhichDiagramUMLSubclasses-797191.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Figure 2a&lt;/span&gt; Subclass overload; each time we create another subclass we have to continually change the description of the sandwich name and price.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.michaelduvall.com/uploaded_images/SandwhichDiagramUML-759767.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://www.michaelduvall.com/uploaded_images/SandwhichDiagramUML-759763.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Figure 2b&lt;/span&gt; The Decorator Pattern&lt;/p&gt;&lt;br /&gt;&lt;p&gt;In figures 2a and 2b we can see both of our options in UML diagrams. In figure 2a we have a subclassing overload nightmare which can quickly get out of control. In figure 2b we have a tidier program, utilizing the Decorator Design pattern; which becomes easier to manage when we add more sandwich types, price changes and condiments.&lt;/p&gt;Since we have many other clients and we enjoy becoming more productive and efficient at what we do. We have decided to use the Decorator pattern approach.&lt;br /&gt;&lt;p&gt;We can start our programming task by first creating a main abstract class defined below:&lt;/p&gt;&lt;br /&gt;&lt;div class="codeview"&gt;                  &lt;br /&gt;public abstract class Sandwich{&lt;br /&gt;&lt;br /&gt;                 String sandwichName = " Sandwich";&lt;br /&gt;&lt;br /&gt;           public abstract getSandwichName(){&lt;br /&gt;&lt;br /&gt;                   return sandwichName;&lt;br /&gt;&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           public abstract double price();&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;Next we extend the Sandwich class by creating an abstract decorator class below:&lt;/p&gt;&lt;br /&gt;&lt;div class="codeview"&gt;                  public abstract class SandwhichCondiment extends Sandwich{&lt;br /&gt;&lt;br /&gt;               public abstract String getSandwichName();&lt;br /&gt;&lt;br /&gt;}&lt;/div&gt;&lt;br /&gt;&lt;p&gt;Now lets create some concrete classes from the abstract SandwhichCondiment decorator:&lt;/p&gt;&lt;br /&gt;&lt;div class="codeview"&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);font-size:85%;"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;// lets add a slice of cheese&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;           public class Cheese extends SandwhichCondiment{&lt;br /&gt;&lt;br /&gt;          &lt;span style="color: rgb(0, 102, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);font-size:85%;"&gt;// this will take on the data type of the Sandwich main class&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;               Sandwich sandwich;&lt;br /&gt;&lt;br /&gt;           public Cheese (Sandwich sandwich){&lt;br /&gt;&lt;br /&gt;               this.sandwich = sandwich;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;          public String getSandwichName(){&lt;br /&gt;&lt;br /&gt;               return sandwich.getSandwichName() + "+ Cheese";&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;         public double price(){&lt;br /&gt;&lt;br /&gt;              return .15 + sandwich.price();&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;Our next concrete class to add some lettuce:&lt;/p&gt;&lt;br /&gt;&lt;div class="codeview"&gt;&lt;br /&gt;       public class Lettuce extends SandwhichCondiment{&lt;br /&gt;&lt;br /&gt;      &lt;span style="color: rgb(0, 153, 0);font-size:85%;"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;// this will take on the data type of the Sandwich main class&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;                  Sandwich sandwich;&lt;br /&gt;&lt;br /&gt;       public Lettuce (Sandwich sandwich){&lt;br /&gt;&lt;br /&gt;                  this.sandwich = sandwich;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;      &lt;span style="color: rgb(0, 102, 0);font-size:85%;"&gt; // this will add the name of the sandwich plus&lt;br /&gt;&lt;br /&gt;           // any elements we decide to use&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      public String getSandwichName(){&lt;br /&gt;&lt;br /&gt;           return sandwich.getSandwichName() + "+ Lettuce";&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;       &lt;span style="color: rgb(0, 102, 0);font-size:85%;"&gt;// lets add to the price dynamically&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       public double price(){&lt;br /&gt;&lt;br /&gt;       return .05 + sandwich.price();&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;Our next concrete class to add some Tomato:&lt;/p&gt;&lt;br /&gt;&lt;div class="codeview"&gt;&lt;br /&gt;&lt;br /&gt;public class Tomato extends SandwhichCondiment{&lt;br /&gt;&lt;br /&gt;           &lt;span style="color: rgb(0, 102, 0);font-size:85%;"&gt;// this will take on the data type of the Sandwich main class&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;           Sandwich sandwich;&lt;br /&gt;&lt;br /&gt;   public Tomato (Sandwich sandwich){&lt;br /&gt;&lt;br /&gt;           this.sandwich = sandwich;&lt;br /&gt;&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;   public String getSandwichName(){&lt;br /&gt;&lt;br /&gt;           return sandwich.getSandwichName() + "+ Tomato";&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;           &lt;span style="color: rgb(0, 102, 0);font-size:85%;"&gt;// lets add to the price dynamically&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;           public double price(){&lt;br /&gt;&lt;br /&gt;               return .05 + sandwich.price();&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;}&lt;/div&gt;&lt;br /&gt;&lt;p&gt;Our next concrete class to add some Pickle:&lt;/p&gt;&lt;br /&gt;&lt;div class="codeview"&gt;&lt;br /&gt;public class Pickle extends SandwhichCondiment{&lt;br /&gt;&lt;br /&gt;   &lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;// this will take on the data type of the Sandwich main class&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;               Sandwich sandwich;&lt;br /&gt;         public Pickle (Sandwich sandwich){&lt;br /&gt;&lt;br /&gt;              this.sandwich = sandwich;&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;      public String getSandwichName(){&lt;br /&gt;&lt;br /&gt;              return sandwich.getSandwichName() + "+ Pickle";&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;      &lt;span style="color: rgb(0, 102, 0);font-size:85%;"&gt; // lets add to the price dynamically&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       public double price(){&lt;br /&gt;               return .05 + sandwich.price();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;/div&gt;&lt;br /&gt;&lt;p&gt;As you can see, there is a basic pattern beginning to develop with the concrete classes, you can add as many as you need to satisfy your client’s needs without affecting the rest of the application.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Now we can add a couple of concrete classes to extend the Sandwich class’s properties and methods:&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The Burger Class:&lt;/span&gt;&lt;br /&gt;&lt;div class="codeview"&gt;&lt;br /&gt;       public class Burger extends Sandwich{&lt;br /&gt;&lt;br /&gt;                // constructor&lt;br /&gt;&lt;br /&gt;                   public Burger(){&lt;br /&gt;&lt;br /&gt;                       sandwichName ="Classic Burger";&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;                  public double price(){&lt;br /&gt;&lt;br /&gt;                       return 3.29;&lt;br /&gt;&lt;br /&gt;   }&lt;/div&gt;&lt;br /&gt;&lt;p style="font-weight: bold;"&gt;The Turkey Burger Class:&lt;br /&gt;&lt;/p&gt;&lt;div class="codeview"&gt;public class Turkey extends Sandwich{&lt;br /&gt;&lt;br /&gt;               // constructor&lt;br /&gt;&lt;br /&gt;               public Burger(){&lt;br /&gt;&lt;br /&gt;                      sandwichName ="Turkey Burger";&lt;br /&gt;&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;               public double price(){&lt;br /&gt;                   return 5.99;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;The Turkey and Burger classes are just the beginning, by using the Decorator Patterns approach we can successfully create as many different base sandwich types that we need without going through all the lines of code looking for cause and effect relationships e.g. if we decided to add a grilled chicken sandwich class we would merely have to give it a sandwichName value and price to utilize the toppings presented in our Decorator’s concrete classes.&lt;/p&gt;&lt;strong&gt;Testing our Application&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;To test the efficiency of the program we use a simple main class to display our results.&lt;br /&gt;&lt;div class="codeview"&gt;&lt;br /&gt;       public class testOurBugers {&lt;br /&gt;&lt;br /&gt;       public void static main (String args[]){&lt;br /&gt;&lt;br /&gt;       // instantiate a new burger object&lt;br /&gt;&lt;br /&gt;           Sandwich ourCreatedSandwich = new Burger();&lt;br /&gt;&lt;br /&gt;       //lets create a Classic burger with cheese, lettuce, tomato and pickle&lt;br /&gt;&lt;br /&gt;   ourCreatedSandwich = new Cheese(ourCreatedSandwich);&lt;br /&gt;&lt;br /&gt;   ourCreatedSandwich = new Lettuce(ourCreatedSandwich);&lt;br /&gt;&lt;br /&gt;   ourCreatedSandwich = new Tomato(ourCreatedSandwich);&lt;br /&gt;&lt;br /&gt;   ourCreatedSandwich = new Pickle(ourCreatedSandwich);&lt;br /&gt;&lt;br /&gt;   System.out.println(ourCreatedSandwich.getSandwichName() + "= $" +   ourCreatedSandwich.price();&lt;br /&gt;&lt;br /&gt;   //lets create a Turkey burger with lettuce and tomato.&lt;br /&gt;&lt;br /&gt;   Sandwich ourCreatedTurkeyBurger = new Turkey();&lt;br /&gt;&lt;br /&gt;   ourCreatedTurkeyBurger = new Lettuce(ourCreatedTurkeyBurger);&lt;br /&gt;&lt;br /&gt;   ourCreatedTurkeyBurger = new Tomato(ourCreatedTurkeyBurger);&lt;br /&gt;&lt;br /&gt;   System.out.println(ourCreatedTurkeyBurger.getSandwichName() + "= $" +   ourCreatedTurkeyBurger.price();&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;The output is just 2 different sandwich combinations out of several possible scenarios.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;How it Works&lt;/strong&gt;&lt;/p&gt;By instantiating a Turkey and a Burger object we are extending the attributes and methods from the Sandwich class. To make use of the SandwhichCondiment Class and decorate our objects we wrap them with any of the condiment concrete classes that we need on our burgers. With each new object instantiation we are essentially decorating the objects with another object see figure 1. This will allow us the opportunity to manipulate our objects at runtime, dynamically, by having each of the objects calling methods on each of wrapped objects we create.&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Pros and Cons&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;We have seen some of the pros and benefits of using the decorator pattern such as maintaining applications with greater ease, manipulating objects dynamically at run time and allowing our applications to have greater flexibility. As with any solution there are also cons that can creep into your application, if you are not careful. One of which is the decorator’s transparency i.e. if the programs UML is not made available to the new developers it can easily go unnoticed. This can create a significant problem because any changes that are made to the application can create mass confusion and undesired results. Another issue is that junior developers may not be able to understand what you have implemented and one can easily get perplexed if the creation of multiple small classes is present. &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;When creating programs that require a mass amount of subclasses to get the desired functionality needed, implementing the decorator pattern methodology can possibly improve your a program’s scalability and maintenance. In the “Scenario” section we created a small generic application that can be easily updated to create more types of sandwiches with different prices and topping combinations. In this application the Decorator pattern achieved the desired results in lieu of the said pros and cons.&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;strong&gt;Definitions&lt;/strong&gt;&lt;p&gt;&lt;/p&gt;Abstract&lt;br /&gt;&lt;p&gt;&lt;br /&gt;[A] formally unfinished class or method, marked with the keyword abstract. It is a way of preventing someone from instantiating a class that is supposed to be extended first. An abstract class is deliberately missing some or all of the method bodies. An abstract method is deliberately missing its method body. An abstract class is similar to an interface which is missing all the method bodies. An abstract class provides a base for someone to extend an actual class. You can’t use new on abstract classes, but you can use abstract references, which always point to objects of a class that extends the abstract class. Interfaces are implicitly abstract as are all their methods (Green, 2008).&lt;br /&gt;&lt;br /&gt;Class&lt;br /&gt;&lt;br /&gt;A class in Java is much like one in C++. It consists of a group of related methods and variables lumped together under one name. The static class variables are for class-as-a-whole data. They are allocated only once at load time and are shared by all instances of objects of that class. The instance variables, are allocated inside each object of that class. Static class methods work when there is no current object. They can only reference static class variables and static methods, unless of course they allocate an object and then use explicit references to the instance variables. Instance methods work by default on the fields of the current this object (Green, 2008).&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Inheritance&lt;br /&gt;&lt;br /&gt;When a class extends a superclass with additional methods and instance variables we say the new class inherits the methods and variables of the superclass. The new class may override some of the superclass’s methods and shadow some of its variables. Not all the inheritance is visible (i.e. available for you to use directly in your subclass), but it is present. Be careful, the inheritance rules for [public/protected/package/private] [static/instance] [method/variable] [abstract/actual] [class/interface] are all different (Green, 2008).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Object-Oriented&lt;br /&gt;&lt;br /&gt;Object-oriented to Java programmers refers to the way you organize methods in classes that work on the current object. Java supports inheritance and polymorphism via shadowing, overriding and overloading. The big advantage of object-oriented programming is the way you can easily create variants of the usual behaviors without cloning code. This makes maintaining the code much easier since when you later want to change something, you need to change it in only one place, not in all the myriad clones (Green, 2008).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Subclass&lt;br /&gt;&lt;br /&gt;This is the reverse of the way a mathematician might look at it. From the point of view of mathematical set theory, Dalmatian has a superset of the methods of Dog (Green, 2008).&lt;/p&gt;&lt;br /&gt;&lt;p&gt;UML&lt;br /&gt;&lt;br /&gt;UML stands for Universal Modeling Language. It is a modeling technique designed by Grady Booch, Ivar Jacobson, and James Rumbauch of Rational Rose. It is used for OOAD (Object Oriented Analysis and Design) It is supported by a broad base of industry-leading companies which, arguably, merges the best of the various notations into one single notation style. It is rapidly being supported by many tool vendors, but the primary drive comes from Rational Rose (Green, 2008).&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Additional Resources&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Cooper, J. W. (1998). The Design Patterns Java Companion. Retrieved April 4, 2008, from patterndepot.com: http://www.patterndepot.com/put/8/JavaPatterns.htm&lt;br /&gt;&lt;br /&gt;Design Patterns. (n.d.). Retrieved April 4, 2008, from SourceMaking.com: http://sourcemaking.com/design_patterns/decorator&lt;br /&gt;&lt;br /&gt;GUO International.(2008).Java Design Patterns At a Glance. Retrieved April 4, 2008, from Javacamp.com:&lt;br /&gt;&lt;br /&gt;http://www.javacamp.org/designPattern/&lt;br /&gt;&lt;br /&gt;McLaughlin, Brett, Pollice, Gary &amp;amp; West, David.(2007).Head First Object-Oriented Analysis and Design: A Brain Friendly Guide to OOA&amp;amp;D. Sebastopol: O'rielly Media, Inc.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;em style="font-weight: bold;"&gt;References:&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Cooper, J. W. (1998). The Design Patterns Java Companion. Wilton, Connecticut: Addison-Wesley.&lt;br /&gt;&lt;br /&gt;Cunningham &amp;amp; Cunningham, Inc. (2000). History Of Patterns. Retrieved March 21, 2008, from Cunningham &amp;amp; Cunningham, Inc.: http://www.c2.com/cgi-bin/wiki?HistoryOfPatterns&lt;br /&gt;&lt;br /&gt;Deitel, H. M., &amp;amp; Deitel, P. J. (2004). Java How to Program (4th Edition). New York City: Prentice Hall.&lt;br /&gt;&lt;br /&gt;Gamma, E., Helm, R., Johnson, R., &amp;amp; Vlissides, J. M. (1997). Design Patterns Elements of Reusable Object-Oriented Software. Upper Saddle River: Pearson Education Corporation.&lt;br /&gt;&lt;br /&gt;Green, R. (2008). Canadian Mind Products Java &amp;amp; Internet Glossary. Retrieved April 30, 2008, from Canadian Mind Products: http://mindprod.com/jgloss/jgloss.html&lt;br /&gt;&lt;br /&gt;Rumbaugh, J., Jacobson, I., &amp;amp; Booch, G. (1999). The Uniified Modeling Language Reference Manual. Massachusetts: Addison-Wesley.&lt;br /&gt;&lt;br /&gt;Snarski, R. (2007). Technical Communications in the Information Age. Acton: Copley Custom Textbooks.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/693951085906924382/1515651136081019054/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=693951085906924382&amp;postID=1515651136081019054' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/693951085906924382/posts/default/1515651136081019054'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/693951085906924382/posts/default/1515651136081019054'/><link rel='alternate' type='text/html' href='http://www.michaelduvall.com/2008/09/unwrapping-decorator-pattern-with-java.html' title='Unwrapping the Decorator Pattern with Java'/><author><name>Michael Duvall</name><uri>http://www.blogger.com/profile/17353796491441756483</uri><email>michaelpduvall@gmail.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-693951085906924382.post-4078184629108655298</id><published>2008-07-31T22:00:00.007-04:00</published><updated>2008-07-31T17:20:31.509-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='netsuite'/><title type='text'>Netsuite: speedline your data entry with the SuiteScript API</title><content type='html'>&lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Georgia;font-size:16px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;If you are like most IT professionals you often times find yourself trying to automate your processes to save time. When working in Netsuite I found that using the SuiteScript API, and a little bit of JavaScript can be a real time saver. &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Georgia;font-size:16px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;In this example I will show you how to use a basic method call to pre-fill your “adjust inventory form”. This method can be used on pretty much any form that you can attach a script to in Netsuite e.g. customer records, inventory, etc. &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 19px;font-family:Georgia;font-size:16px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Georgia;font-size:16px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;To begin we create a basic function in a text editor of your choice, Since I am using a Macbook Pro, I will be using TextWrangler because it works great, loads fast and most importantly it is free!. &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 19px;font-family:Georgia;font-size:16px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 19px;font-family:Georgia;font-size:16px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Georgia;font-size:16px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;Our first function will serve as a calling point- if you will- to execute the following set of small functions that we will create in order to “pre-fill” the following Netsuite fields.&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Georgia;font-size:16px;"&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Adjustment Account&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Department&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Class&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Memo&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Adjustment Location (in case you have more that one)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;     &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 15px;font-family:Monaco;font-size:11px;"&gt;&lt;span style="text-decoration: underline; letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="text-decoration: underline; letter-spacing: 0px;"&gt;function&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt; callAll(&lt;/span&gt;&lt;span style="text-decoration: underline; letter-spacing: 0px;"&gt;)&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;{&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 15px;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;setAdjustmentAcct();&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;setDepartment();&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;setClass();&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;setMemo();&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;setAdjLoc();&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="text-decoration: underline; letter-spacing: 0px;"&gt;}&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 19px;font-family:Georgia;font-size:16px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Georgia;font-size:16px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;Next we will create our second function as follows. &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 15px;font-family:Monaco;font-size:11px;"&gt;&lt;span style="text-decoration: underline; letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;function setAdjustmentAcct(){&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 15px;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;   &lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(127, 0, 85);"&gt;if&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt; (nlapiGetFieldValue(&lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(42, 0, 255);"&gt;'account'&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;).length == 0 ){&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;    nlapiSetFieldValue(&lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(42, 0, 255);"&gt;'account'&lt;/span&gt;&lt;span style="text-decoration: underline; letter-spacing: 0px;"&gt;,&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt; 69, &lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(127, 0, 85);"&gt;null&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;, &lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(127, 0, 85);"&gt;true&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;);&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 15px;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="text-decoration: underline; letter-spacing: 0px;"&gt;}&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 19px;font-family:Georgia;font-size:16px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Georgia;font-size:16px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;In line 1 we create the basic syntax for a JavaScript function and and give it the descriptive name of&lt;span class="Apple-style-span" style="font-size: small;"&gt; “&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; letter-spacing: 0px;font-family:Monaco;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;setAdjustmentAcct”&lt;/span&gt;&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;. &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 19px;font-family:Georgia;font-size:16px;"&gt;&lt;br /&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Georgia;font-size:16px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;In line 2 (ignoring the white space) we create a conditional statement to see if the adjustment account field has a value. We do this by using the&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; "&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; letter-spacing: 0px;font-family:Monaco;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;nlapiGetFieldValue()"&lt;/span&gt;&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;method of the SuiteScript API by passing the field id name &lt;/span&gt;&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;account&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;to the argument. (if you are having trouble finding the field id names, simply click on the field label and check the lower right corner screen shot 1).&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 19px;font-family:Georgia;font-size:16px;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p face="Georgia" size="16px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 19px;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p face="Georgia" size="16px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 19px;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.michaelduvall.com/uploaded_images/fieldHelp-757402.jpg"&gt;&lt;img src="http://www.michaelduvall.com/uploaded_images/fieldHelp-757391.jpg" alt="" style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 19px;font-family:Georgia;font-size:16px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 19px;font-family:Georgia;font-size:16px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 19px;font-family:Georgia;font-size:16px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;In line 3 we use the &lt;span class="Apple-style-span" style="font-size: small;"&gt;"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; letter-spacing: 0px;font-family:Monaco;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;nlapiSetFieldValue()"&lt;/span&gt;&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;method to set the &lt;span style="letter-spacing: 0px;"&gt;“adjustment account['s]” field value to the corresponding general ledger account Id. In this case, it will be set to one of the "cost of goods sold" inventory accounts, which has a field id of 69. The next argument is set to &lt;span class="Apple-style-span" style="font-size: small;"&gt;"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;null"&lt;/span&gt;&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt; and the following to &lt;/span&gt;&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;. Since this is a statement we want to end it by using a semicolon. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p face="Georgia" size="16px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 19px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px;  font-style: normal; font-variant: normal; font-weight: normal;  line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 19px;font-family:Georgia;font-size:16px;"&gt;Line 4 closes out the function with a curly brace “}”.&lt;br /&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px;  font-style: normal; font-variant: normal; font-weight: normal;  line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 19px;font-family:Georgia;font-size:16px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Georgia;font-size:16px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;Repeat this pattern for the remaining functions as follows:&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 15px;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;function setLocation(){&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 15px;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;  &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(127, 0, 85);"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;if&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt; (nlapiGetFieldValue(&lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(42, 0, 255);"&gt;'adjlocation'&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;).length == 0){&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 15px;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;  &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;nlapiSetFieldValue(&lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(42, 0, 255);"&gt;'adjlocation'&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;, 1, &lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(127, 0, 85);"&gt;null&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;, &lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(127, 0, 85);"&gt;true&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;);&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 15px;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;}&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 15px;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;function setClass(){&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 15px;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;  &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(127, 0, 85);"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;if&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt; (nlapiGetFieldValue(&lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(42, 0, 255);"&gt;'class'&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;).length == 0){&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 15px;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;  &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;nlapiSetFieldValue(&lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(42, 0, 255);"&gt;'class'&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;, 10, &lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(127, 0, 85);"&gt;null&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;, &lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(127, 0, 85);"&gt;true&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;);&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 15px;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;}&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 15px;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 15px;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;function setDepartment(){&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 15px;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;  &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(127, 0, 85);"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;if&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt; (nlapiGetFieldValue(&lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(42, 0, 255);"&gt;'department'&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;).length == 0){&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 15px;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;  &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;nlapiSetFieldValue(&lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(42, 0, 255);"&gt;'department'&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;, 10, &lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(127, 0, 85);"&gt;null&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;, &lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(127, 0, 85);"&gt;true&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;);&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 15px;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;}&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 15px;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;function setMemo(){&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 15px;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;  &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(127, 0, 85);"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;if&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt; (nlapiGetFieldValue(&lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(42, 0, 255);"&gt;'Memo'&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;).length == 0){&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 15px;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;  &lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;nlapiSetFieldValue(&lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(42, 0, 255);"&gt;'Memo'&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;, &lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(42, 0, 255);"&gt;'This is my Memo'&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;, &lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(127, 0, 85);"&gt;null&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;, &lt;/span&gt;&lt;span style="letter-spacing: 0px; color: rgb(127, 0, 85);"&gt;true&lt;/span&gt;&lt;span style="letter-spacing: 0px;"&gt;);&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 15px;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-family:Monaco;font-size:11px;"&gt;&lt;span style="text-decoration: underline; letter-spacing: 0px;"&gt;}&lt;/span&gt;&lt;/p&gt; &lt;p   style="margin: 0px;  font-style: normal; font-variant: normal; font-weight: normal;  line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 19px;font-family:Georgia;font-size:16px;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p face="Georgia" size="16px" style="margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Save the file with a name such as “setInventoryAdjs.js”- or something similar -so that you will remember what it is when you upload it to your suitescript folder in netsuite. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p face="Georgia" size="16px" style="margin: 0px;  font-style: normal; font-variant: normal; font-weight: normal;  line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="margin: 0px; font-family: Georgia; font-style: normal; font-variant: normal; font-weight: normal; font-size: 16px; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="margin: 0px; font-family: Georgia; font-style: normal; font-variant: normal; font-weight: normal; font-size: 16px; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.michaelduvall.com/uploaded_images/InventoruAdjForm-792118.jpg"&gt;&lt;img src="http://www.michaelduvall.com/uploaded_images/InventoruAdjForm-792035.jpg" alt="" style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p  style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;  font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-family:Georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Download the complete script here: &lt;/span&gt;&lt;a href="http://www.michaelduvall.com/downloads/setInventoryAdjs.js"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;setInventoryAdjs.js&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p  style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;  font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-family:Georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;  font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-family:Georgia;"&gt;&lt;span style="letter-spacing: 0px;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Coming Soon!, "How to" attach a SuiteScript to a form.  &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/693951085906924382/4078184629108655298/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=693951085906924382&amp;postID=4078184629108655298' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/693951085906924382/posts/default/4078184629108655298'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/693951085906924382/posts/default/4078184629108655298'/><link rel='alternate' type='text/html' href='http://www.michaelduvall.com/2008/07/netsuite-speedline-your-data-entry-with.html' title='Netsuite: speedline your data entry with the SuiteScript API'/><author><name>Michael Duvall</name><uri>http://www.blogger.com/profile/17353796491441756483</uri><email>michaelpduvall@gmail.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-693951085906924382.post-7605164169835119480</id><published>2008-07-29T12:19:00.003-04:00</published><updated>2008-07-30T07:35:31.798-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>My first Java Program, My First Blog</title><content type='html'>&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;i&gt;In this tutorial we assume that you have JAVA installed on your computer and have set the necessary environmental variables in order to compile your programs. If you need more information on this please visit Java.com or http://www.jibble.org/settingupjava.php to install the proper developer’s kit for your operating system.&lt;/i&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia; min-height: 19.0px"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia"&gt;&lt;span style="letter-spacing: 0.0px"&gt;With every programming language comes the much dreaded starting point in which the developer will have to come to terms with the inevitable "hello world program". In this brief example I will break this cliche a bit and show you how to do a "Hello, Google!" program. No this will not increase your search engine rankings or make you part of an elite developer's pack, but it will start you off with the basic fundamentals of the Java Programing language, and show you how to output a string to the console/terminal window of your operation system. &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia; min-height: 19.0px"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia"&gt;&lt;span style="letter-spacing: 0.0px"&gt;To begin we start with the basic code: &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia; min-height: 19.0px"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span style="letter-spacing: 0.0px ;color:#721b54;"&gt;public&lt;/span&gt;&lt;span style="letter-spacing: 0.0px"&gt; &lt;/span&gt;&lt;span style="letter-spacing: 0.0px ;color:#721b54;"&gt;class&lt;/span&gt;&lt;span style="letter-spacing: 0.0px"&gt; HelloGoogleCode {&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="letter-spacing: 0.0px ;color:#721b54;"&gt;public&lt;/span&gt;&lt;span style="letter-spacing: 0.0px"&gt; &lt;/span&gt;&lt;span style="letter-spacing: 0.0px ;color:#721b54;"&gt;static&lt;/span&gt;&lt;span style="letter-spacing: 0.0px"&gt; &lt;/span&gt;&lt;span style="letter-spacing: 0.0px ;color:#721b54;"&gt;void&lt;/span&gt;&lt;span style="letter-spacing: 0.0px"&gt; main (String[] args){&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;System.&lt;/span&gt;&lt;span style="letter-spacing: 0.0px ;color:#1432ba;"&gt;out&lt;/span&gt;&lt;span style="letter-spacing: 0.0px"&gt;.print("Hello, Google!");&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;span style="letter-spacing: 0.0px"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;span style="letter-spacing: 0.0px"&gt;}&lt;/span&gt;&lt;span style="font: 48.0px Georgia; letter-spacing: 0.0px color:#333333;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;b&gt;The First Line:&lt;/b&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia"&gt;&lt;span style="letter-spacing: 0.0px"&gt;Notice we start the program with the words "public" and "class" and follow that with a descriptive term to label our class “HelloGoogleCode”.  The words &lt;i&gt;public&lt;/i&gt; and &lt;i&gt;class&lt;/i&gt; are considered to be Java Keywords (we will get into this in more depth later) . &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia"&gt;&lt;span style="letter-spacing: 0.0px"&gt;In addition you will notice the first letter of the class name is UpperCase as well as the following words “Google” and Code”. This is a common naming convention in the Java programming language and will determine what you will name your file as. In this instance we would save the java file as “HelloGoogleCode.java”. It should also be noted that it is customary to label your class names as nouns. &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;b&gt;The Second Line&lt;/b&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia"&gt;&lt;span style="letter-spacing: 0.0px"&gt;In the second line of code  we use the main method syntax .In the Java programming language this is read by the Java Virtual Machine (JVM) as the starting point to the program’s execution, and it is here where the main method is called (and any other methods you may have).&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia; min-height: 19.0px"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia; min-height: 19.0px"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;b&gt;The Third Line&lt;/b&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia"&gt;&lt;span style="letter-spacing: 0.0px"&gt;Finally in the third line this is where we output the text string “Hello, Google” to the console, using the “System.out” object and the “print” method. It is important to note the line &lt;/span&gt;&lt;span style="font: 11.0px Monaco; letter-spacing: 0.0px"&gt;System.&lt;/span&gt;&lt;span style="font: 11.0px Monaco; letter-spacing: 0.0px color:#1432ba;"&gt;out&lt;/span&gt;&lt;span style="font: 11.0px Monaco; letter-spacing: 0.0px"&gt;.print("Hello, Google!");&lt;/span&gt;&lt;span style="letter-spacing: 0.0px"&gt; is considered to be a statement and must be followed by a semicolon. &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia; min-height: 19.0px"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;b&gt;Compile it!&lt;/b&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia"&gt;&lt;span style="letter-spacing: 0.0px"&gt;To compile the above code in the windows environment, I would generally use a program like notepad++ (free) to write and save the code. Then open up the command line utility in windows, navigate to the directory when the file has been saved by using the change directory command i.e. &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia; min-height: 19.0px"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia; color:#66b132;"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 204, 0);"&gt;cd Desktop&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia;  min-height: 19.0pxcolor:#66b132;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 204, 0);"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia; color:#66b132;"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 204, 0);"&gt;javac HelloGoogleCode.Java&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia;  min-height: 19.0pxcolor:#66b132;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 204, 0);"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia; color:#66b132;"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 204, 0);"&gt;java  HelloGoogleCode&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia; min-height: 19.0px"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia"&gt;&lt;span style="letter-spacing: 0.0px"&gt;The output, if compiled with no errors, should be:&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia; min-height: 19.0px"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia; color:#66b132;"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 255, 51);"&gt;Hello, Google!&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia; min-height: 19.0px"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Please note that this method will only work if you have Java installed on your machine and have properly set up the environmental variables on your system. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia; min-height: 19.0px"&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia; min-height: 19.0px"&gt;&lt;br /&gt;&lt;span style="letter-spacing: 0.0px"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Georgia"&gt;&lt;span style="letter-spacing: 0.0px"&gt;As you can see there is a lot going on in these couple lines of code, I will expand upon the basic fundamentals of JAVA and other  OOP (Object Oriented Programming) principles in later tutorials. But for now I will leave you will this minor titbit and hope to bring you more tutorials very soon. &lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/693951085906924382/7605164169835119480/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=693951085906924382&amp;postID=7605164169835119480' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/693951085906924382/posts/default/7605164169835119480'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/693951085906924382/posts/default/7605164169835119480'/><link rel='alternate' type='text/html' href='http://www.michaelduvall.com/2008/07/test-blog.html' title='My first Java Program, My First Blog'/><author><name>Michael Duvall</name><uri>http://www.blogger.com/profile/17353796491441756483</uri><email>michaelpduvall@gmail.com</email></author></entry></feed>