The business delegate is used to separate the business side and presentation side. The business side is made up of 4 parts:
public interface BusinessService {
public void doSomething();
}
The business interface that the concrete class implements
public class ServiceOne implements BusinessService {
@Override
public void doSomething() {
System.out.println("Something One!"); …
When using variables in code there are 2 different ways the data can be used. When you pass a variable to a function it is either a pass by reference or a pass by value.
Pass by reference is when the memory address is passed to the function. This means that whatever changes happens to the variable will affect all other variables pointed to that memory address. The following code is in C++.
#include <iostream>
using namespace std;void increment(int &x) {
x++;
}int main() {
int num = 10;
cout << num << endl; increment(num);
cout << firstNum; return 0…
The main use of the Transfer Object Pattern is to pass data with multiple attributes at once. It is made up of 3 parts:
PersonTO.java
public class PersonTO {
private String name;
private int id;
PersonTO(String name, int id){
this.name = name;
this.id = id
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
} public String getId() {
return id;
}
public void setId(String id) {
this.id …
Inheritance is one of the four pillars of Object Oriented Programming(OOP). Inheritance allows classes to inherit all methods and properties from another class. The parent class is the class that is being inherited from also known as the base class. The child class is the class that is inheriting from another class.
The parent class is a typical class that just needs to have the methods and properties that will be inherited.
class Parent:
def __init__(self, name):
self.name = name
def printName(self):
print(self.name)
The child class can be a typical class but you just need to wrap the parent class in parenthesis right after the child class. …
Arrow functions are similar to Java and Pythons lambda function. Arrow functions can be used instead of Javascript traditional function definition. Arrow functions are more compact but there are some limitations:
Instead of using the function key word you would wrap the arguments in parenthesis as usual than the arrow, =>, followed by the definition. If the there is only one argument you can ignore the parenthesis. Similarly if the definition only has one line you can ignore the curly braces as well the return keyword because it is implied. You can assign the arrow function to a variable as well. …
Lambda was added to Java in version 8. Similar to Python lambda is a short block of code that is a function do not have a name. Like functions they can take in arguments and returns a value. Unlike Pythons lambda Java has its own way of using lambda. Like in Python lambda functions are typically used in higher order functions or functions that take in another function as an argument.
To use lambda you start by declaring the argument separated by -> then the function definition.
// argument -> definition
x -> System.out.println(x)
If the lambda function takes in more than 1 argument or not argument it needs a parenthesis. …
Lambda is a single line function with no name that can have multiple arguments but only one expression. This is useful for writing functions that will only be run once.
def add(x, y):
return x + y
lambda a, b : a +b
As you can see in order to declare a function as a lambda function you need to use the lambda keyword. What follows after the lambda keyword are the arguments of the function. Then the colon symbol separates the argument from the definition.
You can save the lambda function by setting a variable equal to the lambda function. …
Normally we use numbers from 0–9 which a base 10 system called decimal. Binary is a number system using base 2 system. This means it just uses 2 numbers 0 and 1. Computers use binary to store data and each bit is represented by a 1 or 0. Each bit is grouped in 8 bits which represents a byte. Hexadecimal uses base 16 which is easier to represent 8 bits using only 2 digits instead of binaries 8.
Each digit in a decimal represents a power of 2. So starting from the right to left is 1, 2, 4, 8, 16 etc. When converting binary to decimal you figure out what digit represents what power of 2 and if it has a 1 add the power of 2 together. For example: 10101. From right to left the 1’s represent 1, 4, and 16 so to convert we add those number and we get 21. …
As the name suggests MVC design patterns involves 3 parts:
// Employee.java
public class Employee {
private int id;
private String name;
public String getId() {
return rollNo;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name …
The main idea for the facade design is hiding the complexities of the application. The user would use an interface/facade instead to access any methods.
// Animal.java
public interface Animal {
void species();
}
Interface for concrete class.
// Dog.java
public class Dog implements Animal {
@Override
public void species() {
System.out.println("Dog");
}
}
Interface implementations.
// Cat.java
public class Cat implements Animal {
@Override
public void species() {
System.out.println("Cat");
}
}// Bird.java
public class Bird implements Animal {
@Override
public void species() {
System.out.println("Bird");
}
}
// AnimalMaker.java
public class AnimalMaker {
private Animal dog;
private Animal cat;
private Animal bird;
public AnimalMaker() {
dog = new Dog();
cat = new Cat();
bird = new Bird();
}
public void dogSpecies(){
dog.species();
}
public void catSpecies(){
cat.species();
}
public void birdSpecies(){
bird.species(); …
About