Giter VIP home page Giter VIP logo

clean-arch's People

Contributors

regalius avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

clean-arch's Issues

Add paging example

GetByFilter(ctx context.Context, filter Filter)

we can add paging functionality example.

Standardize all the repo to use one paging format, example :

GetAll(ctx context.Context, pageNum int, pageSize int)
GetByFilter(ctx context.Context, filter Filter, pageNum int, pageSize int)

Bring this behavior through usecase until repository.

We can even bring this to delivery, will be different discussion but we can have 1 function for paging across functionality.

// ReadPagingInfo get paging info from request
func ReadPagingInfo(r *http.Request) (pageNumber int, pageSize int, err error) {
	page := r.FormValue("page")
	size := r.FormValue("size")

	pageNumber, err = strconv.Atoi(page)
	if err != nil {
		return 0, 0, fmt.Errorf("ReadPagingInfo failed parsing pageNumber : " + err.Error())
	}
	pageSize, err = strconv.Atoi(size)
	if err != nil {
		return 0, 0, fmt.Errorf("ReadPagingInfo failed : pageSize " + err.Error())
	}
	return
}

Long variable and struct name

DefaultGetRecommendationForUserIDOptions = GetRecommendationForUserIDOptions{

Let's create simple and short for variables and struct name, IMHO
Becase this struct/variable in product-recom package, when we use it we should already know what's the context (product-recom).

Maybe Options is enough

	DefaultOptions = Options{
		Limit: 5,
	}

Later when some package need this

import productRecom ../../../product-recom

productRecom.DefaultOptions

Stay away from makefile or be careful on it

In my opinion we must as best as possible not using makefile.
https://hackernoon.com/why-not-make-db142ccb2081

But if we want to use it, better to make it as simple as possible, don't use make for any fancy stuff - it will hurt (https://github.com/wejick/mattermost-server/blob/master/Makefile).

good reading : https://sahilm.com/makefiles-for-golang/
or check what content team is doing with makefile, which concise enough

Non CRUD method on model level (was Product uri generation should be on usecase? )

func (p Product) getURL(baseURL string) (result string) {

I think product link uri generation should be on usecase. It needs several logic not related on how we store product, like web, mobile, applink generation.

In general I would say non crud operation should not be here, we should have it on usecase or repository level (I prefer on usecase level tho).

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.