Data types to represent telephone numbers:
a string of ten digits can represent all ten-digit telephone numbers.
an object can hold data (integers or strings) of the elements of a telephone number
an integer data type can represent all ten-digit numbers
–a boolean can only represent two values
an enumerated type can only represent a fixed number of constant
Abstract Class:
An abstract class may have constructors, but it is illegal to invoke the new operator on an abstract class
An abstract class is allowed to have method implementations
There is no restriction about the placement of abstract classes in a class hierarchy
It is legal for an abstract class to implement an interface and implement one or more interface methods
Design a role player game:
creating an abstract superclass for a generic player will simplify the design.
This is because the maintenance of the common methods will be simplified.
An abstract class is the perfect container, as a superclass, for the common methods
Model
A sports team with fixed number of players in which players may participate in other teams
a many-to-many association from players to team Will work
Java Bean convention for setter methods
void setFirstName(String value)
Data Hiding
A well-encapsulated class must have all of its attributes marked private.
A well-encapsulated class must hide all internal methods. This is because this is NOT part of the class’s public interface.
NOT all attributes require accessor or mutator methods.
The principle of “programming to an interface”?
Generalize the return type of a method. The return type of a method should be as abstract as possible, such that any object of that type could be returned. If a concrete class is used as the return type, then only an object of that type (or its subclasses) can be returned.
A class hierarchy is a static part of the code structure. Polymorphism and program to an interface are principles that apply to the dynamic aspects of the code, such as the objects that are stored in variables and passed through methods.
The parameter type of a method should be as abstract as possible, such that any object of that type could be passed in to the method. If a concrete class is used as the parameter type, then only an object of that type (or its subclasses) can be used as a parameter.
The type of an instance variable should be as abstract as possible, such that any object of that type could be held by the owning object. If a concrete class is used as an instance variable type, then only an object of that type (or its subclasses) can be held in that variable.
The relationship between classes and interfaces form only a static part of the code structure. Polymorphism and program to an interface are principles that apply to the dynamic aspects of the code
From: http://sitestree.com/?p=4844
Categories:Computer Game Design, Java Short Notes
Tags:
Post Data:2010-05-12 10:21:08
Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada