representation of a real world entity.
instance of a class.
abstract entity and its components(data and actions).
contains attributes and behaviours
has 2 components: attributes(like lists) and behaviours (functions)
support abstraction
facilitating ease of debugging
future maintenance (only need to work through one subprogram instead of whole thing)
reusability of code
modularity
decrease reuse.
reuse helps development speed cuz developers can work on it at the same time.
increases maintenance overheads
changing one line of code could have big impact on all classes involved.
greater room for error and takes lots of time to fix error
data is stored as a combination of binary values in the computer
data types are used to store different kinds of data
needed because they specify to the computer how to interpret the binary values in the storage
So computer uses minimum RAM, and the program is more efficient
boolean = data thatâs only 2 values (true/ false, on/off). 1 byte
integers = represent whole numbers, 4 bytes bits to store information
real = decimal numbers, 8 bytes
string = sequence of characters like a name, each character takes up one byte
class that inherits the other class is known as sub class
can add its own states and behaviours
allows us to pass information or instructions into functions and procedures
names of the information we want to use in a function or procedure
values passed in are called arguments
in a class, different methods have the same name
different signatures where signature can differ but number of input parameters or type of input parameters (or both).
allows child class to provide a specific implementation of a method that is already provided by the parent class
same function, same parameters but different classes
always invokes the more specialized behaviour.
overloading = same function but different parameters
overriding = same function, same parameters but different classes connected through inheritance
data hiding
increased flexibility
reusability
testing code is easy
secure because user canât see the inner information of the class
not visible to the user how the class is storing values in the variables
only know that we are passing the values to a setter method and variables are getting initialized with that value
encapsulation also improves ability for code to be used many times
can be copied to different/new classes and help meet new requirements
allows unit testing (automated testing that tests many different types of data quickly
easier to fix larger programs if you know which method is returning the wrong response
can make variables of the class as read-only or write-only, depending on our requirement
if we wish to make the variables as read-only then we can omit the setter methods
or for variables as write-only then, we omit the get methods
minimizes amount of duplicate code in an application by sharing common code amongst several subclasses
reduces time and effort to recreate classes by moving that common code up to a common superclass
minimize amount of duplicate code in an application
better organization of code
code more flexible to change
allows a parent class to specify methods that will be common to all of its derivatives
while allowing sub classes to define the specific implementation of some or all of those methods
allow us to call methods of any of the parent classes without even knowing the specifics of the parent class
donât have to create and remember different names for functions doing the same thing
like would have to make many methods names for ever possible combination of parameters being used
time saving
sorting algorithms do not have to be re-invented (like u dont have to reinvent the wheel)
complex algorithms and processes can be reused
increased complexity for small problems
unsuited to particular classes of problems
involves more lines of code than procedural programs
slower than procedure-based programs, as they require more instructions to be executed
problems can be easily solved by functional programming style, logic programming style, or procedure-based programming style and applying OOP in those situations will not result in efficient programs
ex. why make an object when using a String will do
Speed of completion faster
information hiding to reduce module dependencies
expertise in a narrow field
developers only need to know the name and required parameters to use a behaviour
can use code without needing to understand how it functions
security benefit to coders not having access to actual data items
assembling a complex project needs many skills
each part can be programmed by an expert in that field, so quality of final product is significantly higher than expecting one person to know it all
Communication and coordination issues
Groupthink: diffusion of responsibility; going along
Working by inertia; not planning ahead
Conflict or mistrust between team members
easier debugging and testing
speedier completion
code blocks reusable
smaller modules to test means easier to find and fix bugs
number of tests that have to be run to confirm the module is operational is reduced
breaking the project into smaller modules, can save time by using modules that already exist from libraries that do the function you want
each module can be worked on concurrently, so speedier completion of the overall project
some problems are common and possible occur in multiple programs (like needing a text box)
can reuse blocks of code, so development time is slashed
named pointer that explicitly identifies an object, class, method or variable
allows programmer to refer to the item from other places in the program
most basic data types available within Java language
boolean, byte, char, short, int, long, float, double
building blocks of data manipulation
purpose: contain pure, simple values of a particular kind
named storage location for a value that a program can manipulate
must be declared before they can be used
non -static variables and are declared in a class outside any method, constructor or block
created when object of the class is created and destroyed when object is destroyed
can use access modifiers for instance variables
parameter allows us to pass information or instructions into functions and procedures
names of the information we want to use in a function or procedure
values passed in are argument
variable defined within a block or method or constructor
created when the block is entered or the function is called and destroyed after exiting from the block or when the call returns from the function
only accessible within its block
set of code referred to by name and can be called at any point in a program simply by utilizing the methodâs name
described as a subprogram that acts on data and returns value
each method had its own name
type of method returning the value of a private instance variable
getter method
setter method
used to control changes to an encapsulated instance variable
instance method invoked when object of that class is created (using the new keyword)
same name as class, no return type
class name, object name = new constructor();
method can be any user defined name
constructor must be class name
method should have return type
constructor doesnât have any return type
method called explicitly either with object reference or class reference
constructor called automatically whenever object is created
part of the method declaration
combination of the name and the parameter list
__()
return = reserved keyword in Java, not an identifier
exits from a method, with or without a value
procedures dont return any value (void)
functions return value
no method can return more than one value at a time in Java
can only be accessed within the declared class itself
most restrictive access level
can be accessed outside of class if public getter methods are present
using the private modifier is main way an object encapsulates itself and hides data from the outside world
can be accessed only by subclasses
prevents non related classes from trying to use it
common character sets among many platforms and languages like Unicode
platform independent high level languages enable code to run on many platforms