FAQ
Hi folks,

I wanted to ask the opinion of people here. If you had a data structure

type A struct {
Id string
Name string
Source string
}

and based on the Source value you needed to connect to one of two different
services to resolve a float64 based on a *time.Time, where the two services
had APIs such that one only allowed for a single A to be resolved at a time
while another took a sequence of A, do you think you would be more inclined
to

(a) create a functions for each service lookup type, e.g.,

resolveServiceType1(a A, t *time.Time) float64
resolveServiceType2(a []A, t *time.Time) []float64

(b) create functions to operate on a struct Set []A that could resolve a
slice of a Set as needed?

type Set []A
func (set Set) Resolve(t *time.T) []float64

under the hood this Resolve function would have to examine the A.Source to
determine whether or not it had to make many resolver calls or could batch
them into one

(c) create something more elaborate?

Jim

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Dave Cheney at Mar 27, 2013 at 5:05 am
    Why are you passing a pointer to a time.Time ?
    On Wed, Mar 27, 2013 at 4:03 PM, Jim Robinson wrote:

    Hi folks,

    I wanted to ask the opinion of people here. If you had a data structure

    type A struct {
    Id string
    Name string
    Source string
    }

    and based on the Source value you needed to connect to one of two different
    services to resolve a float64 based on a *time.Time, where the two services
    had APIs such that one only allowed for a single A to be resolved at a time
    while another took a sequence of A, do you think you would be more inclined
    to

    (a) create a functions for each service lookup type, e.g.,

    resolveServiceType1(a A, t *time.Time) float64
    resolveServiceType2(a []A, t *time.Time) []float64

    (b) create functions to operate on a struct Set []A that could resolve a
    slice of a Set as needed?

    type Set []A
    func (set Set) Resolve(t *time.T) []float64

    under the hood this Resolve function would have to examine the A.Source to
    determine whether or not it had to make many resolver calls or could batch
    them into one

    (c) create something more elaborate?

    Jim

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jim Robinson at Mar 27, 2013 at 5:08 am

    On Tuesday, March 26, 2013 10:04:57 PM UTC-7, Dave Cheney wrote:

    Why are you passing a pointer to a time.Time ?
    I'm not really, I just typed the '*' out of habit from how one used to use
    time.Time in the pre go1 library.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • David DENG at Mar 27, 2013 at 5:39 am
    I may design it as follow:

    resolve(t time.Time, a... A) []float


    And in the implementation, call resolving function one-by-one if the API is
    the first kind.

    David
    On Wednesday, March 27, 2013 1:03:35 PM UTC+8, Jim Robinson wrote:


    Hi folks,

    I wanted to ask the opinion of people here. If you had a data structure

    type A struct {
    Id string
    Name string
    Source string
    }

    and based on the Source value you needed to connect to one of two
    different services to resolve a float64 based on a *time.Time, where the
    two services had APIs such that one only allowed for a single A to be
    resolved at a time while another took a sequence of A, do you think you
    would be more inclined to

    (a) create a functions for each service lookup type, e.g.,

    resolveServiceType1(a A, t *time.Time) float64
    resolveServiceType2(a []A, t *time.Time) []float64

    (b) create functions to operate on a struct Set []A that could resolve a
    slice of a Set as needed?

    type Set []A
    func (set Set) Resolve(t *time.T) []float64

    under the hood this Resolve function would have to examine the A.Source to
    determine whether or not it had to make many resolver calls or could batch
    them into one

    (c) create something more elaborate?

    Jim
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Ask at Mar 27, 2013 at 5:44 am
    If you are not sure then go with whatever seems simpler. It's easier to
    make it more complicated than go the other way as you learn how to work
    with your API.


    Ask

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMar 27, '13 at 5:03a
activeMar 27, '13 at 5:44a
posts5
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase