Without trying to be comprehensive or tedious, we want to end this chapter with some hints that may make your classes more acceptable in well-mannered OOP circles.
After all, the users of your class are more interested in the public interface than inthe details of the private implementation. And they are more interested in methods than in data.
However, there is no universal agreement on what is the best style. The Sun coding style guide for the Java programming language recommends listing fields first andthen methods. Whatever style you use, the most important thing is to be consistent.
This class really implements two separate concepts: a deck of cards, with its shuffle and draw methods, and a card, with the methods to inspect the value and suit of acard. It makes sense to introduce a Card class that represents an individual card.Now you have two classes, each with its own responsibilities:
A good convention is that a class name should be a noun (Order) or a noun preceded by an adjective ( RushOrder) or a gerund (an “-ing” word, like Billing Address). As for methods, follow the standard convention that accessor methods begin with a lower caseget (getSalary), and that mutator methods use a lowercase set (setSalary).
Core Java Related Interview Questions
|J2EE Interview Questions||Core Java Interview Questions|
|JDBC Interview Questions||JSP Interview Questions|
|Android Interview Questions||JavaServer Faces (JSF) Interview Questions|
|Java collections framework Interview Questions||Java 8 Interview Questions|
|Java Collections Interview Questions||Java Exception Handling Interview Questions|
|Java Concurrency Interview Questions||Java Serialization Interview Questions|
|Java Programmer Interview Questions||Java Inheritance Interview Questions|
|Java IO Interview Questions||Object Oriented Programming in PHP Interview Questions|
Core Java Tutorial
An Introduction To Java
The Java Programming Environment
Fundamental Programming Structures In Java
Objects And Classes
Interfaces And Inner Classes
User Interface Components With Swing
Deploying Applications And Applets
Exceptions, Logging, Assertions, And Debugging
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.