Terminology Flashcards
Class
- Class is a blueprint /template to describe object.
- Class describe characteristic, and behavior of object allow representation of the real-world object in coding and improve the readability of code
- Class is one way of Java implement type or class is a type. The values of the type are the object and the methods of the class operate on the object
- Class always contains unique characteristics to particular object and normally with different value.
Object
- Object is normally referring to an abstraction of real-world entity and is has attributed and behavior.
- Object is an instance of class that have state or values that represent a instantiation of the class
Constructor
A special method will be call when constructing the object to initialize the object state
Attribute
Attribute is referring to the characteristic or property of an object
Method
- Method encapsulate a set of instructions that are related to achieve a single task or goal.
- Method is a collection of statements that group together to achieve a goal or perform a task.
Parameter
A parameter is a special kind of variable, used in a subroutine/procedure to refer to one of the pieces of data provided as input to the subroutine/procedure.
Argument
The arguments are the values supplied to the subroutine/procedure when it is called.
Behaviour
Behaviour is about task and actions can be performed by the object.
Characteristic
Characteristic is the property, quality, or state of the object that described using values.
Variable
Variable is an identifier in the program that store a value/reference that could be change.
Constant variable
Variable where its value cannot be change once being assign.
Instance variable
- Variable declare as the property of a class that represents the state of an object.
- Instance variable is belong to particular instance object that represent the state of the object.
Instance method
Instance method is the subroutine of an object, declared in a class.
- Belong to instance object.
Static variable/ Class variable
Variable declare as property of class that shared among instances of the class and have only one copy throughout the program.
Predefined library
The predefined libraries contain classes, methods that are pre-written by respective programmers to provide common solutions to problem face in application development. It has higher quality and access by everyone.
User defined library
User defined library is maintained by individuals or company to solve specify problem domain. the quality depends on the programmer and used privately.
Type
Type is a set of data values and the operations that can be performed on them.
Inheritance
- Inheritance allow generalization and specialization to eliminate code redundancy and improve coding maintenance.
- Inheritance is a technique to allows a class to contain some features from the other class without replication to encourage code reuse. Or it refers to the ability of one class (child class) to inherit/obtain the identical functionality of another class (super class), and then add new functionality of its own.
Generalization
Generalization is the process of avoiding code and data duplication among several classes by creating a super class to those classes and moving the duplicate code and data up into that superclass, which is commonly abstract. The code is going upward in the class hierachy.
Specialization
Specialization is the process of extending an existing class by adding new features is called using inheritance for specialization. The code is moving downward in the class hierarchy.
Inheritance for specialization
The process of extending an existing class by adding new features is called using inheritance for specialization.
Singleton Object
An object that has only one instance in the entire program and it is defined using object keyword.
Companion Object
It is a singleton object that has the same name with a class name, and it is use to describe every instance of the class. It always contains common characteristic for all instances of the class with same values.
Signatures
A method signature is part of the method declaration. It is the combination of the method name and the parameter list.
Overloading
Overloading is to allows declaration of method to have the same name/identifier but difference signatures.
Overriding
- Overriding is to modified the implementation of a concrete method with the same name/identifier and signatures.
- Overriding concrete methods means that the method implemented in the parent class is hidden away and replace with overridden method in the sub class
- Overriding abstract methods means provide implementation of the unimplemented in the parent class.
Abstract class
- Class that may has unimplemented methods and could not create instances, It allows defining a class that is too abstract to have implementation.
- Abstract is about class that may contain unimplemented methods or variable that need to be further defined by class that extends.
Concrete class
Concrete class is a class that can create instances object. It contains only implemented methods and property values. It is normal class that represents real world entity in term of characteristic and behaviour.
Polymorphism
- Polymorphism is the characteristic of being able to assign a different meaning or usage to something in different contexts.
- Polymorphism allow the same operation/message to be carried out on different objects and perform differently.
Parametric polymorphism
- Parametric polymorphism allows a function or a data type to be written generically, so that it can handle values identically without depending on their type.
- Allows a class/trait/functions to accept data type as a value so that class/trait/functions can be written generally.
Subtype polymorphism
- Object of subtype can be legally used wherever and object of a supertype is expected is called subtype polymorphism.
- Polymorphism in one of the OOP features that allow the program to be extensible and maintainable/
- allow Object of a subtype can be legally used wherever an object of a supertype is expected. It employ the idea of subtyping to restrict the range of types that can be used in a particular case of polymorphism.
val vehicle1: Vehicle = new Car()
Cohesion
Cohesion is a measure of how focused the responsibility of a module are.
Coupling
Coupling refers to how dependent modules are on each other.
Interface
Interface is a second way of Java implement type. The values of the type are object of Class that implement the interface and the methods of the interface implemented by Class operate on the object.
Interface is a special class that specify the similar behavior among difference type of classes without implementation.
Interface is a programming structure/syntax that allows the computer to enforce certain properties on an object (class)
Trait
Traits are used to share interfaces and fields between classes. They are similar to Java 8’s interfaces with addition it can contain concrete variable and methods. Classes and objects can extend traits cannot be instantiated and therefore have no parameters.
- Trait is a partial/part description of an objects. Where the description can be incorporated in different class.
Generic programming
Generic programming allow types to be parameterise in class, interface or methods much like formal parameter use in method declaration.
Iterator
Iterator is an interface for collection in Java/Scala library that specify hasNext and next abstract function
Data field
Data field represent the attribute of an object.
Property
property is a method in OOP to expose private data field through getter and setter so that data can be encapsulated in within the class to hide internal data field handling and also allow implementation of data validation.
Companion object
Companion object is the singleton object that has the same name with the class and is written in the same source of together with the class.
Singleton object
Singleton object is object that has only 1 instance in the entire program.
Mixin
A mixin is a class that cantains implementations for use by other classes without having to be the parent class of those other classes. How those other classes gain access to be the mixin’s methods depends on the language. Mixins are sometimes described as being “included” rather than “inherited”.
Instantiation
Instantiation is creation of object from a class.
Initialization
Initialization is assigning values to object’s attributes
Association
When object has any relationship(has a, is a assigned…) to another object.
Aggregation
An association indicates that one class is part of another class. In an aggregation relationship, the being referenced class instance can outlive its belonging class.
Composition
- An association indicated that one class is a part of another class.
- A strict form of aggregation where the life of the part is tied to the life of the whole.
Identifier
Identifier is the naming given to variable, method or class. It usually follow a set of rules depend on the programming language.
Has-A relationship
When an object of one class maintain a reference to objects of another class then it can be consider the object has another object.
Is-A relationship
When a set of object of Class A is a subset of object of Class B then it is consider A has is-a relationship with B.
Guideline of identify class
- Extract Nouns and Verbs
- > Based on the problem specification, identify the nouns and verbs used in describing the problem.
- Use concepts from the application domain
- > From the background of the problem domain, find extra class candidate
- Use CRC Cards
- > A small size note card (4” x 6”) that allow you to summarize the responsibilities of each class in a few words and helps the design team avoid getting bogged down in low-level detail too soon.
Guideline of creating class
- Every class should be responsible for doing one things only and doing it well.
- Different kinds of responsibilities should be separated among different objects.
- The object that contains the necessary data to perform a task should be the object that performs the task. (expert pattern)
- Avoid duplication. Dry principle = don’t repeat yourself.
- Only one class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes.
- Class should have complete and consistent protocols.
- Class should design for changes by following Open-Closed Principle that is design software to be open for extension but closed for modification.
- Obey the law of Demeter.
Guideline of object oriented development by Ralph Morelli & Ralph Walde
- Problem Specification
- Problem decomposition
- Design Specification
- Data, method, and Algorithm
- Coding
- Testing, debugging
Scala linearization
Scala linearization is a deterministic process that puts all traits in a linear inheritance hierachy
The rules for process of linearization
1) Start at the first extended class or trait and write that complete hierarchy down. We will call this the linearized hierarchy
2) Take the next trait and write this hierarchy down
- now remove all classes/traits from this hierarchy which are already in the linearized hierarchy
- add the remaining traits to the bottom of the linearized hierarchy to create the new linearized hierarchy.
3) Repeat step 2 for every trait.
4) Place the class itself as the last type extending the linearized hierarchy