Skip to content

Cheatsheets organization #2

Open

Description

@feruzabad

As far as i can see, cheatsheets are both containing implementation and test code. It's better to separate them. We may think to use phpunit to test cheatsheets.

The world "cheatsheets" doesn't sound right to me. I already made a pull request regarding the composer autoloader, so lets put these files under "src" and it's own directory. I can make one example and we can discuss it further.

Activity

  1. 20jam commented on Jun 16, 2020

    @20jam
    Owner

    Yah you are right, I've changed cheatsheets to src now, but I'm not sure how to go about sepatating test code from cheatsheet. please make an example

  2. feruzabad commented on Jun 17, 2020

    @feruzabad
    ContributorAuthor

    I'll make an example and open a pull request. do you want to try phpunit? i can utilize that too. examples can be run systematically. you may search about it can give feedback to me.

  3. 20jam commented on Jun 17, 2020

    @20jam
    Owner

    I think PhpUnit is great framework for testing, but to keep matters simples it is best to leave it out. for now.

    I saw how some repos separate the code from implementation/simulation, which also yields unnecessary complexity.

  4. feruzabad commented on Jun 18, 2020

    @feruzabad
    ContributorAuthor

    I propose the following directory structure. Please inspect and give feedback so i can organize the implementation.

    src/ConcernName/ExampleName

    example1: src/StrategyPattern/FileUploader
    example2: src/StrategyPattern/CacheManager

    So, with this pattern we can have multiple example under same concern.

    We can put test folder and readme file inside the example. (we can consider it after some time.)

  5. 20jam commented on Jun 18, 2020

    @20jam
    Owner

    Nah, directory based navigation and extra setup will make this more complex. I’m actually working on creating a reference for design patterns and am doing exactly what you’ve proposing here.

    Since the examples are small in size and the scope is (doing oop in php) we can have multiple examples in one file. The namespacing and autoloading might be an example where we split the code into multiple files. The good thing of having the implementation and simulation in the same file is only needing to open one file when needing a reference for doing something.

    We need two dirs inside src (examples and challenges). In challenges dir we can have a set of challenges written in readme for people to solve, and the solution in a numbered php file 01.php with the same dir “challenges”.

    I’m excited for having challenges, it will put will we learn under testing.

  6. feruzabad commented on Jun 18, 2020

    @feruzabad
    ContributorAuthor

    Since the examples are small in size and the scope is (doing oop in php) we can have multiple examples in one file. The namespacing and autoloading might be an example where we split the code into multiple files. The good thing of having the implementation and simulation in the same file is only needing to open one file when needing a reference for doing something.

    Putting implementation and test code in to a file violates PSR-1, and it's bad generally considered as bad practise because they are different concerns.

    Files SHOULD either declare symbols (classes, functions, constants, etc.) or cause side-effects (e.g. generate output, change .ini settings, etc.) but SHOULD NOT do both.

    https://www.php-fig.org/psr/psr-1/#1-overview

    Challenges should be located outside of "src" as they are not part of the library/source.

    "Examples" is irrelevant as a vendor/library name. We can think "src" directory as library folder (which it is) so anything irrelevant must located or non-exist in this directory.

  7. 20jam commented on Jun 18, 2020

    @20jam
    Owner

    Thanks for pointing this out, it actually make sense. I must get used to some standard after all. I agree challenges might be best be outside the src. Please open a PR request for the needed changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions