Code Monkey home page Code Monkey logo

akorwash / quizbattle Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 1.0 11.4 MB

Quiz Battle is a cognitive game something like "Saif Almarifa", In our game players own their questions as "Card" and they can trade their "cards " with others or challenge them in "public/private" battles.

Home Page: https://www.quizzbattle.com/

License: MIT License

Go 56.22% HTML 21.20% CSS 3.06% JavaScript 19.01% Dockerfile 0.52%
firestore-database golang gorilla-mux mongodb websockets

quizbattle's People

Contributors

ahmedfat7y avatar ahmedkorwash avatar akorwash avatar emad-elsaid avatar resata avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

ahmedfat7y

quizbattle's Issues

Swagger Documentation needed

Describe the solution you'd like
Add swagger documentation for project, at least you can add documentation for 2 endpoints
non-auth required and another auth required.
Please document your work, i will follow your code and apply for whole project.

Describe alternatives you've considered
you can use swaggo/swag or go-swagger

Code review

  • You should add .vscode file to .gitignore.
    If you are working within a team, you don't want to enforce your editor's settings on other team members. Or even to others who want to contribute to your repo.

  • I see some inconsistencies in your naming for folders and files. Some are camelCase and others are SnakeCase.
    I think the convention is to use lower case letters for both folders and files. Here are a few examples from net/http
    filetransport.go, httputil

  • Check these slides for some naming tips.
    https://talks.golang.org/2014/names.slide#1

  • Avoid nesting if possible. For example:

func (startup *Startup) LoadQuestions() *Startup {
	if startup.Errors != nil {
		return startup
	}

	if len(engine.QuestionSet) <= 0 {
		for i := 1; i <= 100; i++ {
			question := engine.NewQuestion(i, "test question #"+strconv.Itoa(i))
			engine.QuestionSet = append(engine.QuestionSet, *question)
		}
	}
	return startup
}

Better be:

func (startup *Startup) LoadQuestions() { 
        const lim = 100 // use constants instead of the magic values and choose a better name than `lim` I don't know the context so I couldn't choose a better name ๐Ÿ˜ข . You can also decide if this needs to go global, be exported, add it to Startup struct, etc...

	if startup.Errors != nil || len(engine.QuestionSet) == 0 {
		return
	}
	for i := 1; i <= lim; i++ {
		q := engine.NewQuestion(i, "test question #"+strconv.Itoa(i))
		engine.QuestionSet = append(engine.QuestionSet, *q)
	}
}
  • In datastore/entities instead of having multiple files, I think it's better to have them all in datastore/entities/entities.go
    And as the package name is called entities so you better drop the EntitySuffix from the structs' names.
    Instead of type AnswerEntity struct{}, let it be type Answer struct{}
    Put in mind that when you use this from outside the package you will write entities.AnswerEntity you will find that entity is written twice, while entities. entities.Answer is clean enough.

  • I see you are already applying some good practices, like sorting and grouping the imports, and others ๐Ÿ‘ Good work ๐ŸŽ‰ .

  • There are other parts with areas of improvement. But these are the points I noticed from a glance.
    If you find it helpful, I will try to give more feedback when I get some free time.

  • Pro Bro tips:

    • Check this youtube channel, there are a couple of videos where the guy clones a repo, and refactor it. I have learned a lot from this guy.
    • Explore some of the standard libraries. They have great stuff, and I have learned a couple of useful patterns while checking them, you can also get some good practices from them.
    • Write more documentation, maybe update the README file with some instructions on how to run the project locally.
      Also check this
    • Dude, you are missing a lot of fun by not writing unit tests!
      There's a couple of plugins to help you generate a skeleton for testing a function. They almost do all the work, and you will have to only fill a table by some data/structs.
      Give a try to writing unit tests and even better if you work in TDD, like solid programmers (I am not one of them yet, ed3ily).
      A very popular way is Table Driven Tests. You can check it on some of the standard libraries like net/http.
  • A recommendation:
    From the parts I have checked, I didn't see any usage of channels. Which is fine, but if you want a simple task to use/learn channels, check how you can do a graceful shutdown, so that when the user terminates the program by ctrl+c, the program stop taking any actions from the user but keeps the system up till it shutdowns all running services successfully. Or maybe to save the state of your game or whatever is in engine.ExitTheGame().
    And maybe rename ExitTheGame to Shutdown, Exit or Close.

test cases running concurrently

Describe the bug
When I added new test cases for my project and run it through go test ./...
sometimes my tests faild due to mis mataching ids or object when retriving it from mongo database.

what actually happend
multiple test cases running at the sametime "concurrently ", and each test case seed object or multiple object to database
and the problem comes when the test case try to retrive object from database sometime another test case delete or modify it.

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.