Giter Club home page Giter Club logo

Comments (11)

JohnSundell avatar JohnSundell commented on May 18, 2024 1

The way I would name the above method is:

func spotable(_ spot: Spotable, itemSelected item: Item, view: SpotView)

Reasoning: The first argument should always match the object that you're the delegate for. This is both in line with Apple's naming convention, but also improves API discoverability and makes for an easier grouping of methods (and better auto complete). _ is used because it's clear from the method name that the first argument is going to be a Spotable. The verb is not formulated as didSelect because in this case the Spot itself didn't select the item - the user did. This would be different if it was (for example) an image loader that itself downloaded an image (func imageLoader(_ imageLoader: ImageLoader, didLoadImage image: UIImage)).

from spots.

zenangst avatar zenangst commented on May 18, 2024 1

Oh, I don't think I'm torn anymore 😁
I like this suggestion, it would of course have implications for the other delegate proposals that I've made but I think this would be a good way to go.

from spots.

onmyway133 avatar onmyway133 commented on May 18, 2024

@zenangst yeah we could do that. For now I think we can use ui method to retrieve the View?

from spots.

zenangst avatar zenangst commented on May 18, 2024

This is correct :)

from spots.

vadymmarkov avatar vadymmarkov commented on May 18, 2024

Would be a nice addition 👍

from spots.

zenangst avatar zenangst commented on May 18, 2024

I propose that the version 6.0.0 version would look something like this;

func spotsDidSelect(view: SpotView, item: Item, in spot: Spotable) {

from spots.

zenangst avatar zenangst commented on May 18, 2024

@JohnSundell mentioned a variation of this that can also be very interesting (sorry mate, forgot about that).

It would end up looking something like this:

func spot(view: SpotView, _ spot: Spotable, itemSelected item: Item)

I just thought about another variant.

func spotsDid(selectView view: SpotView, itemSelected item: Item, in spot: Spotable)

from spots.

zenangst avatar zenangst commented on May 18, 2024

torn

from spots.

zenangst avatar zenangst commented on May 18, 2024

What do you guys think @hyperoslo/ios ?

from spots.

vadymmarkov avatar vadymmarkov commented on May 18, 2024

I like @JohnSundell's suggestion, the only thing I' not sure about is spotable in the name.

from spots.

zenangst avatar zenangst commented on May 18, 2024

I think it makes sense in the context, however... I don't know if I would make that connection straight away as the intention on what happened is located later in the signature. But it would be easily scoped into spot.. which would make it super easy to discover the methods. Also like @JohnSundell described, if you imply it in the method name, you can drop the first label.

from spots.

Related Issues (20)

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.