Update for 15-03-22 22:30

This commit is contained in:
Tyler Perkins 2022-03-15 22:30:01 -04:00
parent 8a77ea249f
commit f2ac305bfb
3 changed files with 51 additions and 0 deletions

View File

@ -58,6 +58,26 @@ Different ways to store and operate on data, with differing efficiency
* [[machine_learning|Machine Learning]]
* [[neural|Neural Networks]]
== Programming patterns ==
=== Creational ===
* [[singleton]]
* [[prototype]]
=== Structural ===
=== Behavioral ===
* builder
* factory
* facade
* proxy
* iterator
* observer
* mediator
* state
== Common operations ==
* [[gcd]] - Find the GCD of two numbers

8
tech/prototype.wiki Normal file
View File

@ -0,0 +1,8 @@
= Prototype =
This is a design pattern where we copy an existing object without making the
code dependent on their classes.
The general idea is sometimes we need an exact clone of an object. We cant copy
the object exactly from the outside, as we dont know the private fields.
Therefore, the object can implement a `clone` method

23
tech/singleton.wiki Normal file
View File

@ -0,0 +1,23 @@
= Singleton =
A singleton is a design pattern in which a class has only one instance, and
that instance is globally accessable. This is often important for use in shared
resources, such as a file, database connection, or logging application.
== Implementation ==
* Make the default constructor private, preventing other objects from using
`new`
* Create a static creation method that acts as a constructor. This method calls
a private constructor and instantiates a static field, which is the
singleton. All further calls return a reference to this cached, static
object.
== Use case ==
* strict control over global vars
* instance where a single instance of an object is required
== Cons ==
* Take special care to not instantiate several in a multithreaded enviroment