using methods of the builders class?

I have a constructor that is quite complicated to ask my calling methods.
I'm not sure whether to make these static methods.

example #1
class {Test}
Object obj;

Test() {}
....
Initialize (this);
....
}

public static private Sub initialize (Test t) {}
t.obj = new Object();
doThis (t);
doThat (t);
}

static private void doThis (t-Test) {...}
static private void doThat (t-Test) {...}
}
-----
example #2
class {Test}
Object obj;

Test() {}
....
Initialize();
....
}

private void initialize() {}
obj = new Object();
}

private void doThis() {...}
private void doThat() {...}
}
-----
I understand the danger of use override-able for initialization methods, so take all the initialization methods are private.

Directors of oriented programming OBJECT (as I understand them) suggest that instance methods are used to change the State of an object.
Surely, the initialization changes the State of an object (forming / future).
Yet, for some reason any when I call methods in constructors, I feel that these methods must be static.
What is the right way of thinking?

827723 wrote:
Yet, for some reason any when I call methods in constructors, I feel that these methods must be static.

Why?

A static method belongs to the class and not any instance of this class. Make a method to initialize a static object is contrary to this principle. If you are already inside the class object / what possible benefit can you get pass a reference to itself between all your methods?

Here is another alternative, a block to initialize.

class Test {
    {
        obj = new Object();
    }

    Object obj;

    Test() {
        // obj already initialised, no need to do anything here
        // other code
    }
}

Tags: Java

Similar Questions

  • To access the methods of the VORowImpl class

    Scenario is,

    I have a view object class VOImpl.java in the model.view package.

    I have another class of JavaBean EntryHandle.java

    EntryHandle class I can Import model.view.VOImpl;

    Help me now how I can access methods of the VOImpl class in the ADF.

    Or I have to create the VOImpl object class in class EntryHandle? as in programming java Simple? or something else

    JDeveloper Version: 11g Release 2 11.1.2.0.0

    Zaid,

    If you have a VO with 2 attributes, you have defined the category value. (This poster Lov sense and sets the value for the category field).

    You want to get the value selected from the lov. Is this correct?

    When do you get this value? When they choose a new value from the LOV.

    If you have written the code in the valueChangeListener, you can check the link below:

    https://blogs.Oracle.com/ADF/entry/getting_selected_value_from_selectonechoice

    Code of the blog

    public void valueChanged(ValueChangeEvent valueChangeEvent) {
        this.setValueToEL("#{bindings.Deptno.inputValue}", valueChangeEvent.getNewValue()); //Updates the model
        System.out.println("\n******** Selected Value: "+resolveExpression("#{bindings.Deptno.attributeValue}"));
        System.out.println("\n******** Display Value: "+resolveExpression("#{bindings.Deptno.selectedValue ne ' ' ? bindings.Deptno.selectedValue.attributeValues[1] : ''}"));
    }
    
    public Object resolveExpression(String el) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ELContext elContext = facesContext.getELContext();
        ExpressionFactory expressionFactory =  facesContext.getApplication().getExpressionFactory();
        ValueExpression valueExp = expressionFactory.createValueExpression(elContext,el,Object.class);
        return valueExp.getValue(elContext);
    }
    
    public void setValueToEL(String el, Object val) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ELContext elContext = facesContext.getELContext();
        ExpressionFactory expressionFactory =   facesContext.getApplication().getExpressionFactory();
        ValueExpression exp = expressionFactory.createValueExpression(elContext, el, Object.class);
        exp.setValue(elContext, val);
    }
    

    You can get the selected value and the value of display with the above code. You need to replace Deptno by category.

    See you soon

    AJ

  • What is the method of the String class's trim() in special cases?

    You are looking for here ( String (Java Platform SE 7) ), I understand that the method of the String class's trim() 'returns a copy of the string with white spaces of early and omitted end', but I don't understand what the last special case Unicode characters is exactly.

    You are looking for here ( list of characters Unicode - Wikipedia, the free encyclopedia ), I see that U + 0020 is a space character, and I also see the characters that follow the character space (for example, the exclamation point character).

    So, I decided to write a sample of the size of the code to try to reproduce the behavior that I quoted (from the documentation of the API of the trim method) in the comment from several line of this code even example. Here is the code example. :

    public class TrimTester {
    
        public static void main(String[] args) {
           
            /*
             * "Otherwise, let k be the index of the first character in the string whose code
             * is greater than '\u0020', and let m be the index of the last character in the
             * string whose code is greater than '\u0020'. A new String object is created,
             * representing the substring of this string that begins with the character at
             * index k and ends with the character at index m-that is, the result of
             * this.substring(k, m+1)."
             */
            String str = "aa!Hello$bb";
            System.out.println(str.trim());
        }
    }
    

    However, what is printed is "aa." «Hello bb$ "(without the quotes) instead of «!» "Hello$" (without the quotes).

    Any input to help me better understand what's happening would be greatly appreciated!

    Hallo,

    I think that the characters 'a' and 'b' both have greater than '\u0020' code, so your entire string is returned by the trim () - method, then the first character of the string whose code is superior to ' \u0020 has index 0, and the last character whose code is greater than '\u0020' a index 10. All printable characters have codes greater than 0020, try "\r\ntest". After trim(), you get 'test '.

    Regarding

    Rafal Z

  • How to use getDBTransaction() in the controller class

    I use the code below.

    OADBTransaction tx = (OADBTransaction) getDBTransaction ();
    java.sql.Connection pConncection = tx.getJdbcConnection ();
    ConcurrentRequest cr = new ConcurrentRequest (pConncection);


    But receiver error not found getDBTransaction method in the cust.oracle.apps.pos.changeorder.webui.extendViewOrderPGCO class below

    Should I extend AM and use this code in AM or can I use this code in extended controller.

    Thanks for your help.
    HP.

    OADBTransaction tx = (OADBTransaction) getDBTransaction ();
    java.sql.Connection pConncection = tx.getJdbcConnection ();
    ConcurrentRequest cr = new ConcurrentRequest (pConncection);

    Connection conn = (Connection)oapagecontext.getApplicationModule(oawebbean).getOADBTransaction().getJdbcConnection();
    ConcurrentRequest cr = new ConcurrentRequest(conn);
    

    http://oracleanil.blogspot.com/2009/04/itemqueryvoxml.html

    Thank you
    -Anil
    http://oracleanil.blogspot.com

  • Impossible to replace "initialize" method on the Application class

    Hi all

    Compilation of the following:

    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                   xmlns:s="library://ns.adobe.com/flex/spark" 
                   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:local="*">    
        <fx:Script>
            <![CDATA[
                override public function initialize():void {                
                    super.initialize();
                }
            ]]>
        </fx:Script>    
    </s:Application>
    
     
     
     
    

    Returns an error:

    Test_Initialize.mxml 1021: duplicate function definition. /Test_Initialize/src line 7 Flex problem

    The compiler bug?

    I think the ActionScript class generated by the compiler to your MXML file has its own surrogate autogenerated initialize(). You can check it using the - keep option. I do remember not what does the initialize() generated automatically, but - keep will show you.

    Assuming I'm right, I agree that it is a bad thing for the compiler to, so you should file a bug.

    Gordon Smith

    Adobe Flex SDK team

  • you have makeContextMenu() method in the field class?

    Hi all
    I use the BlackBerry Plugin on Eclipse.
    I have installed BlackBerry by JRE 5.0.0 project.

    I used the class field on my program. But I can't use certain methods in this class, for example makeContextMenu() method.

    I try to develop 5.0.0 JRE packages on the left side of the window of the Eclipse and I found the net.rim.device.api.ui.Field class. I see all the methods in this class, but there is a method is "YELLOW" and these methods cannot use in my program.

    Can you help me to solve this problem, thanks a lot!

    You must override the method, do not call it directly.  You can see an example of its use in the example here:

    http://supportforums.BlackBerry.com/T5/Java-development/create-a-scrollable-image-field/TA-p/444955

  • reading viewScope variable in the method of the ViewImpl class

    Hello

    Suppose I want to get viewScope.deptno in my function that is declared in the class ViewImpl

    ' Public Sub proc (String deptno, String amount) {}
    setp_deptno (deptno == null? ('%': deptno);
    this.setNamedWhereClauseParam ("p_deptno", deptno);
    this.executeQuery ();
    System.out.println("viewScope.DEPTNO="...?);
    }

    How to get to it in my service?
    do you mean placing the logics from VOImpl to client interface class?
    

    Yes, then you can see the method exposed in the control of data under the node ViewObject. Then, you can run the method in your method of beans as below

        public String executeMyVOMethod {
            BindingContainer bindings = getBindings();
            OperationBinding operationBinding = bindings.getOperationBinding("proc");
            operationBinding.getParamsMap().put("deptno", PassAnyDeptNo);//you can get it from view scop variable
            operationBinding.getParamsMap().put("amount", passAnyAmmountvalue);  //you can get it from view scop variable
            Object result = operationBinding.execute();
            if (!operationBinding.getErrors().isEmpty()) {
                return null;
            }
            return null;
        }
    

    could you clarify why this is a bad practice to store the logic in VOImpl?
    is it because I can't refer to ViewScope of there?
    >

    access a range of memory variable in your model layer (if its there) is a bad practice, because you're breaking MVC model. This is not the best approach, even if you can do it.

    >
    (this approach is based on video tutorial of Shay "Passing parameters to the ADF through the URL of the Application")
    >
    It's different, it's not your use case

  • Import excel should allow space in a column during the use of media: the value class coldfusion.sql.QueryColumn can not be converted to a date

    I followed the pretty good learncfinaweek and can see no error in my code.   Here is the error, that should solve and the page with the code.  Any help is appreciated.  This should be quite simply like this: < cfset blogPost.dateposted = importData ["posted Date"] / >, which allows the column in excel with a space between words.

    Good: dateposted - the coldfusion.sql.QueryColumn class value cannot be converted to a date.

    Root cause: org.hibernate.HibernateException: property: dateposted - the coldfusion.sql.QueryColumn class value cannot be converted to a date



    "< cfimport taglib ="... /... "/ customTags" prefix = "ct" / >

    < ct:securityCheck redirectPage = "#cgi.script_name #" / >

    < name = "cfparam form.submitted" default = "0" / > "

    "< name =" cfparam form.importFile"default =" "/ >

    < cfif form.submitted >

    <! - Download file - >

    < cffile action = "upload" destination = "#getTempDirectory ()" # "filefield ="importFile"nameconflict ="makeunique"/ >"

    <!--> reading spreadsheet

    "< cfspreadsheet action = 'read' src="#cffile.serverDirectory#/#cffile.serverfile# ' query = headerrow "importData" = "1" excludeheaderrow = "true" / >

    <!--> Import data

    < cfloop query = "importData" >

    < cfset blogPost = entityNew ('blogPost') / >

    < cfset blogPost.title = importData.title / >

    < cfset blogPost.summary = importData.summary / >

    < cfset blogPost.body = importData.body / >

    < cfset blogPost.dateposted = importData ["posted Date"] / >

    < cfset EntitySave (blogPost) / >

    < / cfloop >

    < cfset ormFlush() / >

    < cflocation url = "listblogpost.cfm? message = #urlencodedformat ('Blog Posts Imported Successfully')" # "addtoken ="false"/ >"

    < / cfif >

    < cfoutput >

    < section ct:layout = "Summary" >

    < section = 'blog' active 'post' = ct:navigation / >

    < div class = "span10" >

    The Blog posts to download < h2 > < / h2 >

    < form class = "form-horizontal" action = "" #cgi.script_name # "method ="post"enctype =" multipart/form-data">"

    < div class = "control group" >

    < class label = 'label control' for 'importFile' = > import file < / label >

    < div class = "orders" >

    < input type = "file" id = "importFile" name = "importFile" value = "#form.importFile #" >

    < / div >

    < / div >

    < div class = "control group" >

    < div class = "orders" >

    < button type = 'submit' class = "btn, btn-primary" > download < / button >

    < / div >

    < / div >

    < input type = "hidden" name = "subject" value = "1" / >

    < / make >

    < / div >

    < / ct:layout >

    < / cfoutput >


    DavidSCarlisle55 wrote:

    I changed the date to 'YYYY-MM-DD' in the xls file by changing to the UK format within excel.

    It is still giving an error.  ?

    Odd. Then there can be only one solution to the riddle: what you read is a column name, and not the date value stored in the column.

    See what happens when you replace this line by

    or, perhaps better,.

  • How to use methods within the itemRenderer

    Hello

    I have basic itemRenderer as a component:

    < mx:Component id = "ColorRenderer" >
    < mx:Label
    Text = "{rgb2hex (255,100,50)} ' / / this gives error: 1180: call to a method may be undefined rgb2hex"
    / >
    < / mx:Component >

    My method works if I use it with a 'normal' tag < mx:Label = "22" x = "12" text = "{rgb2hex (255,100,50)}" width = "150" / > "
    but it does not work inside the itemRenderer?

    What I'm missing here?

    When you use the tag you define a new variable scope. In this context, the rgb2hex does not exist. You need to qualify: { outerDocument.rgb2hex (255,100,50)}

  • The material inconsistency: getNext() method of the Cursor class

    Hi, I'm a newcomer to Berkeley DB I.

    I found an inconsistency between the JavaDoc and the documents of GettingStartedGuide (GSG)
    -the description of getNext().

    In JavaDoc, getNext() of a cursor returns first element of data in all of the duplicates if the
    corresponding key has values duplicated, while in GSG, getNext() of a cursor indicates the next record
    in the database, regardless of whether it is a duplicate of the current record.

    Maybe I didn't understand what that two descriptions really mean@~ @.

    Can anyone help clarify this inconsistency?

    Thank you.

    Hello

    Sorry - the javadoc for getNext is incorrect. If you remove this sentence: 'If the corresponding key is duplicated values, the first element of data in all of the duplicates is returned.', then the rest of the javadoc description is correct.

    -mark

  • The session class method "connect."

    Hi all

    Anyone know how the argument 'version' in the Connect method of the Session class becomes the PeopleTools version when connecting? I see in the PeopleSoft documentation, it is still defined as "1". However, how he took over the version of PeopleTools of the used psjoa.jar file? Any suggestions?

    Session.Connect (version, {'EXISTING' | //PSoftApplicationServer:JoltPort}, user name, password, ExtAuth)

    Here's what I'm trying to accomplish:

    The below error raises the following when the PS tools connect with does not match what is on the application server. I like to know where to find the version number of PeopleTools on the web server, in the example below, it would be '8.51.16 '. Where is it stored? Is there a way I can call to retrieve this info?

    Error:

    Release of PeopleTools (8.51.16) for the web server "is not the same as the Application Server PeopleTools release (8.51.08). Access denied. ;

    Thank you in advance!

    Thone

    So after having read the two messages, I think that the solution of the other post corresponds to your need. Integrate you with PeopleSoft, the client gives you a copy of the psjoa.jar to deploy on your end. It is supposed to match their current version. You probably had problems where they sent you the wrong copy or you have deployed the wrong version somehow, and you want a way to validate the version against what they are running. When you refer to the version on the web server, you really mean the file psjoa.jar on deployed on your server. In which case, I gave you 2 solutions on the other thread.

    If I got that wrong let me know and if not I think we can let this thread go now.

    BTW: If you find my posts useful or answer your question, please report them accordingly. I'm trying to get out of the status of beginner and half of the people asking question never give points :)

    Thank you

    Published by: CCR on March 7, 2013 21:01

    Edition of the grammar

  • How do I do to make the manager class to run the drawFocus method?

    Hello world.

    Please let me question.

    I want to have the handler class to do drawFocus.

    Development is not won if "FOCUSABLE" is specified to the constructor for the handler class. You know the method of the handler class drawFocus method?

    Moreover, I want to express a given from the list of mail in the handler class.

    JDE 4.6.0 component package

    I solved for oneself.

    The following figure is a thing I wanted to do.

    http://picasaweb.Google.co.jp/LH/photo/9wNNUNZam8MKyV9h1FTquw?feat=DirectLink >

    (Because the image was not displayed by the preview, the link was introduced. "I'm sorry.)

    First of all, I've arranged it at the head of the 'FOCUSABLE' NullField handler class. (The handler class can judge the acquisition of the development of this event.)

    The handler class has a class variable that shows the status of the presence of development.

    And "focusChanged' FocusChangeListener method is mounted.

    The handler class to draw the rectangle in the method object referring to the value of the variable in class to come.

    I want to do there.

    I want to close this question hereby.

    Thank you to save expensive time, Mark.

  • With the help of the child in the executable class

    I'm kinda stuck and don't know how to solve and could not find a solution online.

    I have a parent class and its children to the class. The child class only overrides a method, but not the run method. I want to compile the executable project, where the run method is called, but the class type is the child, not parent. How to do this?

    I tried three things, but all in vain:

    (1) in the build properties when I select start VI the run method of the parent, I get in the executable the parent, not the child's class class. It's logical. However, I couldn't find the option to use the child as a type's class.

    (2) when I add the run method of the child class and appeal to parents, I get two windows pop up. The run of the parent and the child method. Too many. Even if for the class child run method (see below the block diagram of a child, red run method's parent), I put not to show the façade when it is called in the properties of VI.

    (3) when I tried with a separate VI calling the run method of the parent class, but the class type is the child, I get the façade of this separate VI and the run method of the parent. See below (Blue class is child, red of parent).

    In both cases 2 and 3, I chose to put the checkbox 'See the façade when it is called' a FAKE, but still the front panels appear.

    Someone don't know either: i) the use in the executable version of the options to generate an executable when a different class method is used, or ii) when you compile an executable file with a certain start VI, to not show this starting VI?

    I understand if I say "you want to configure the RUN method of the class as 'start-up VI' in the EXE file, but it should run the RUN method for a child object"?

    If this is correct, your third approach is the right one. This new boot VI is often used as 'Splash Screen' that covers the task of a demon "spawning" for your application.

    You must simply close this VI once it's over. This can be done using VI server on its own front panel functions.

    hope this helps,

    Norbert

  • Call the method of the object, the view object entity

    Hi all
    I use jdeveloper 11.2.1.0, and I need to call the method in the object class to view object entity class.
    Someone knows how to do?

    Thank you.

    http://andrejusb.blogspot.in/2009/11/calling-custom-entity-method-from-view.html

  • import a class: how many ways are there? CFC, import, extend the base class

    How many ways is there to import a class and am I confused

    1 screen/public class extends MovieClip

    This inherits all the properties and methods of the MovieClip class so WHY again do we use: import flash.display.MovieClip;

    Import something else or just made the job twice

    2 import flash.display.MovieClip - so no need to extend (repeat me once again - see 1)

    3 CFCS: connect to a CFC

    4. stir in a SWF with a meta tag

    5. in the properties panel menu - add a class as a base class

    OMG - a bit confusing

    You can only "extend" another class if the compiler knows where he is.

    The import statement is only by the compiler to find the class on your hard drive.

    It is not "import" of the entire class in the sense that you import a BMP in Photoshop.

Maybe you are looking for

  • IPhone shows 68 videos but iTunes 13

    Hi all I need help, my brother passed away and I'm saving her videos of her phone, if I opened the Photo app and I can see 68 videos, but when I connect the phone to the PC I see only 13 on the 100APPLE folder. Can someone give me help on how to copy

  • Tecra A8-104 requires no password BIOS or HARD drive

    Hi, I recorded the two Bios and hard drive goes into security help Toshiba but when starting the system he does not ask me for any of them. No idea why?

  • HP mini 110 ask current password and do not start computer

    Hi I was wondering if you can help with a password. I get the CNU9362H8L error code after three unsuccessful attempts

  • NavigationClick overridden to manager does not seem to be invoked

    I'm building a custom field Manager. I replaced navigationMovement and touchEvent successfully but can't do even the most basic features of working with navigationClick. I expect that this code will show at least some type of message when you click t

  • Cannot stream video on my laptop HP Folio 13

    Hi, I'm new here and have a question about streaming video. I got my laptop HP Folio 13-1029 for a short period, and the problem has been there from day one. , I have Windows 7 can not the flow of data from any website, YouTube, etc. Even your videos