Best name to class that Do something....

Hello !
I have a doubt about naming Java classes that do something..
Example: I have a class that calculate an range of year available to generate an report. This class return a list with Last 5 years from 2011... ex: in 2013 the list will return 2012, 2011 etc...
How can i naming this class?? Its consufing because in the naming conventions it must be an name and not a verb.
Thanks !

PaulH wrote:
Example: I have a class that calculate an range of year available to generate an report. This class return a list with Last 5 years from 2011... ex: in 2013 the list will return 2012, 2011 etc...Is that all the class does? It just has that one method? And the method does nothing more than create a list of Integers corresponding to the last 5 years? If so, then I would probably not create a whole class just for that. And if that's not all it does, then it's hard to suggest a name without knowing more about what it really does.
However, its name should come from a word or phrase that summarizes it responsibilities. The name ReportHelper that was already suggested may be appropriate, or perhaps ReportUtil. On the other hand, if the class isn't specifically just for reports, but does a handful of common tasks that deal with times and dates and calendars that could be used elsewhere in your app, then perhaps TimeUtil, or CalendarHelper would be appropriate. Or, if it is just the one method, then maybe that method should be moved to a ReportGenerator class, where calculating the list of years is one step in the task or generating a report.

Similar Messages

  • Pass variable name to class that modifies it

    in my main fla:
    import Preloader;
    var prel:Preloader = new Preloader();
    var toPass=9;
    prel.loads(this,stage,"toPass",2);
    in my Preloader.as:
    package  {
              import flash.display.Sprite;
              import flash.display.Stage;
              import flash.events.Event;
         public class Preloader extends Sprite {
              private var stageRef:Stage;
              private var mainTimeLineRef:*;
              public function loads(a,b,c,d):void{
                   this[c]=d
    I want to pass the toPass var to my class that has to edit that, how can i do?  (i know that i could simply write toPass = d)

    i'm not sure what you're trying to do but to pass a variable's value, use:
    framode wrote:
    in my main fla:
    import Preloader;
    var prel:Preloader = new Preloader();
    var toPass:int=9;
    prel.loads(stage,toPass);
    in my Preloader.as:
    package  {
              import flash.display.Sprite;
              import flash.display.Stage;
              import flash.events.Event;
         public class Preloader extends Sprite {
              private var stageRef:Stage;
              private var mainTimeLineRef:*;
    private var toPassRef:int;
              public function loads(a:Stage,b:int):void{
    stageRef=a;
                 toPassRef=b;

  • How to get name of class that the JVM was started with ?

    Assume I have class foo with the standard main method.
    I also have classes ding and dong, they extend foo.
    The JVM is started with either ding or dong as the 'main' class. Since neither ding nor dong directly implement main, the actual main method being executed is foo's.
    In the main method of foo I want to construct an instance of either ding or dong, depending on which the JVM was started with. Since I'm in a static context, I can't do anything with 'this'. Is there another way to get the name of the 'main' class from the JVM so that I can construct an instance of it ?

    The idea behind all of this is that the developer of
    Ding and Dong should not have to know anything about
    foo, in particular it's constructors. But if Ding and Dong are subclasses of Foo, then developers must know about Foo. If you expect developers to extend a framework without having a well-defined interface to that framework, you are probably heading for trouble.
    To be able to
    privatize the constructors, construction of the
    concrete class has to take place in foo.If Ding and Dong are subclasses of Foo, then you can not make all of Foo's constructors private.
    Of course I could have a method in Ding and Dong that
    calls a static method in foo into which the Ding and
    Dong instance pass their class, but then I'd have
    identical implementations of this method in Ding and
    Dong. Yes you would (well, not identical, but very similar). Like I said, you could do this programmatically with AOP, or you could probably do it dirtily using stack traces (though with it being a single hit at startup, you might not consider it being quite so dirty).
    But: the point of inheritance is that common
    functionality goes into superclasses. I disagree. The important thing about inheritance is that classes share an interface, and that methods can be polymorphically inherited, allowing new functionality to be 'plugged in' in the future, and even at runtime.
    Also, in
    general one wouldn't make methods static if a class
    reference is needed (or one would make it an
    argument), but Sun didn't consult me when they
    designed the main method :-(I still don't see why you need to do what you want to do. It appears that all you are after is the ability to start your program using a command line like
        java com.mypackage.Ding
    instead of
        java com.mypackage.Foo com.mypackage.Ding
    or
        java com.mypackage.Foo Ding.properties
    or something else along these lines.
    Since you must know the name of the class you want to use at the time you want to use it, why can't you just pass the name as an argument, or start up using some properties file, or a shell script?

  • I have a file that is something I recorded on my camcorder.  I am trying to open it and it keeps saying that a required codec isn't available.  This is the name of the file. M2U00001.MPG.  What can i do to get it to play.

    I have a file that is something I recorded on my camcorder.  I am trying to open it and it keeps saying that a required codec isn't available.  This is the name of the file. M2U00001.MPG.  What can i do to get it to play.

    The info in this thread should help you - https://discussions.apple.com/thread/3648239?start=0&tstart=0 

  • Add HW Inventory class that does not exist in a default inventoried class

    Hello all, 
    I am trying to find a way to create a new class to supersede the win32_logicaldisk class. We are looking to add the VolumeDirty flag since it does not exist in the current SMS_logicaldisk class. However I cant seem to find a good way to do this. Has anyone
    done something like this before? Adding new classes doesn't seem to be difficult, but since this is a default WMI class that is being inventoried, I don't want to make any modifications to it as I know I will regret it down the road. I was thinking maybe creating
    a configuration item and inventorying it that way? Thoughts? Or is this even possible? Thanks in advance! 
    Scott

    I do similar things--create a new I-Made-It-Up class to pull in something that the default doesn't.  I understand and agree with not modifying default classes--it perhaps would never be a problem--but if (perhaps maybe) some future upgrade or cumulative
    update failed to install because you modified a default class, it could be a sad sad day.  :)
    If you want me to just write the mof edit for you, let me know.  Otherwise for a sample of how to do that; look at the mof edits for 'making up my own' SQL inventory:
    http://mnscug.org/blogs/sherry-kissinger/328-installed-sql05-sql08-sql12-sql14-version-information-via-configmgr-hardware-inventory
    Essentially, you make up a configuration.mof edit; making a 'copy of' what you really want out of win32_logicaldisk, but you dump it into a cm_scott_x_awesomeness  (or whatever you want to call it), and you put that at the bottom of configuration.mof
    on your server.
    Then your to-be-imported.mof into default client, hardware inventory, classes... import (if you're old skool, the sms_def.mof piece of it) will be a .mof file to inventory cm_scott_x_awesomeness
    Just be careful to name what you really want to see in v_gs_NameThatView inside the quotes SMS_Group_Name and SMS_Class_ID.  You'll be living with that table and view name forever, so maybe, perhaps, calling it Scott_X_Awesomeness just might not be
    the best name ever (although it sounds great right now, at review time w/the boss maybe not so much).
    Standardize. Simplify. Automate.

  • MouseMotion on a class that's not an extended Component

    Hi, i'm trying to make a class that has the addMouseMotion(MouseEvent e) on it, but i can't make it work, this class has nothing to do with the class componet so i can't use it.
    I saw some people's code using a Vector of MouseMotionListener and implementing MouseMotion interface but i don't seem to make it work. Can someone help me out?
    Here's the code:
    class Whatever implements MouseMotionListener
    Vector motionListeners = new Vector();
    public void addMouseMotionListener(MouseMotionListener l)
    motionListeners.add(l);
    public boolean removeMouseMotionListener(MouseMotionListener l)
    return motionListeners.remove(l);
    public void mouseMove(MouseEvent e)
    Enumeration e = motionListeners.elements();
    ((MouseMotionListener)e.nextElement()).mouseMove(e);
    public void mouseDrag(MouseEvent e)
    Enumeration e = motionListeners.elements();
    ((MouseMotionListener)e.nextElement()).mouseDrag(e);

    From Enumeration javadoc:
    NOTE: The functionality of this interface is duplicated by the Iterator interface. In addition, Iterator adds an optional remove operation, and has shorter method names. New implementations should consider using Iterator in preference to Enumeration.
    From Iterator javadoc:
    An iterator over a collection. Iterator takes the place of Enumeration in the Java collections framework. Iterators differ from enumerations in two ways:
    * Iterators allow the caller to remove elements from the underlying collection during the iteration with well-defined semantics.
    * Method names have been improved.
    The best thing you could do is to debug you app, either with System outputs or by using a debugger. E.g. there's a gui debugger integrated in JBuilder and propably in Forte, too.
    Then you can step through your program.
    Otherwise I needed more code relevant to this problem (where do you register an object of this class to a MouseMotion source? Where do you register other MouseMotionListeners to this object?).
    Greets
    Puce

  • Portlets development: When to use the class that extends PortletBridge...

    When I create some Portlet (.jspx based) JDeveloper generate some resources. One of those is a class (with the name that I´ve configured) that extends PortletBridge...
    Ok. So, I want to know if I use JSF standards should I put my actions into this class or should I create another Managed bean to handle that? What to do with this generated class?
    Thank you.

    So you want to create a portlet that uses JSF instead of JSP?
    You can JDev do that for you. When you create a new portlet there is a step where you can specify the default page for the portlet mode (view, edit).
    On the right hand side you can select ADF JSF (or something like that).
    JDev will then create a class that extends the PortletBridge class and you don't have to do anything more. Just edit the jspx like it's a normal page.

  • How to call a class that extends a frame from a panel ?

    How to call a class that extends a frame from a panel ?
    I am trying to create an application say "Videoshow"
    Videoshow has a panel which in turn consists of 2 components : 1]a textarea( to show the contents of a page) and 2] a mediaclip(to show the video).
    Now I have an application "MediaApplication"(to show the videoclip) which extends Frame (Code from Java 2 Unleashed, Chap 21). I want to show this MediaApplication in Component 2 of the above panel. But when I do this, I only see the MediaApplication frame instead of the whole SlideShow.
    I want to do something likethis.
    VideoShow :
    |---------------------------------|-------------------|
    | |
    | (Comp 1) | (Comp 2)
    | TEXTAREA | Video Clip
    | |(MediaApp entends Frame)
    |---------------------------------|-------------------|
    What is the best way to achieve this ? Also which component can I use to show the videoclip ?

    im not familiar with the code you mention from Java 2 Unleashed, but your best bet is to read up on Swing a bit - so you get an idea of how Swing containers and components work - then im sure you'll find a solution to your problems. Then if you encounter any difficulties whilst your attempting to do that, post your code in the Swing forum and im sure someone will help you.

  • Show the class that is loading

    Hi i have an applet that take a lot of classes to load and i have a splash screen that display the user a little image with a JProgressBar with the setIndeterminate() to true. For this i don't care, but what i want is to do like acrobat software that display all plugin that is loading. So when the splashscreen start i want it to display all classes that is loading at the moment the jre load it.
    Is there a dynamic way? Cause i know i can use
    Class thatClass = Class.forName("TheClassToLoad");
    theObject = thatClass.newInstance();
    but each time i will have to add a new class i will add to add these line... so i want something that will know which classes the java runtime is loading and display the name to the user
    thx

    maybe this could help
    it's a class i had to load the applet, that give me the possibility to start my splash screen before the user dl all my big applet
    import javax.swing.JApplet;
    import java.applet.AppletStub;
    import java.awt.Graphics;
    import java.awt.GridLayout;
    import javax.swing.JLabel;
    import javax.swing.JEditorPane;
    public class QuickLoader extends JApplet implements Runnable, AppletStub
        String appletToLoad;
        JLabel label;
        Thread appletThread;
        public void init()
            appletToLoad = getParameter("applet");
            if (appletToLoad == null)
                label = new JLabel("No applet to load.");
            else
                label = new JLabel("Please wait - loading applet " + appletToLoad);
            getContentPane().add(label);
        public void run()
            if (appletToLoad == null)
                return;
            try
                // Get the class for the applet we want
                Class appletClass = Class.forName(appletToLoad);
                // Create an instance of the applet
                JApplet realJApplet = (JApplet)appletClass.newInstance();
                // Set the applet's stub - this will allow the real applet to use
                // this applet's document base, code base, and applet context.
                realJApplet.setStub(this);
                // Remove the old message and put the applet up
                getContentPane().remove(label);
                // The grid layout maximizes the components to fill the screen area
                // - you want the real applet to be maximized to our size.
                getContentPane().setLayout(new GridLayout(1, 0));
                // Add the real applet as a child component
                getContentPane().add(realJApplet);
                // Crank up the real applet
                realJApplet.init();
                realJApplet.start();
            catch (Exception e)
                // If we got an error anywhere, print it
                label.setText("Error loading applet.");
            // Make sure the screen layout is redrawn
            getContentPane().validate();
        public void start()
              appletThread = new Thread(this);
              appletThread.start();
        public void stop()
              appletThread.interrupt();
              appletThread = null;
        // appletResize is the one method in the JAppletStub interface that
        // isn't in the JApplet class. You can use the applet resize
        // method and hope it works.
        public void appletResize(int width, int height)
              resize(width, height);
    }bu i don't know how to integrate your code to load all my classes correctly and be able to display the name of the class that are loading
    thx for help

  • What's the best way to detect that text fits into ContainerControllers without scrolling?

    Hi.
    Question
    What's the best way to detect that text typed by user (or added programmatically) exceeds available container space and find out where starts truncated part? Is there available some other (than described bellow) easy way to detect it or disallow set of controllers to receive more characters that can be displayed in given composition area?
    My partialy failed attempt (simplified)
    For example lets say that I've got an editable textflow with attached two instances of ContainerController.
    var flow:TextFlow = createSomeFlowFromGivenString(sampleText),
        firstController = new ContainerController(firstSprite, 100, 30),
        lastController = new ContainerController(secondSprite, 600, 30);
    flow.interactionManager = new EditManager(new UndoManager());
    flow.flowComposer.addController(firstController);
    flow.flowComposer.addController(lastController);
    flow.flowComposer.updateAllControllers();
    With enabled vertical scroll policy I can compare height of the composition in last controller with height of the content:
    var bounds:Rectangle = lastController.getContentBounds(),
        overflow:Boolean =  lastController.compositionHeight < bounds.height;
    trace('Content does not fit into given area?', overflow)
    But when I switch vertical scroll policy off (lastController.verticalScrollPolicy = ScrollPolicy.OFF) - unfortunately this no longer works...(In my case scrolling should be dissabled, since text areas might have only one line with restricted width)
    Use case
    I want to create fillable form. Field might have a single or multiple lines. One field might start in the middle of the page, continue in the next line where it spreads through whole page and end in the - quarter of page width long  - third line. Text typed by the user can't exceed given area since it might cover some static text that sits right after/below field.
    Something like ascii image bellow:
    |                <PAGE>                    |
    |                                          |
    |                                          |
    |                                          |
    |               [Field starts here........ | 
    | ........................................ |
    | ........................................ |
    | Ends here..]                             |
    |                                          |
    |                                          |
    | [Another field] xxxx  xxxx xxxxxxxx x xx |
    | xxxxxxxxxxxxxxxxxxx                      |
    |                                          |
    |                              [One more.. |
    | .....]                                   |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    Info:
    [......]  <-- form fields starts with '[' character, and ends with ']'
    xxx       <-- sample, static text
    | and _   <-- page borders

    I've tried something like that previously, but it didn't work because then I've got vertical scroll policy to set to 'auto'. After changing verticalScrollPolicy to ScrollPolicy.OFF  in the last container it worked like a charm.
    Thanks zhen bian

  • Best practice for class and constructors

    I'm writing a small utility class that has a private member that is a List. I'm troubled when I think about where this List should be created - in the declaration of the reference or in the default constructor - thus having all other constructors call the default.
    Should I have:
    public Class Foo() {
        private List myList = new ArrayList();
      public Foo() {
      public Foo(String myFoo) {
      public Foo(String[] myFoo) {
      // more methods....
    }or would it be better to code it as:
    public Class Foo() {
        private List myList;
      public Foo() {
        myList = new ArrayList();
      public Foo(String myFoo) {
        foo();
       // other stuff
      public Foo(String[] myFoo) {
        foo();
       // other stuff
      // more methods....
    }In the first option, I know from putting a watch on myList that it stays undefined until any one of the constructors in called. This would seem to me to be the best approach as it doesn't require future additional constructors to have to be written to specifically call the default constructor just to get the ArrayList created. What's typically done in this situation? Which one is considered "good form" or is there a better way?

    I'm writing a small utility class that has a private
    member that is a List. I'm troubled when I think
    about where this List should be created - in the
    declaration of the reference or in the default
    constructor - thus having all other constructors call
    the default.It's not done this way - you have to call this().
    I think the better solution is to have the creation and initialization of the List in the most specific constructor, and have the default call that:
    public class Foo
        private List myList;
        public Foo()
            this(Collections.EMPTY_LIST);
        public Foo(List newList)
            this.myList = new ArrayList(newList);
    }%

  • Error in File name or class name not found during Automation operation: 'CreateObj​ect'

    Hello Team,
    When I am trying to execute the below code i am getting the following error. Any help would be greatly appreciated.
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    If Not oFSO.FolderExists(SavePath) Then
    Set f = oFSO.CreateFolder(SavePath)
    Else
    End If
    53 4/11/2014 12:27:22 PM Error:
    Error in <NoName(4).VBS> (Line: 9, Column: 1):
    File name or class name not found during Automation operation: 'CreateObject'
    I have googled through the error and tried to re-register the scrrun.dll using regsvr32 eventhogh it is successfully registered, i am getting the following error. My PC is windows 7 32bit OS.
    any help is greatly appreciated.

    The following script class will write a log file entry. See if it will run for you.
    The script is using a class object that you might not have seen before. A little intro:  The top section is just for testing the class. Normally I just comment this out after the class is working well.  It should run right way. I would save the vbs file in the editor, That way when you are using autoactpath or currentscriptpath variables they will be able resolve the paths.
    Paul
    Attachments:
    LoggingCode_V2.VBS ‏5 KB

  • I just got an iTouch and whenever I try to sync it to iTunes it keeps poping up with a message that says something like "cannot sync or read file". What should I do?

    I just got an iTouch and whenever I try to sync it to iTunes it keeps poping up with a message that says something like "cannot sync or read file". What should I do?

    Is the error message:
    "Attempting to copy to the disk <iPod name> failed. The disk could not be read from or written to."
    if it is try:
    http://support.apple.com/kb/HT1207
    If not, what is the wording?

  • Why java file name and class name are equal

    could u explain why java file name and class name are equal in java

    The relevant section of the JLS (?7.6):
    When packages are stored in a file system (?7.2.1), the host system may choose to enforce the restriction that it is a compile-time error if a type is not found in a file under a name composed of the type name plus an extension (such as .java or .jav) if either of the following is true:
    * The type is referred to by code in other compilation units of the package in which the type is declared.
    * The type is declared public (and therefore is potentially accessible from code in other packages).
    This restriction implies that there must be at most one such type per compilation unit. This restriction makes it easy for a compiler for the Java programming language or an implementation of the Java virtual machine to find a named class within a package; for example, the source code for a public type wet.sprocket.Toad would be found in a file Toad.java in the directory wet/sprocket, and the corresponding object code would be found in the file Toad.class in the same directory.
    When packages are stored in a database (?7.2.2), the host system must not impose such restrictions. In practice, many programmers choose to put each class or interface type in its own compilation unit, whether or not it is public or is referred to by code in other compilation units.

  • Is that possible to add a listener to a class that bind with a image?

    Hello, I am trying to add listener to a class that binds with image.  For example, I want to add listener to customDividerSkin(see example below, i bold and underline the text), so when user click the customdividerSkin image haloGreen box will be hided. Thanks,
    <?xml version="1.0" encoding="utf-8"?>
    <!-- http://blog.flexexamples.com/2008/09/18/customizing-the-divider-skin-on-a-dividedbox-conta iner-in-flex/ -->
    <mx:Application name="HDividedBox_dividerSkin_test"
    xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="vertical"
    verticalAlign="middle"
    backgroundColor="white"
    initialize="init();">
    <mx:Script>
    <![CDATA[
    [Embed("arrowLeft.png")]
    private const customDividerSkin:Class;
    private function init():void
    dividedBox.setStyle("dividerSkin", customDividerSkin);
    ]]>
    </mx:Script>
    <mx:HDividedBox id="dividedBox"
    horizontalGap="24"
    width="100%"
    height="100%">
    <mx:ViewStack id="AddFormViewStack"
      width="100%"
      height="100%">
    <mx:Box id="box1"
    backgroundColor="haloGreen"
    width="100%"
    height="100%"
    minWidth="100"/>
    <mx:Box id="box2"
    backgroundColor="haloBlue"
    width="100%"
    height="100%"
    minWidth="100"/>
    </mx:ViewStack>
    </mx:HDividedBox>
    </mx:Application>

    Set the class as the source for an mx:Image and set the listener to the  Image

Maybe you are looking for