Bean - setters and getters naming conventions

Hi,
Just like the constructor is named after the class,
why shouldn't the setters & getters be named after the
properties?
This would make the reflection code clearer.
Wouldn't it?

Maybe he means that they should be called:
void variableName(int value); // setter
int variableName();  // getter
Ouch, that was really ugly :)If thats true, our friend is a Delphi programmer :)
Next we could drop the parenthesis in no arg methods
v = variableName;
ahhhh, so much more obfuscating.

Similar Messages

  • How to use setters and getters in another program by using bean

    how to use the setters and getters methods using database connection by bean

    Say again?And so he did:
    http://forum.java.sun.com/thread.jspa?threadID=750645
    kind regards,
    Jos ;-)And again
    http://forum.java.sun.com/thread.jspa?threadID=750643&tstart=0
    No, that's his class mate I guess; it must be national getter and setter
    day somewhere today ;-)
    kind regards,
    Jos

  • Setters and getters in my beans - syncrhonize

    All,
    have a bunch of POJO's. Using hibernate. Should I syncronize my setters and getters?

    It depends if you would use the object concurrently or not. Even if you did use an instance concurrently, you would not need to synchronize on every getter and setter. I strongly suggest you learn the ins and outs of thread safety before arbitrarily locking your objects.

  • Setters and Getters

    Can any one Explain  the setters and getters and different ways of writing?? How Can we use it much better??

    http://www.flashscript.biz/flashas3/AS3_tutorial/lesson9.html

  • Regarding Setters and Getters

    Hi All,
    1. How parametters we can send to a Setter ?
    2. What are the best practices of setters and getters?
    Thank you
    Siva

    You should read up on "ENCAPSULATION". Here is a good read for ya:
    http://www.inf.ufsc.br/poo/smalltalk/ibm/tutorial/oop.html
    Thanks.

  • Examples of Global, Universal, and Local naming convention

    I am stuck on the types of naming conventions for global, universal, and local groups.
    For example, I have Managers, Clinical, VC, BC, Councilors, Accounting, Nurses, Payroll, Benefits, Company Policies/Form
    Which ones would you make global, universal and local?
    I was thinking of making Clinical, Accounting and Managers the global groups. Then make VC, BC, Nurses, Payroll, Benefits and Company Policies/Forms, Councilors the local groups.
    Since this is only a single domain, I was going to omit the universal group.
    What are your thoughts? Would this work?

    Greetings!
    There is really no difference in your scenario. If you have a single domain with no other child domains simply go for Global. The differences between these groups are related to membership of
    the users. For example in Global groups, users from other domains are not allowed to be member of the group.
    More information at:
    Group scope
    Regards.
    Mahdi Tehrani   |  
      |  
    www.mahditehrani.ir
    Please click on Propose As Answer or to mark this post as
    and helpful for other people.
    This posting is provided AS-IS with no warranties, and confers no rights.
    How to query members of 'Local Administrators' group in all computers?

  • Why use setters and getters?

    Hi.
    I've been wondering woudn't a function with return do the same thing as a get function with return?
    Ex:
    var age:Number = 16;
    function get Age() {
         return age;
    isn't the same as:
    function Age() {
         return age;
    Thanks.

    I respectfully disagree with the statements that it is a matter of nomenclature. Although there are a lot of cases when accessors (getters/setters) are overused, they are definitely extremely useful features of any OO language. In some case code would be much longer and more cumbersome without accessors. I must say that with code written on timeline accessors are less useful (although I can see plenty of cases one can utilize them). When code is written in classes - accessors are indispensable.
    With your age example it is really a matter of preference. But if you need to do more with age - you would definitely appreciate getters/setters.
    For example:
    Say you have a class Person and it has property age:
    public var age:int = 0;
    Somewhere we instantiate this class:
    var myPerson:Person = new Person();
    Now we set age:
    myPerson.age = 23;
    trace(myPerson.age); // returns 23
    Just imagine you instantiate this variable in 100 of places.
    When you think you are done, your boss comes to you and says: “I want you when they set the age also to evaluate what age group person belongs to.”
    If there were no getters/setters – you would have a very hard time chasing all 100 instances in your program and changing your Person class architecture. With accessors you will spend a few minutes only. You can do the following:
    // change the variable to private
    private var _age:int = 0;
    // create accessors
    public function set age(a:int):void{
         _age = a;
         // here you evaluate age
         if (_age < 10) {
              trace("child");
         else if (_age > 10 && _age < 20) {
              trace("teenager");
         else if (_age > 20 && _age < 30) {
              trace("young");
         else {
              trace("too old to bare :-(");
    public function get age():int{
         return _age;
    As you can see you changed the code in one place and while not doing a thing in any of 100 places you instantiated the Person class.
    Again, your boss can come back and ask to restrict the age to people older than 20.
    So may write:
    public function set age(a:int):void {
         if (a > 20) {
              _age = a;
    Again, you met requirements and did not change any code anywhere else.
    One more request from the boss. Say, he wants you to count how many times age was changed. You can use setter to do that:
    private var getterCounter:int = 0;
    public function get age():int {
         getterCounter++;
         return _age;
    You wouldn’t be able to do all these things if there were not accessors.
    Still the use of age variable will stay the same:
    var myPerson:Person = new Person();
    myPerson.age = 34;
    trace(myPerson.age);
    Welcome to scalability and encapsulation. It doesn’t matter what you do when age is set inside Person class – it will not break code anywhere else.
    There are millions more useful cases when getters/setters come handy.

  • Command Link : Backing bean setters/getters always invoked

    I am trying to understand how to the setters and getters of a request scope managed backing bean are invoked through the navigation flow when using a command link.
    It seems that no matter where the navigation rules redirects the page as a result of the action, both the setters and getters of any field bound in the originating page are called.
    For example if the originating page has a field name referred by "#{UserBean.name}" to input a username. setName() and getName() are always called as a result of a click on a command link
    This behavior is easily seen in a simple JSF example such as http://www.netbeans.org/kb/articles/jAstrologer-intro.html.
    If the jsp pointed by "to-view-id" is changed to have no reference to the backing bean or is changed to a jsp with just text, both setters and getters are still invoked.
    I could understand why the setters would be invoked (doesn't know ahead of time if the bean will be used?) but at least why the getters?
    Last, how to prevent this behavior? The problem is that the backing bean might have complex logic where it will fetch data if a getter is called.
    Thanks.

    I guess this article might be interesting to get some insights http://balusc.xs4all.nl/srv/dev-jep-djl.html
    The setters are invoked to set values and the getters are invoked to get the eventually presetted default values or the previously submitted values.

  • EP Naming Conventions and Best Practices

    Hi all
    Please provide me EP Naming Conventions and Best Practices documents
    Thanks
    Vijay

    Hi Daya,
    For SAP Best Practices for Portal, read thru these documents :-
    [SAP Best Practices for Portal - doc 1 |http://help.sap.com/bp_epv170/EP_US/HTML/Portals_intro.htm]
    [SAP Best Practices for EP |http://www.sap.com/services/pdf/BWP_SAP_Best_Practices_for_Enterprise_Portals.pdf]
    And for Naming Conventions in EP, please go through these two links:-
    [Naming Conventions in EP|naming standards;
    [EP Naming Conventions |https://websmp210.sap-ag.de/~sapidb/011000358700005875762004E]
    Hope this helps,
    Regards,
    Shailesh
    Edited by: Shailesh Kumar Nagar on May 30, 2008 4:09 PM

  • Code Inspector - Naming conventions &mExtended Naming conventions for Progs

    Hi experts,
    I had a look into the naming conventions enforced by 'DEFAULT' variant of code inspector (SCI).
    the relevant categories are: "Naming Conventions", and "Extended Naming conventions for Programs" under "Programing conventions".
    in the "Extended Naming conventions for Programs" category, for functions, (applicable while calling the functions) it says,
    importing parameter : I[:type:]_
    exporting parameter : E[:type:]_
    changing parameter  : C[:type:]_
    tables parameter    : T[:type:]_
    but in the "naming conventions" category, for functions (applicable while defining the functions), it says,
    importing parameter : P_*
    exporting parameter : P_*
    changing parameter  : P_*
    tables parameter    : P_*
    I felt, while defining the function too, its better to have beginning with  I_, E_, C_ or T_ instead of P_
    is the 'DEFAULT' variant of code inspector is provided and recommended by SAP?
    for easier maintenance and clearer understanding, which naming convention is more suitable, or is there any official guidelines released by SAP for ABAP developers.
    appreciate the opinions from experienced abap developers.
    thanks,
    Madhu_1980

    Frank,
    Thanks for your answer.
    But what about Entity Objects, View Objects, View Links, and Application Modules.
    I would like my developers to have an easy way to name them and also find them via intellisense.
    So I was thinking in naming them the following way :
    Entity Objects :
    EO_Employee
    EO_Department
    View Objects :
    VO_Employees
    VO_Departments
    View Links :
    VL_EmployeesToDepartments
    Application Module :
    AM_HRService
    However the use of "_" is not so "Java naming oriented".
    So other alternatives would be:
    1. take the "_" :
    1.1 EOEmployee (I don't like the fact of having 3 capital letters together).
    1.2 EoEmployee (I don't like the fact of having Entity Object with a lowercase "o").
    2. Use the prefix at the end, but this way I loose the intellisense feature I want:
    ex: EmployeeEO
    Which naming approach are you using for big projects ?
    Thanks,
    Claudio.

  • How to use javasetters and getters in different classes

    how to use setters and getters in different class so that the setvalue in one class is effect in second class for getting

    If i got your question right,
    make sure your classes are in the same package
    make sure your getters are public/protected
    make sure your code calls the setter before calling the getter
    Kind regards

  • Naming conventions in EP

    Hi all,
    we are currently in the process of preparing for Buisness Package certification in Enterprise Portal.
    While going through the Test Plan provided by SAP describing the guidelines and the naming conventions.
    Is there any thing that should be especially noted when we do the naming of EP folders and other EP components.Any help on these naming conventions is welcome.
    Regards
    Rohit.

    Hi Rohit,
    Please refer to the Vendor Structuring Guide (a.k.a. How to Certify Portal Content document) for more information on the naming conventions. You should have received this together with the test plan.
    If you cannot locate this document, please contact your assigned integration consultant and/or complete and return the project registration document as much as you can so that the consultant can get back to you with any corrections that might be necessary.
    Regards,
    Mustafa.

  • Naming Conventions for a BI Project

    Hi Experts,
    I am looking for some guidance on how to name my custom infoobjects,  cubes, process chains, infopackages, sources etc.
    What is the best approach and what naming convention to assign them?
    Thanks,
    Raj Jain

    Hi Rajesh,
    Naming conventions are always followed according to the customer standards... Some ask for Z* objects while others Y*.... If you have to find out how to name your objects.... go to your production system and search some custom objects... this might take some time but will save you the burden of rework.... Always please refer to your production systems for Naming conventions of any objects
    Regards,
    Pramod

  • Java bean field naming convention

    I posted this under the Desktop -> JavaBeans, but wasn't sure if that was the right place, so I'm posting here to:
    I have an object with a field "iATANumber".
    I have getters and setters like this:
        public String getIATANumber() {
            return iATANumber;
        public void setIATANumber(String iATANumber) {
            this.iATANumber = iATANumber;
        }In my jsp I'm trying to print it out like this:
    ${foo.iATANumber}and it doesn't work. I just get nothing, while all the other fields on my object work, and it prints out the number I want if I call the getter from a scriptlet.
    Everything works great though if I change the field to iataNumber (note the change in case), and change the getter, setters and jstl to match. Then the jsp works fine.
    The getter and setter names for iATANumber were generated useing IntelliJ, are they not right, and that's why ${foo.iATANumber} won't work?
    Thanks in advance.

    The JavaBeans naming convention falls on its face if a property starts with a lower-case letter followed by an upper-case letter. The commonest way to find this problem is to call your property "eMailAddress" but you have found a different way.
    You also found a solution. Workarounds are the best you can do here.

  • Question about CEP Naming Conventions and or Standards

    Hello,
    CEP is new to the organization that I am working with. I have been asked to draft a few standards around CEP to help promote standardization and proper reuse of CEP artifacts. Can anyone share with me examples of CEP artifacts with a naming convention or their experiences with naming conventions around CEP in general. This is a living standards document for us. We plan on using CEP heavily going forward. Your experiences will help us start off on the right foot.
    Thanks in advance,
    JJE
    Spelling Edited by: JJ.Everett on Sep 7, 2010 11:16 PM

    Hi,
    Oracle CEP supports reuse of components in several ways. For example, you can design your application as a set of modules that can be deployed independently (different teams can develop each module). Modules can register services, such as an event source or event consumer, and these services can be used by other modules. So, it's possible to plug modules developed by different teams of developers together and reuse them in different applications or environments. A component instance registers itself as a service when its advertise attribute is set to true in the Spring application context that defines a module.
    A component implementation can also register a factory as a service that allows instances of the component to be created by other modules. Section 13.1.5 in the CEP Developer Guide describes this. http://download.oracle.com/docs/cd/E14571_01/doc.1111/e14301/adapters.htm#CIHBHEDA
    Hope that helps.
    Regards,
    Seth

Maybe you are looking for