Where to put methods?

Hi folks, this isn't a Java dependant question but since I am coding in Java I will ask it here. I have a value object that contains a few attributes, accessor and persistence methods. We'll call the Class Player and it contains details of a person who is playing a game. All of the methods and attributes belonging to this Class are related to an instance of Player. I want to have a utility method that returns ALL the players. What do people of the group think is the best way to treat this method? Should I add a new Class i.e. PlayerUtils, where I could subsequently add more utility methods OR would adding a method to the Player Class, public static Vector getAllPlayers() be a viable option? My gut feeling is to go with the PlayerUtils Class even though there is only one method so far because it is more flexbile and it keeps static method calls out of my instance Class. I don't really have any formal training in Java so most of what I have learned is through experience and reference-type books. Your thoughts are valued.
Thanks, Max

This is like a singleton, except it is a "multipleton". (I haven't studied my design patterns well yet, maybe it has a name.) I agree that keeping the collection information in another class might be a better idea, but this Player class could also do its own enforcing that certain Player fields (such as name) acts like primary keys and are not duplicated.
class Player
   // static field
   private static Vector allPlayers = new Vector();
   // private constr
   private Player(<args>)
   public static Player createNewPlayer(<args>)
      Player newguy = new Player(args);
      allPlayers.add(newguy);
      return newguy;
   public static Player getPlayerByName(String name)
      ... // assuming Player has a Name field, find him
   public static Vector getAllPlayers()
      return allPlayers;  // or a copy of it

Similar Messages

  • Where to put methods in a abstract base class - subclasses system

    Hi,
    I’d like to ask a question on some basic design practice.
    When there are methods which are common in some subclasses so I would like to “move them up” in the base abstract class, I would also like to make sure that the ADT concept of the base class itself is not broken. So I don’t want to have methods in the base class that are not general enough to be there. How to resolve this?
    For example I create a base abstract class Vehicle. Then I create subclasses Plane and Tanker and realize that the startEnginge() method in them is the same and in order remove the duplicated code, I can put it in Vehicle. But later there may be Bicycle or Sled subclasses which don’t need startEngine().
    In a broader sense, I would like to keep the Vehicle class as similar to the real word concept of vehicles as possible. And not evey vehicle have engine of course.
    What is the solution?
    Extending the class hierarchy by injecting another abstract class between the base and the subclasses? (e.g: VehicleWithEngine)
    I suppose I can’t use Interfaces because I need to have the common implemenations as well.
    Thanks for any comments in advance,
    lemonboston
    ps: I am a beginner and don't know the terminology, so if there are programming expression for the followings for example, I would be thankful if someone could help with this too:
    - moving common methods up in the class hierarchy
    - injecting a class in the hierarchy
    - abstract base class - subclasses system

    lemonboston wrote:
    Hi,
    I’d like to ask a question on some basic design practice.
    When there are methods which are common in some subclasses so I would like to “move them up” in the base abstract class, I would also like to make sure that the ADT concept of the base class itself is not broken. So I don’t want to have methods in the base class that are not general enough to be there. How to resolve this?
    You are talking about code.
    Instead you need to talk about the design.
    The base class represents conceptually a 'type' of something. That 'type' defines behavior. That behavior is what goes in the base class nothing else (in terms of design.)
    If you have common functionality which does not fit into the definition (design) of the 'type' then you put it in another class and use (composition) that class in the sub class.
    For example I create a base abstract class Vehicle. Then I create subclasses Plane and Tanker and realize that the startEnginge() method in them is the same and in order remove the duplicated code, I can put it in Vehicle. But later there may be Bicycle or Sled subclasses which don’t need startEngine(). No that is not how it works.
    You have specific examples of some vehicles and then you need to manage those types generically. That is the first step.
    Second step is then to determine what the exact 'type' is that you want to manage. And you use the requirements of the need to create the 'type'.
    Then you look at the specific examples to determine how they will meet the needs of the type.
    Thus if I have an application that must start the engines of all the vehicles in the city then I must have a vehicle class which has startEngine.
    But if I have an application that manages vehicles as inventory (like a retail store) and then decide that because my examples both have engines that I might as well move it into the base class. In that case there is no 'need' for the application to manage starting vehicles. The fact that both have engines is irrelevant.
    So looking back at your example you have stated functionality about your specific types but you have not stated anything about why your application needs to deal with that functionality generically.
    Another way to think about it is that you do not put the shared functionality in the base because you can but rather because you must.

  • Where to put javascript code?

    Hello,
    I am trying to set some columns in a list as "read-only" and is using the following code:
    <script type=”text/javascript”>
    function SetReadOnly()
    var elements=document.getElementById(’4_ctl00_ctl00_TextField’);
    elements.readOnly=true;
    _spBodyOnLoadFunctionNames.push(“SetReadOnly()”);
    </script>
    But I am not sure where to put the code in. Should I put it in the space in Content Editor Web Part,
    or through a link to a txt file, or in "Edit HTML"? I've tried them but none works.
    Thanks a lot!
    Patrick

    You can try this:
    1) Open your Sharepoint List. Go to List edit view.
    2) On right side of Ribbon you will find "Form Web Parts" option as shown in figure.
    3) Choose your List form which you want to edit.
    4) Now you can add web part in new window.
    5) Add Content Editor Web part.
    6) In content editor web part add the path of your "txt" file in which you have written your script, for eg.
    <!DOCTYPE html>
    <html>
    <body>
    <script type=”text/javascript”>
    function SetReadOnly()
    var elements=document.getElementById('4_ctl00_ctl00_TextField');
    elements.readOnly=true;
    _spBodyOnLoadFunctionNames.push("SetReadOnly()");
    </script>
    </body>
    </html>
    I haven't tried this method so I am not sure but hope it works...:D
    ***If my post is answer for your query please mark as answer***
    ***If my answer is helpful please vote***

  • 10g UIX Where to put ResourceBundle?

    I'm looking at putting all my Strings in a ResourceBundle for my UIX pages. I've read the documentation for Internationalization, but I think the piece that I'm missing is where to put the properties file. Say I've got a file called 'strings.properties', and my provider looks like this:
    <provider>
         <data name="bundle" >
              <bundle class="strings.properties" />
         </data>
    </provider>Then where in the JDev project do I need to have the file in order for it to get deployed properly and found by the UIX framework at runtime?
    Also, just to be sure I'm not going crazy, I know that the documentation and even the bundle tag say to specify a Class, and I just noticed that the ResourceBundle javadoc also says that the 'baseName' parameter to the static 'getBundle' method should be a 'fully qualified class name', but I've always just given it a filename of a properties file before. So I'm assuming that the 'class' parameter to the bundle tag can be a properties filename -- is this correct?

    Whoops! Of course, the argument to the bundle class attribute should just be 'strings'.
    After some experimentation, I discovered that if I put the properties file at the root of the 'src' directory in my JDev project, then it gets transferred to the 'classes' output directory when I compile. This works for running my project in the Embedded OC4J. I haven't tried deploying it to any other app server yet. Is this the right place?

  • Problem in Storing ByteArray(Value) with String (Key) using put method

    Hello Folks:
    I wish to store a byte array with associated with a String. For this I use the put method in Java which stores put(Object key, Object value). I have written a piece of code which works but I am not able to understand it. Its not outputing what I want but something else.
    I guess, I have some ignorance.
    When I compile using
    $javac testing.java propsput.java
    $java testing
    I get the following output.
    Bytes Array:[B@1372a1a
    I understand that B stands for Bytes array. Also, If I change the String I get the same thing. If I modify the code for Integer array
    and store some Integer array I get [I@1372a1a.
    I fail to understand why I am getting this 1372a1a again and again.
    Instead where is my array.
    May be I am not using the method getValue correctly.
    Thank You very much for your help
    Regards
    //testing.java
    import java.io.*;
    import java.util.*;
    public class testing{
    public static void main(String args[]){
    propsput headers=new propsput();
    String s="Let me See how you do it";
    byte buf[]=s.getBytes();
    headers.put("Bytes Array",buf);
    //propsput.java
    import java.util.*;
    import java.io.*;
    public class propsput{
    public void put (String key, byte[] value) throws IllegalArgumentException{
    HashMap _props =new HashMap();
    _props.put(key, value);
    Set set =_props.entrySet();
    Iterator i=set.iterator();
    while(i.hasNext())
    Map.Entry me=(Map.Entry) i.next();
    System.out.print(me.getKey()+":");
    System.out.println(me.getValue());
    ----------------------------------------------------------------

    Hi Thanks for your help.
    But I have included your method in the propsput class and also using it like this in the propsput class.
    while(i.hasNext())
    Map.Entry me=(Map.Entry) i.next();
    System.out.print(me.getKey()+":");
    byte a[]=me.getValue();
    showBytes(a);
    But while compiling with javac I get the following error:
    propsput.java:24: incompatible types
    found : java.lang.Object
    required: byte[]
    byte a[]=me.getValue();
    Please let me know how should I use it so as to print my String.
    Well, its still not clear in the previous code (my First Message) that why I am gettinng "1372a1a" everytime. (Even if I change the String. When I change the array to be an Integer array I get [I@1372a1a )
    Othewise in the case of Strings I get ( [B@1372a1a)
    Bytes Array:[B@1372a1a
    Thanks and Regards                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Where to put java code - Best Practice

    Hello. I am working with the Jdeveloper 11.2.2. I am trying to figure out the best practice for where to put code. After reviewing http://docs.oracle.com/cd/E26098_01/web.1112/e16182.pdf it seemed like the application module was the preferred spot (although many of the examples in the pdf are in main methods). After coding a while though, I noticed that there were quite a few libraries imported, and wondered whether this would impact performance.
    I reviewed postings on the forum, especially Re: Access service method (client interface) programmatically . This link mentions accessing code from a backing bean -- and the gist of the recommendations seems to be to use the data control to drag it to the JSF, or use the bindings to access code.
    My interest lies in where to put java code in the first place; In the View Object, Entity Object, and Am object, backing bean.....other?
    I can outline several best guesses about where to put code and the pros and cons:
    1. In the application module
    Pros: Centralized location for code makes development and support more simple as there are not multiple access points. Much like a data control centralizes services, the application module can act as a conduit for different pieces of code you have in objects in your model.
    Cons: Everything in one place means the application module becomes bloated. I am not sure how memory works in java -- if the app module has tons of different libraries are they all called when even a simple query re-execute method is called? Memory hog?
    2. Write code in the objects it affects. If you are writing code that accesses a view object, write it in a view object. Then make it visible to the client.
    pros: The code is accessed via fewer conduits (for example, I would expect that if you call the application module from a JSF backing bean, then the application module calls the view object, you have three different pieces of code --
    conts: The code gets spread out, harder to locate etc.
    I would greatly appreciate your thoughts on the matter.
    Regards,
    Stuart
    Edited by: Stuart Fleming on May 20, 2012 5:25 AM
    Edited by: Stuart Fleming on May 20, 2012 5:27 AM

    First point here is when you say "where to put the java code" and you're referring to ADF BC, the point is you put "business logic java code" in the ADF Business Components. It's fine of course to have Java code in the ViewController layer that deals with the UI layer. Just don't put business logic in the UI layer, and don't put UI logic in the model layer. In your 2 examples you seem to be considering the ADF BC layer only, so I'll assume you mean business logic java code only.
    Meanwhile I'm not keen on the term best practice as people follow best practices without thinking, typically best practices come with conditions and people forget to apply them. Luckily you're not doing that here as you've thought through the pros and cons of each (nice work).
    Anyway, back on topic and off my soap box, as for where to put your code, my thoughts:
    1) If you only have 1 or 2 methods put it in the AppModuleImpl
    2) If you have hundreds of methods, or there's a chance #1 above will morph into #2, split the code up between the AppModuleImpl, ViewImpl and ViewRowImpls. Why? Because your AM will become overloaded with hundreds of methods making it unreadable. Instead put the code where it should logically go. Methods that work on a specific VO row go into the associated ViewRowImpl, methods that work across rows in a VO go into the ViewImpl, and methods that work across VOs in the associated AppModuleImpl.
    To be honest which you ever option you choose, one thing I do recommend as a best practice is be consistent and document the standard so your other programmers know.
    Btw there isn't an issue about loading lots of libraries/imports into a class, it has no runtime cost. However if your methods require lots of class variables, then yes this will have a memory cost.
    On a side note if you're interested in more ideas around how to build ADF apps correctly think about joining the "ADF EMG", a free online forum which discusses ADF architecture, best practices (cough), deployment architectures and more.
    Regards,
    CM.

  • Architecture question...where to put the code

    Newbie here, so please be gentle and explicit (no detail is
    too much to give or insulting to me).
    I'm hoping one of you architecture/design gurus can help me
    with this. I am trying to use good principals of design and not
    have code scattered all over the place and also use OO as much as
    possible. Therefore I would appreciate very much some advice on
    best practices/good design for the following situation.
    On my main timeline I have a frame where I instantiate all my
    objects. These objects refer to movieClips and textFields etc. that
    are on a content frame on that timeline. I have all the
    instantiation code in a function called initialize() which I call
    from the content frame. All this works just fine. One of the
    objects on the content frame is a movieClip which I allow the user
    to go forward and backward in using some navigation controls.
    Again, the object that manages all that is instantiated on the main
    timeline in the initialize() function and works fine too. So here's
    my question. I would like to add some interactive objects on some
    of the frames of the movieClip I allow the user to navigate forward
    and backward in (lets call it NavClip) . For example on frame 1 I
    might have a button, on frame 2 and 3 nothing, on frame 4 maybe a
    clip I allow the user to drag around etc. So I thought I would add
    a layer to NavClip where I will have key frames and put the various
    interactive assets on the appropriate key frames. So now I don't
    know where to put the code that instantiates these objects (i.e.
    the objects that know how to deal with the events and such for each
    of these interactive assets). I tried putting the code on my main
    timeline, but realized that I can't address the interactive assets
    until the NavClip is on the frame that holds the particular asset.
    I'm trying not to sprinkle code all over the place, so what do I
    do? I thought I might be able to address the assets by just
    providing a name for the asset and not a reference to the asset
    itself, and then address the asset that way (i.e.
    NavClip["interactive_mc"] instead of NavClip.interactive_mc), but
    then I thought that's not good since I think there is no type
    checking when you use the NavClip["interactive_mc"] form.
    I hope I'm not being too dim a bulb on this and have missed
    something really obvious. Thanks in advance to anyone who can help
    me use a best practice.

    1. First of all, the code should be:
    var myDraggable:Draggable=new Draggable(myClip_mc);
    myDraggable.initDrag();
    Where initDrag() is defined in the Draggable class. When you
    start coding functions on the timeline... that's asking for
    problems.
    >>Do I wind up with another object each time this
    function is called
    Well, no, but. That would totally depend on the code in the
    (Draggable) class. Let's say you would have a private static var
    counter (private static, so a class property instead of an instance
    property) and you would increment that counter using a
    setInterval(). The second time you enter the frame and create a new
    Draggable object... the counter starts at the last value of the
    'old' object. So, you don't get another object with your function
    literal but you still end up with a faulty program. And the same
    goes for listener objects that are not removed, tweens that are
    running and so on.
    The destroy() method in a custom class (=object, I can't
    stress that enough...) needs to do the cleanup, removing anything
    you don't need anymore.
    2. if myDraggable != undefined
    You shouldn't be using that, period. If you don't need the
    asset anymore, delete it using the destroy() method. Again, if you
    want to make sure only one instance of a custom object is alive,
    use the Singleton design pattern. To elaborate on inheritance:
    define the Draggable class (class Draggable extends MovieClip) and
    connect it to the myClip_mc using the linkage identifier in the
    library). In the Draggable class you can define a function unOnLoad
    (an event fired when myClip_mc is removed using
    myClip_mc.removeMovieClip()...) and do the cleanup there.
    3. A destroy() method performs a cleanup of any assets we
    don't need anymore to make sure we don't end up with all kinds of
    stuff hanging around in the memory. When you extend the MovieClip
    Class you can (additionally) use the onUnLoad event. And with the
    code you posted, no it wouldn't delete the myClip_mc unless you
    program it to do so.

  • Where to put removeChild (Away3d 4.x)

    Hey guys i need some help on how to change primitives and removing the previous primitive showing in the scene and also changing materials on the primitive with a click of a button.
    Mainly just where to put removeChild.
    This is for Away3d
    package
        import away3d.cameras.*;
        import away3d.containers.*;
        import away3d.controllers.*;
        import away3d.core.base.SubGeometry;
        import away3d.core.base.data.Vertex;
        import away3d.debug.*;
        import away3d.entities.Mesh;
        import away3d.extrusions.*;
        import away3d.filters.*;
        import away3d.lights.*;
        import away3d.materials.*;
        import away3d.materials.lightpickers.*;
        import away3d.materials.methods.*;
        import away3d.primitives.*;
        import away3d.textures.*;
        import away3dplus.controllers.SimpleHoverController;
        import flash.display.Bitmap;
        import flash.display.BitmapData;
        import flash.display.Sprite;
        import flash.display.StageAlign;
        import flash.display.StageScaleMode;
        import flash.events.Event;
        import flash.events.MouseEvent;
        import flash.geom.Vector3D;
        import flash.text.TextField;
        import flash.text.TextFieldAutoSize;
        import flash.text.TextFormat;
        [SWF(backgroundColor="#000000",frameRate="30",quality="LOW")]
        public class Main extends Sprite
        //engine variables
        private var view:View3D;
        private var scene:Scene3D;
        // debug
        private var awayStats:AwayStats;
        //light objects
        private var pointLight:PointLight;
        private var lightPicker:StaticLightPicker;
        //material objects
        private var redColorMaterial:ColorMaterial;
        private var skyBoxCubeTexture:BitmapCubeTexture;
        //Buttons   
        private var btnCube:Sprite = new Sprite
        private var btnSphere:Sprite = new Sprite
        private var btnCylinder:Sprite = new Sprite
        private var btnTorus:Sprite = new Sprite   
        private var btnMaterial:Sprite = new Sprite   
        private var btnWireframe:Sprite = new Sprite
            public function Main() {
                init();
                private function init():void {
                    initEngine();
                    initLights();
                    initCamera();
                    initMaterials();
                    initObjects();
                    initListeners();
                    drawButton()
                    btnCube.addEventListener(MouseEvent.CLICK, changeCube);
                    btnCube.x = 400;
                    btnCube.y = 25;
                    addChild(btnCube);
                    btnSphere.addEventListener(MouseEvent.CLICK, changeSphere);
                    btnSphere.x = 400;
                    btnSphere.y = 60;
                    addChild(btnSphere);
                    btnCylinder.addEventListener(MouseEvent.CLICK, changeCylinder);
                    btnCylinder.x = 400;
                    btnCylinder.y = 95;
                    addChild(btnCylinder);
                    btnTorus.addEventListener(MouseEvent.CLICK, changeTorus);
                    btnTorus.x = 400;
                    btnTorus.y = 130;
                    addChild(btnTorus);
                    //btnMaterial.addEventListener(MouseEvent.CLICK, changeMaterial);
                    btnMaterial.x = 15;
                    btnMaterial.y = 95;
                    addChild(btnMaterial);
                    btnWireframe.addEventListener(MouseEvent.CLICK, changeWireframe);
                    btnWireframe.x = 15;
                    btnWireframe.y = 130;
                    addChild(btnWireframe);
                 * Initialise the engine
                private function initEngine():void {
                    //stage setup
                    stage.scaleMode = StageScaleMode.NO_SCALE;
                    stage.align = StageAlign.TOP_LEFT;
                    // 3d view - window into 3d scene
                    view = new View3D();
                    addChild(view);
                    // 3d scene.
                    scene = view.scene;
                    // stats
                    awayStats = new AwayStats(view);
                    addChild(awayStats);
                 * Initialise the lights
                private function initLights():void {
                    //point light
                    pointLight = new PointLight();
                    scene.addChild(pointLight);
                    lightPicker = new StaticLightPicker([pointLight]);
                private function initCamera():void {
                    var hoverCameraManager:SimpleHoverController = new SimpleHoverController(view, 700, [pointLight]);
                 * Initialise Buttons
                private function drawButton():void {
                    var textLabel:TextField = new TextField()
                    btnCube.graphics.clear();
                    btnCube.graphics.beginFill(0xFFFFFF); // white
                    btnCube.graphics.drawRoundRect(0, 0, 80, 25, 10, 10); // x, y, width, height, ellipseW, ellipseH
                    textLabel.text = "CUBE";
                    textLabel.x = 22;
                    textLabel.y = 4;
                    textLabel.selectable = false;
                    btnCube.addChild(textLabel)
                var textLabel01:TextField = new TextField()   
                btnSphere.graphics.clear();
                btnSphere.graphics.beginFill(0xFFFFFF); // white
                btnSphere.graphics.drawRoundRect(0, 0, 80, 25, 10, 10); // x, y, width, height, ellipseW, ellipseH   
                textLabel01.text = "SPHERE";
                textLabel01.x = 18;
                textLabel01.y = 3;
                textLabel01.selectable = false;
                btnSphere.addChild(textLabel01)
                var textLabel03:TextField = new TextField()   
                btnCylinder.graphics.clear();
                btnCylinder.graphics.beginFill(0xFFFFFF); // white
                btnCylinder.graphics.drawRoundRect(0, 0, 80, 25, 10, 10); // x, y, width, height, ellipseW, ellipseH   
                textLabel03.text = "CYLINDER";
                textLabel03.x = 10;
                textLabel03.y = 3;
                textLabel03.selectable = false;
                btnCylinder.addChild(textLabel03)   
                var textLabel04:TextField = new TextField()   
                btnTorus.graphics.clear();
                btnTorus.graphics.beginFill(0xFFFFFF); // white
                btnTorus.graphics.drawRoundRect(0, 0, 80, 25, 10, 10); // x, y, width, height, ellipseW, ellipseH   
                textLabel04.text = "TORUS";
                textLabel04.x = 17;
                textLabel04.y = 3;
                textLabel04.selectable = false;
                btnTorus.addChild(textLabel04)   
                var textLabel05:TextField = new TextField()   
                btnMaterial.graphics.clear();
                btnMaterial.graphics.beginFill(0xFFFFFF); // white
                btnMaterial.graphics.drawRoundRect(0, 0, 80, 25, 10, 10); // x, y, width, height, ellipseW, ellipseH   
                textLabel05.text = "MATERIAL";
                textLabel05.x = 6;
                textLabel05.y = 3;
                textLabel05.selectable = false;
                btnMaterial.addChild(textLabel05)       
                var textLabel06:TextField = new TextField()   
                btnWireframe.graphics.clear();
                btnWireframe.graphics.beginFill(0xFFFFFF); // white
                btnWireframe.graphics.drawRoundRect(0, 0, 80, 25, 10, 10); // x, y, width, height, ellipseW, ellipseH   
                textLabel06.text = "WIREFRAME";
                textLabel06.x = 2;
                textLabel06.y = 3;
                textLabel06.selectable = false;
                btnWireframe.addChild(textLabel06)       
                 * Initialise the materials
                private function initMaterials():void {
                    // red color
                    redColorMaterial = new ColorMaterial(0xFF0000, 0.8);
                    redColorMaterial.lightPicker = lightPicker;
                    skyBoxCubeTexture = new BitmapCubeTexture(new EnvPosX().bitmapData, new EnvNegX().bitmapData, new EnvPosY().bitmapData, new EnvNegY().bitmapData, new EnvPosZ().bitmapData, new EnvNegZ().bitmapData);
                 * Initialise the scene objects
                private function initObjects():void {
                    var trident:Trident = new Trident(100);
                    trident.x = 0;
                    trident.y = 0;
                    scene.addChild(trident);
                    //Geometry - Geometry is a collection of SubGeometries, each of which contain the actual geometrical data such as vertices, normals, uvs, etc.
                        ////PrimitiveBase    - PrimitiveBase is an abstract base class for mesh primitives, which are prebuilt simple meshes.
                            //CubeGeometry     A Cube primitive mesh.
                            var newCubeGeometry:CubeGeometry = new CubeGeometry(200, 200, 200, 50, 50, 50, true);
                            //SphereGeometry - A UV Sphere primitive mesh.
                            var newSphereGeometry:SphereGeometry = new SphereGeometry(50, 16, 12, true);
                            //CapsuleGeometry     A UV Capsule primitive mesh.
                            var newCapsuleGeometry:CapsuleGeometry = new CapsuleGeometry(50, 100, 16, 12, true);
                            //ConeGeometry     A UV Cone primitive mesh.
                            //var newConeGeometry:ConeGeometry = new ConeGeometry(50, 100, 16, 1, true, true);
                            //CylinderGeometry     A UV Cylinder primitive mesh.
                            var newCylinderGeometry:CylinderGeometry = new CylinderGeometry(50, 50, 100, 16, 1, true, true);
                            //PlaneGeometry     A Plane primitive mesh.
                            var newPlaneGeometry:PlaneGeometry = new PlaneGeometry(100, 100, 1, 1, true);
                            //RegularPolygonGeometry     A UV RegularPolygon primitive mesh.
                            var newRegularPoligonGeometry:RegularPolygonGeometry = new RegularPolygonGeometry(100, 16, true);
                            //TorusGeometry     A UV Torus primitive mesh.
                            var newTorusGeomentry:TorusGeometry = new TorusGeometry(50, 50, 15, 8, true);
                    // Entity - The Entity class provides an abstract base class for all scene graph objects that are considered having a "presence" in the scene,
                    //            in the sense that it can be considered an actual object with a position and a size (even if infinite or idealised), rather than a grouping.
                        //Mesh - Mesh agregates instance of a Geometry, augmenting it with a presence in the scene graph, a material, and an animations tate.
                        //            It consists out of SubMeshes, which in turn correspond to SubGeometries. SubMeshes allow different parts of the geometry to be assigned different materials.
                        //var cube:Mesh = new Mesh(newCubeGeometry, redColorMaterial);
                        //cube.x = 100;
                        //cube.y = 100;   
                        //cube.z = 100;
                        //scene.addChild(cube);
                        //var sphere:Mesh = new Mesh(newSphereGeometry, redColorMaterial);
                        //sphere.x = -75;
                        //sphere.y = -150;
                        //scene.addChild(sphere);
                        //var capsule:Mesh = new Mesh(newCapsuleGeometry, redColorMaterial);
                        //capsule.x = -200;
                        //capsule.y = -150
                        //scene.addChild(capsule);
                        //var cone:Mesh = new Mesh(newConeGeometry, redColorMaterial);
                        //cone.x = -200;
                        //cone.y = 150;
                        //cone.showBounds = true;
                        //scene.addChild(cone);
                        //var cylinder:Mesh = new Mesh(newCylinderGeometry, redColorMaterial);
                        //cylinder.x = -75;
                        //cylinder.y = 150;
                        //scene.addChild(cylinder);
                        //var plane:Mesh = new Mesh(newPlaneGeometry, redColorMaterial);
                        //plane.x = -75;
                        //plane.y = 275;
                        //scene.addChild(plane);
                        //var poligon:Mesh = new Mesh(newRegularPoligonGeometry, redColorMaterial);
                        //poligon.x = -275;
                        //poligon.y = 275;
                        //scene.addChild(poligon);
                        //var torus:Mesh = new Mesh(newTorusGeomentry, redColorMaterial);
                        //torus.x = -275;           
                        //scene.addChild(torus);
                        //SkyBox     A SkyBox class is used to render a sky in the scene.
                        //var skyBox:SkyBox = new SkyBox(skyBoxCubeTexture);
                        //scene.addChild(skyBox);
                        // SegmentSet
                            //WireframeAxesGrid - Class WireframeAxesGrid generates a grid of lines on a given planeWireframeAxesGrid
                            //var wireFrameAxesGrid:WireframeAxesGrid = new WireframeAxesGrid(4, 400, 1);
                            //scene.addChild(wireFrameAxesGrid);
                            //WireframeGrid     Class WireframeGrid generates a grid of lines on a given planeWireframeGrid
                            //var wireframeGrid:WireframeGrid = new WireframeGrid(10, 100, 5, 0x0000FF);
                            //wireframeGrid.x = 75;
                            //wireframeGrid.y = 275;
                            //scene.addChild(wireframeGrid);
                            //WireframePrimitiveBase
                                //WireframeCube    - Class WireFrameGrid generates a grid of lines on a given planeWireFrameGrid
                                //var wireFrameCube:WireframeCube = new WireframeCube(100, 100, 100, 0x0000FF, 5);
                                //wireFrameCube.x = 75;
                                //scene.addChild(wireFrameCube);
                                //WireframeSphere - Class WireFrameGrid generates a grid of lines on a given planeWireFrameGrid
                                //var wireFrameSphere:WireframeSphere = new WireframeSphere(50, 16, 12, 0x0000FF, 5);
                                //wireFrameSphere.x = 75;
                                //wireFrameSphere.y = -150;
                                //scene.addChild(wireFrameSphere);
                                //WireframePlane
                                //var wireframePlane:WireframePlane = new WireframePlane(100, 100, 10, 10, 0x0000FF, 5);
                                //wireframePlane.x = 175;
                                //wireframePlane.y = 275;
                                //scene.addChild(wireframePlane);
                 * Initialise the listeners
                private function initListeners():void {
                    addEventListener(Event.ENTER_FRAME, onEnterFrame);
                 * render loop
                private function onEnterFrame(event:Event):void {
                    view.render();
                 * Intialise the buttons events
                private function changeCube(event:MouseEvent):void {
                    var newCubeGeometry:CubeGeometry = new CubeGeometry(200, 200, 200, 50, 50, 50, true);
                    var cube:Mesh = new Mesh(newCubeGeometry, redColorMaterial);
                    cube.x = 100;
                    cube.y = 100;   
                    cube.z = 100;
                    scene.addChild(cube);
                    private function changeSphere(event:MouseEvent):void {   
                         var newSphereGeometry:SphereGeometry = new SphereGeometry(50, 16, 12, true);
                         var sphere:Mesh = new Mesh(newSphereGeometry, redColorMaterial);
                         scene.addChild(sphere);
                    private function changeCylinder(event:MouseEvent):void {   
                        var newCylinderGeometry:CylinderGeometry = new CylinderGeometry(50, 50, 100, 16, 1, true, true);
                        var cylinder:Mesh = new Mesh(newCylinderGeometry, redColorMaterial);
                        scene.addChild(cylinder);
                    private function changeTorus(event:MouseEvent):void {   
                        var newTorusGeomentry:TorusGeometry = new TorusGeometry(50, 50, 15, 8, true);
                        var torus:Mesh = new Mesh(newTorusGeomentry, redColorMaterial);
                        scene.addChild(torus);
                    private function changeWireframe(event:MouseEvent):void {   
                        var wireFrameCube:WireframeCube = new WireframeCube(100, 100, 100, 0x0000FF, 5);
                        scene.addChild(wireFrameCube);
    Thanks, Matthew

    Fraudulent seller.
    I received an empty package.- - 
    Back to the drawing board.
    Thanks for your replies.
    eBay is going through their required steps.
    It will take a week or better to get my refund.
    Thanks
    Shopping for another "Mac Pro Late 2013" or I might settle for my "Mac Mini 2012 i7 16 Gig 256 SSD Intel 4000" refurb with warranty bought from Apple that I already have on hand.
    Thank You
    I don't know how this ended upon two threads.
    I'm pretty sure I'm going to go with my 2012 Mac Mini i7 16 gig 256 SSD and Lacie Little Big Thunderbolt 1 512 SSD
    That will be pretty punchy for me.
    I'll only have about $1,000 in the computer itself with a three year Apple Care Warranty.
    It should sell for $500 a year from now if I choose too.
    I think it's going to work great.
    I'm going to load it up with all of the software just like I was going to do on the Mac Pro.
    It's good for three computers in the future so no money lost on the software
    I'll probably just keep the Mini indefinitely for a backup even after I upgrade to the newer 2015 Mac Pro later next year.
    Thanks

  • Where to put Validation Code?

    Up until now, Im still having second-thoughts of where to put validation code when setting attributes of an entity.
    Right now I have created lots of custom validators --(implement JbovalidatorInterface) that calls stored procedures to validate the value entered. But sometimes, i just use a ViewObject and query it on the setterAttribute method of the Entity and just manually throw a JboException of the value is invalid based on some business rule.
    Question is, what are the best practices where to put validation codes? do we have to be strict that we always put all validations on Validators or are we free to just throw JboExceptions anywhere on the BC classes' code.
    regards,
    Anton

    1. The reason I have a custom validator and I don't normally use the built in declarative validators is that the error message generated when the validation fails is fixed, only one message. I decided to have create a custom validator is that I need to test a one attribute for many cases in each case should produce a distinct error message. So if I use the built in validators, I would have to create lots of built in validators for that single attribute only. (and i have lots of entities and lots of attributes that needs business rule validation). So, I decided to create a custom validator, that calls the stored procedure, the stored procedure takes care of all test cases, for that attribute only, and I can return a dynamic error message depending on the test case that failed. What do you think about the approach?
    It's a little extra work to create a reusable validator class that will only be used once, but whether you do it that way or encapsulate the call in a helper class that your one-off method validator code delegates too, it seems similar to me. So it's more of a stylistic choice for you which you like better. Now, if your reusable validator were enable to encapsulate
    2. When I said anywhere; I meant inside the setterAttribute methods on the Entity and on the ViewRowImpl, orThe ViewImpl class or inside a method on an ApplicationModule?
    Rather than writing code in the setAttribute, I recommend using attribute-level method validators. This makes it more clear where all your validation code lives.
    I don't recommend performing validation in the view object level since entity objects are the component in the system that are tasked with handling validation. It would be easy to circumvent view level validation checks unless you make a lot of assumptions about exactly how your application is working.
    3. One other issue is that Validator methods are for validation purposes only. So its not a good idea to put in attribute setters to other attributes inside there. So you put the attribute setter logic outside of the validator usually inside the setAttribute() just after validator returns. But there are cases that is very straightfoward to put validation logic inside the setAttribute; meaning, inside the setAttribute() method, I test for a condition, if it fails, just throw a JboException, if its true, continue with the otherAttributes setter logic.
    Whether attribute setting of other attributes is performed in a setter method or in an attribute-level method validator, either way you will need conditional logic to avoid going into a validation "loop" (which eventually will throw an exception if after 10 attempts the object is still not valid at posting time.

  • Where to put .txt file with SimpleInput

    Hello everyone,
    I'm rather new to Java and have a slight problem. The thing is that I need to write an app that can read a text file in this format:
    2
    Orc
    name = Gnorck
    experience = 20
    maxHealthPoints = 50
    healthPoints = 30
    maxBerserk = 9
    berserk = 7
    Human
    name = Aragorn
    experience = 45
    maxHealthPoints = 40
    healthPoints = 30
    maxGreed = 20
    greed = 10
    The first number is de number of characters in the file and after that every character is described in 7 lines.
    Now the application has to be able to read the file. I've choosen to first just make a list of characters. A friend helped me with this code but I'm not completely sure if I know how it works. The code:
    package RPGApplicatie;
    import java.util.*;
    public class Karakters {
         //Constructor
         public Karakters(int size){
              karakters = new ArrayList(size);
         //Methode voor het toevoegen van een karakter
         public void voegToe(Karakter k){
              karakters.add(k);
         public static Karakters readFile(String filename) throws ClassNotFoundException, RuntimeException, InstantiationException, IllegalAccessException{
              SimpleInput file = new SimpleInput(filename);
              int size = file.nextInt();
              Karakters result = new Karakters(size);
              for(int i = 0; i < size ; i++) {
                   Class c = Class.forName(file.nextLine());
                   result.voegToe((Karakter)c.newInstance());
              return result;
         //Variabelen aanmaken
         private ArrayList<Karakter> karakters;
    }First question: I have the classes Karakter (which is the superclass for class Human and Orc), Human and Orc. So does the method forName scan for strings that are also classes? Like so it scans the file and when it comes across a line that says either 'Orc' or 'Human' it adds it to the list?
    Second question: Where to put the text file that holds the data? I now have it in the same folder called test.txt. I use this code to run it:
    package RPGApplicatie;
    public class RPGApplicatie {
         public static void main(String[] args) throws ClassNotFoundException, RuntimeException, InstantiationException, IllegalAccessException {
              Karakters.readFile("test.txt");
    }Thanks in advance! If more info is needed I can post that.
    Regards,
    Sander

    I assume you have defined your Human and Orc classes to include fields name, experience, etc and a constructor that takes these values as parameters?
    You can remove the Class.forName() method altogether. Example:
    int count = file.readInt();
    // define variables for Karakter values (name, experience etc.)
    for (int i = 0; i < count; i++)
      String characterClass = file.readLine();
      // read common character components
      if (characterClass.equals("Human")
        // read human specific components
        karakters.add(new Human(...));
      if (characterClass.equals("Orc")
        // create Orc
    //...Cheers

  • Where to put custom function at?

    Let's say I make a custom function, do I make it a CFC or a tag?
    Here is some sample code (I put in bold my function call)
    <cfif IsDefined("form.submit")>
        <cfset data.comment = Trim(HTMLEditFormat(form.comment))>
        <cfset data.name = Trim(REReplace(form.name, "[^A-Za-z0-9 ]", "", "all"))>
        <cfset data.location = Trim(CustomFunction(form.location))><!--- where to put it? as cfc or as a tag? --->
        <cfif data.comment NEQ "">       
            <cfif data.name EQ "">
                <cfset data.name = "Anonymous">
            </cfif>
            <cfinvoke
            component="guestbook.cfc.db"
            method="insert_comment">
            <cfinvokeargument name="form_data" value="#data#"/>
            </cfinvoke>
        <cfelse>
            <cfset message="Comment is required!">
        </cfif>
    </cfif>

    Custom tags are different than udfs.  Let's stick with udfs.  Your location choices are:
    1.  If only one template is going to use it, you can put it in that template.  Otherwise,
    2. You can put it in a .cfm file and cfinclude that file whenever you want to call the function, or
    3. You can put it into a .cfc.
    A little while back, someone ran some tests and posted the results on one of these forums.  The gist of it was that Option 2 would run faster than Option 3.

  • Where to put my customized formatting that Control Hints does not provide?

    To whom that know or have experience with it:
    The control hints does not provide solutions for all possible formatting needs. For example, I need to display only last four digits of social security numbers (i.e., for "123-45-6789", display "***-**-6789"). Another data table column stores school semesters as YYYYMM, e.g., 200902, where 2009 is the year and 02 is the month that represents Spring (MM can also be 06 and 09 that represent Summer and Fall). I need to display the semester in a more user-friendly way (i.e., for "200902", display "Spring 2009"). Of course, I can not change data format in the table; I only seek to format the display of the data.
    I would think that it takes only a few lines of java code to do these formatting by splitting the string into sub-strings, replace some of them with appropriate new values, then re-assemble them. But where to put such code? Does any documentation cover this topic?
    Newman

    Shay,
    I read the document, tried it, and it worked out nicely.
    There is not the getAttributeName() method in the ViewObjectImpl class in version 10.1.3.4, which is the version I am using. But the EO class has it and it works out all the same.
    I don't know how long it would otherwise take me to read and fumble to find out where to put the custom formatting code. Your experience and familiarity with the technology really saved me a huge amount of time. Thank you so much for your help!
    Newman

  • What is the difference between on new focus and do prepare out put methods

    Hi,
    what is the difference between on new focus and do prepare out put methods.

    Hi Divya,
    DO_PREPARE_OUTPUT method is triggered each time the view is prepared after each event. Normally we redefine this method in order default the initial values based upon the parameter iv_first_time = 'X'. There can be certain other scenarios like putting data validations where this method can be helpful.
    For details on ON_NEW_FOCUS, refer to this [thread|on_new_focus event;
    Thanks
    Vishal

  • Where i Put my swing application jar file in jboss

    Hi experts...
    I develope swing application and convert it into jar file....I know jnlp deployment using tomcat..In tomcat i
    put my appcation.jar in webapps/root folder...This is not similar in jboss..I dont know where i put my applcation.jar in jboss.If any body know the idea please let me know..

    Hi
    You have to put your jar file in
    server/default/deploy
    Regards
    M Fazal Ur Rehman

  • I changed my iPhone lately but i can't restore my last backup since it keeps saying "itunes could not restore backup because the password was incorrect" but I don't know where to put the password to make it happen... Any suggestions?

    Hey guys,
    I just bought a new iPhone but i can't restore my backup files beacuse it keeps saying "itunes could not restore backup because the password was incorrect" but I really don't know where to put the password to restore it. I really have some files that are meaningful for me so I really need help. Any suggestions anyone?

    Select your iDevice in the iTunes.
    Choose the Summary screen (tab) and scroll to the bottom of the screen.
    Then un-select Encrypt iPhone backup.
    iTunes will then prompt you to “Enter the password to unlock your iPhone backup”, enter the password you set originally.

Maybe you are looking for

  • No sound on YouTube videos and others

    I have read through other discussions so I am prepared! I am using Windows XP Prof. PC 32 bit. Hello! I did the checking with the Adobe / Forum website - as to what version I am using in Flash: I was able to get animation - NO Sound I copied this inf

  • New Macbook Air 11" 2014 Model Display Hinge Loose and exacerbated by extremely poor service

    I have bought a new MacBook Air 11 from Ezone on the 3rd of October.  When I opened the product, I realised that the hinge seemed to be loose and would fall back on its own when tilted. That's when my troubles started. I went to the Maple Apple Autho

  • Dynamic Form Help Needed !!

    Hi Guys, I need a form that has the following how do i code it in dreamweaver ? name : email address : phone number : status: item are New, Contacted, Appointment Scheduled, Sold ( This would be a dropdown and depending on what the user chooses the o

  • Host Adapter DOCUMENT_WRITE_PREPROCESS Event, not enough time

    Dear all I want to do some stuff before the document saves. I use the Host Adapter with Illustrator When I register a handler: AIEventAdapter.getInstance().addEventListener(AIEvent.DOCUMENT_WRITE_PREPROCESS,handler); the function gets called when sav

  • Nef to raw? help!

    Hallo! I own a Nikon D3100, when I take photos in Nikon's raw format, it produces .NEF files. I would like to open them with photoshop cs4, on which I've put a camera raw plug in 5.7 I tried many many things and it the end I discovered that the plug