Overview

The business delegate is used to separate the business side and presentation side. The business side is made up of 4 parts:

  • Client — The presentation code to display the data
  • Business Delegate — Provides access to the business service methods which the client uses
  • LookUp Service — Responsible to get relative business implementation and provides business object access to business delegate object
  • Business Service — The concrete class implements the business service interface to provide business implementation logic
Image for post
Photo by Charles Forerunner on Unsplash

Implementation

BusinessService.java

public interface BusinessService {
public void doSomething();
}

The business interface that the concrete class implements

ServiceOne.java

public class ServiceOne implements BusinessService {
@Override
public void doSomething() {
System.out.println("Something One!"); …


Overview

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.

Image for post
https://blog.penjee.com/passing-by-value-vs-by-reference-java-graphical/#:~:text=The%20terms%20%E2%80%9Cpass%20by%20value,where%20the%20value%20is%20stored.

Pass By Reference

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…


Overview

The main use of the Transfer Object Pattern is to pass data with multiple attributes at once. It is made up of 3 parts:

  • Transfer Object — Simple Plain Old Java Object(POJO) which just has getters and setters
  • Business Object — Contains the logic that manipulates the transfer object.
  • Client — Passes or gets transfer object from the business object
Image for post
Photo by Markus Winkler on Unsplash

Implementation

Transfer Object

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 …


Overview

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.

Image for post
Photo by Markus Spiske on Unsplash

Parent 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)

Child Class

The child class can be a typical class but you just need to wrap the parent class in parenthesis right after the child class. …


Overview

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:

  • No bindings to this or super so it should not be used inside object if they are to be methods
  • No access to arguments or new.target
  • Should not be used with call, apply and bind methods because they rely on a scope or the current context where it is being executed
  • Cannot be used as a constructor
  • Cannot use yield in its definition
Image for post
Photo by Nick Fewings on Unsplash

Implementation

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 is a short block of code that is a function do not have a name

Overview

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.

Image for post
Photo by Markus Spiske on Unsplash

Implementation

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. …


Overview

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.

Image for post
https://devclass.com/wp-content/uploads/2018/10/lambda.jpeg

Implementation

Normal Implementation

def add(x, y):
return x + y

Lambda Implementation

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.

Assignment

You can save the lambda function by setting a variable equal to the lambda function. …


Overview

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.

Image for post
Photo by Markus Spiske on Unsplash

Binary and Decimal

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. …


Overview

As the name suggests MVC design patterns involves 3 parts:

  • Model — The object that contains the data. It should contain no logic to display data.
  • View — Presents the data to the user. It should only have the logic to display the data and not any logic to manipulate it.
  • Controller — Controls the data flow between the model and view keeping the two of them separate. The view triggers events that cause the controller to change the model.
Image for post
Photo by Halacious on Unsplash

Implementation

Model

// 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 …


Overview

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.

Image for post
Photo by Daniel von Appen on Unsplash

Implementation

Interface

// Animal.java
public interface Animal {
void species();
}

Interface for concrete class.

Class Implementation

// 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");
}
}

Facade

// 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

Daniel Liu

Hi

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store