Update for 15-03-22 22:30
This commit is contained in:
parent
8a77ea249f
commit
f2ac305bfb
@ -58,6 +58,26 @@ Different ways to store and operate on data, with differing efficiency
|
|||||||
* [[machine_learning|Machine Learning]]
|
* [[machine_learning|Machine Learning]]
|
||||||
* [[neural|Neural Networks]]
|
* [[neural|Neural Networks]]
|
||||||
|
|
||||||
|
== Programming patterns ==
|
||||||
|
|
||||||
|
=== Creational ===
|
||||||
|
|
||||||
|
* [[singleton]]
|
||||||
|
* [[prototype]]
|
||||||
|
|
||||||
|
=== Structural ===
|
||||||
|
|
||||||
|
=== Behavioral ===
|
||||||
|
|
||||||
|
* builder
|
||||||
|
* factory
|
||||||
|
* facade
|
||||||
|
* proxy
|
||||||
|
* iterator
|
||||||
|
* observer
|
||||||
|
* mediator
|
||||||
|
* state
|
||||||
|
|
||||||
== Common operations ==
|
== Common operations ==
|
||||||
|
|
||||||
* [[gcd]] - Find the GCD of two numbers
|
* [[gcd]] - Find the GCD of two numbers
|
||||||
|
8
tech/prototype.wiki
Normal file
8
tech/prototype.wiki
Normal 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
23
tech/singleton.wiki
Normal 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
|
Loading…
Reference in New Issue
Block a user