Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ This repository maintained by [Nick Scialli](https://twitter.com/nas5w) and powe

- [Merge Sort](/src/algorithms/sorting/mergeSort.js)
- [Quick Sort](/src/algorithms/sorting/quickSort.js)
- TODO: Bucket Sort
- [Bucket Sort](/src/algorithms/sorting/bucketSort.js)
- [Heap Sort](/src/algorithms/sorting/heapSort.js)
- [Counting Sort](/src/algorithms/sorting/countingSort.js)
- [Bubble Sort](/src/algorithms/sorting/bubbleSort.js)
- [Selection Sort](/src/algorithms/sorting/selectionSort.js)
- [Insertion Sort](/src/algorithms/sorting/insertionSort.js)
- TODO: Shell Sort
- [Shell Sort](/src/algorithms/sorting/shellSort.js)

- Searching

- [Linear Search](https://github.com/nas5w/javascript-patterns/blob/master/src/algorithms/searching/linearSearch.js)
- [Binary Search](https://github.com/nas5w/javascript-patterns/blob/master/src/algorithms/searching/binarySearch.js)
- TODO: Jump Search
- TODO: Interpolation Search
- TODO: Exponential Search
- [Jump Search](https://github.com/nas5w/javascript-patterns/blob/master/src/algorithms/searching/jumpSearch.js)
- [Interpolation Search](https://github.com/nas5w/javascript-patterns/blob/master/src/algorithms/searching/interpolationSearch.js)
- [Exponential Search](https://github.com/nas5w/javascript-patterns/blob/master/src/algorithms/searching/exponentialSearch.js)
- TODO: Sublist Search (Search a linked list in another list)
- TODO: Fibonacci Search
- [Fibonacci Search](https://github.com/nas5w/javascript-patterns/blob/master/src/algorithms/searching/fibonacciSearch.js)
- TODO: The Ubiquitous Binary Search

## Patterns
Expand Down
34 changes: 34 additions & 0 deletions src/patterns/facade/Course.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* eslint-disable no-console */
class Course {
constructor(data) {
this.name = data.name;
this.project = data.project;
this.completed = data.completed || false;
}
}

const CourseServices = (() => {
return {
complete: Course => {
Course.completed = true;
console.log("Completing course", Course.name);
},
save: Course => {
console.log("Saving course", Course.name);
}
};
})();

const CourseServicesFacade = (() => {
const Complete = (Course) => {
CourseServices.complete(Course)
if (Course.completed) {
CourseServices.save(Course)
}
}
return {
CompleteMethod: Complete
}
})();

module.exports = { Course, CourseServicesFacade };
13 changes: 13 additions & 0 deletions src/patterns/facade/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-disable no-console */
const {Course, CourseServicesFacade} = require("./Course");

const myCourse = new Course({
name: "Design Pattern",
project: "Facade Design Pattern App"
});

console.log("myCourse-1: ", myCourse);

CourseServicesFacade.CompleteMethod(myCourse)

console.log("myCourse-2: ", myCourse)