Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Andreas Leitgeb Newsgroups: comp.lang.java.programmer Subject: Re: can someone chk is this code ok and if i can make it better please state how Date: Fri, 6 Jan 2017 21:11:42 -0000 (UTC) Organization: A noiseless patient Spider Lines: 66 Message-ID: References: Reply-To: avl@logic.at Injection-Date: Fri, 6 Jan 2017 21:11:42 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="116584210242414456deda75bd9e4538"; logging-data="32641"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/0kcl0755ihRRR74UuYnJ9" User-Agent: slrn/1.0.2 (Linux) Cancel-Lock: sha1:tZT9uV2S5M2MeyiyMItNKKtW2YQ= Xref: csiph.com comp.lang.java.programmer:36164 Possible improvements: - adding the missing close-brace for the class at the end. - There exist styling conventions for casing (upper/lower) of identifiers. Most of the identifiers are ok, except those for the fields. MixedCase with an initial capital should be used only for class-names. - Unless "the" is part of the field name, it shouldn't be included into accessor methods' names. As for mutator methods: here's an example (assuming that the fields have been renamed to lowercase initial): ... private int weight; ... public void setWeight(int weight) { this.weight = weight; } ... public int getWeight() { return weight; } ... ditto for the other fields. SuperGiirl wrote: > On Friday, January 6, 2017 at 8:38:28 PM UTC, SuperGiirl wrote: >> public class Gadget >> { >> private int Weight; >> private double Price; >> private String Model; >> private String Size; >> >> >> public Gadget(int theWeight, double thePrice, String theModel, String theSize) >> { >> Weight = theWeight; >> Price = thePrice; >> Model = theModel; >> Size = theSize; >> } >> >> >> public int getTheWeight() >> { >> >> return Weight; >> } >> public double getThePrice() >> { >> return Price; >> } >> public String getTheModel() >> { >> return Model; >> } >> public String getTheSize() >> { >> return Size; >> } > > can someone please explain how to do the mutator method