Git Product home page Git Product logo

Comments (7)

adamhathcock avatar adamhathcock commented on May 29, 2024

I always say conditionals should be forced. Code merge situations can easily change if statements without braces. The braces usually make code not compile on mismerges.

C# 7 features are too good not to use.

from protoactor-dotnet.

adamhathcock avatar adamhathcock commented on May 29, 2024

I mean "force braces on any nested structure" including loops, etc.

from protoactor-dotnet.

rogeralsing avatar rogeralsing commented on May 29, 2024

What about API surface.

Return arrays or IReadonlyList<T> ?

e.g.

public string[] GetNodes()
//vs..
public IReadonlyList<string> GetNodes()

And how far should we push it on in params?
Allow IEnumerable<T> on args of more than one elements rather than arrays?

Internally, we could know that we only use arrays and avoid allocations in favor for a more restricted API.
On the other hand, having a generalized codebase could be nice in the long run.

Thoughts?

from protoactor-dotnet.

adamhathcock avatar adamhathcock commented on May 29, 2024

To be really "correct" I guess readonly lists but i hate coding with them. If people modify the array then they're really killing themselves. How much rope do we give people to hang themselves?

I prefer enumerables as parameters. Let the receiver rebuffer the data if they have to. The receiver should be doing that anyway to guarantee their own copy.

Of course that is subject to perf.

It almost feels like there is a low level and high level set of APIs. Like what is there is low level with arrays. What I'm attempting with DI and a MediatR approach is high level. Maybe think of the API and guidance in that way?

from protoactor-dotnet.

cpx86 avatar cpx86 commented on May 29, 2024

I agree about the style preferences above :)

Regarding collection types, we should actually avoid arrays because creating them is more expensive than lists. Internally I don't see any problem with having Lists as return types, although for public members we should probably strive for IReadOnlyCollection.

from protoactor-dotnet.

adamhathcock avatar adamhathcock commented on May 29, 2024

Arrays are more expensive than lists? Lists use arrays. I must be missing something in your point.

I'm thinking more of the "danger" of giving the user a mutable collection.

from protoactor-dotnet.

cpx86 avatar cpx86 commented on May 29, 2024

A correction: populating arrays is more expensive than lists (because of bounds-checking). OTOH, a List will have a few more allocations. So I guess we'd need to profile it to see which is more important.

Yes the user shouldn't be given mutable collections, but that can be solved by only having the readonly interfaces on public signatures.

from protoactor-dotnet.

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.