Git Product home page Git Product logo

designpatterns's Introduction

Programming Design Patterns Build Status

Repository with community-driven docs and examples for Programming Design Patterns

Our mission

We tend to build the most full and up-to-date collection of good quality examples and recommendations on use for all known Programming Design Patterns

Collaborating

To start collaborating:

  • fork this repo, create a branch, checkout that branch, apply your work, push the branch to Github, and send a pull request; or,

  • create a ticket to start a discussion on Github

Using examples

PHP

Our PHP examples were tested against PHP v5.4. We're using PHPUnit (at least v3.17.13) to write and run test suites.

Every regular PHP example should contain following files (unless specified otherwise in README file):

  • %EXAMPLE_NAME%.php - actual pattern code
  • %EXAMPLE_NAME%_test.php - test suit for pattern code
  • %EXAMPLE_NAME%_usage.php - practical use example of pattern code

Here is how you could run an example, say called car, in state pattern:

php state/php/example_car/car_usage.php

..and here is how you could run it's test suit:

phpunit state/php/example_car/car_test.php

If you don't have PHPUnit installed, you can use Composer to install it right inside the project:

composer install

This will create vendor directory with all dependencies. Running a test suite then can be done via:

vendor/bin/phpunit state/php/example_car/car_test.php

Credits

Our work is based on external resources pretty much. Just a few of them are:

License

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to http://unlicense.org/

designpatterns's People

Contributors

raslin avatar sergeylukin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

designpatterns's Issues

PHP examples directory structure

There are few ways to manage files structure inside each pattern's php directory. Please vote.

  1. Each example in it's own directory
└─┬ php/
  ├── composer.json
  ├── composer.lock
  ├─┬ example_car/
  │ ├── car.php
  │ └── car_test.php
  ├─┬ example_delivery/
  │ ├── delivery.php
  │ └── delivery_test.php
  └── vendor/
  1. All examples in one dedicated directory:
└─┬ php/
  ├── composer.json
  ├── composer.lock
  ├─┬ example/
  │ ├── car.php
  │ └── delivery.php
  ├─┬ test/
  │ ├── car_test.php
  │ └── delivery_test.php
  └── vendor/
  1. All examples in root directory:
└─┬ php/
  ├── composer.json
  ├── composer.lock
  ├── example_car.php
  ├── example_delivery.php
  ├─┬ test/
  │ ├── example_car_test.php
  │ └── example_delivery_test.php
  └── vendor/

Do we really need composer?

I think we can remove all composer.json and all composer.lock files.
Originally I added them to have the ability to easily install PHPUnit right inside our repo, but as far as I see now, it's better to rely on having PHPUnit installed as a general dependency of our project.. as those files look like something that shouldn't be there. What do you think?

Comparison of similar patterns

After we finish adding the most known patterns to our list, we need to provide a clear comparison of differences between similar ones, for example such patterns like:

  • Facade and Gateway
  • Decorator and Visitor
  • etc.

This is very important as until now there is a big misunderstanding of what pattern should be used when and where. Also using wrong pattern may not necessary lead to a not working software, so it's very easy not to realize that a wrong pattern was used in particular case.

After such document will be started, it should be updated regulary with new patterns added.

Credits and external resources

I think we need to agree on a way we mention external resources in our works.

Here is my proposal:

  • in README.md we should mention general resources we found helpful, like name of Book, name of Course, name of online resource like Wikipedia, StackOverflow, etc.
  • in %pattern%/README.md we should mention resources we used to collect information on specific pattern, like URL of article on specific pattern, specific chapter of a book, post on StackOverflow, etc.

What do you think?

SVG for UML

We need to find a free tool for easy generation of UML diagrams in SVG format

Rebase before merging pull requests

In order to keep Git tree growing in length and not in width which can make it hard to browse, I propose rebasing Pull Request against up-to-date master branch before merging if requested branch's HEAD is behind master's HEAD by more than 1 commit. As far as I know the best result is achieved if pull request initiator does that.
Please share your questions, thoughts on this topic here.

Describe contribution flow

We need a clean way of collaboration for everyone who wants to contribute to our community-driven project. Here are some major issues we need to solve with it:

  • Every addition/modification merged to master branch should pass a voting/discussing stage by group members
  • Everyone should be able to propose/ask for addition/modification without sending a pull request
  • Every group member should be notified about every addition/modification coming to the project

Contributing

I think we should agree on the way we contribute. My proposal is to exclude any direct PUSHes, in order to avoid disagreement on anything that gets into master branch. Everything should go through Pull Request, even if it is one word replacement.

What do you think?

Prototype for pattern's README

After adding most known patterns to our list and having enough README files in place, we'll need to overview the format of README file we want to stick to and propose a single prototype that will be used across all README files.

Consistency in Documentation across all patterns is important because:

  • it's easier to read/understand/get used to one format of documentation
  • it can be automatically parsed by script in the future (for a project's website?)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.