Coder Social home page Coder Social logo

Code readability about ddbus HOT 3 CLOSED

thaven avatar thaven commented on June 14, 2024
Code readability

from ddbus.

Comments (3)

WebFreak001 avatar WebFreak001 commented on June 14, 2024 1

I agree, it was bothering me when I was working with it too. But in order to keep this consistent we should be using dfmt. Something which comes close to your suggestions with dfmt would be this editorconfig:

[*]
dfmt_brace_style = otbs
dfmt_space_after_keywords = true
dfmt_space_after_cast = true
indent_style = space
indent_size = 2

from ddbus.

thaven avatar thaven commented on June 14, 2024 1

I agree auto-formatting would generally be the right thing to do. However, dfmt actually doesn't really do its full job yet. (For example, when applying otbs style, it won't add braces to single-line conditionals.)

Also, it does not seem to support a style that places braces the way I'd like them. When limiting our choices to what dfmt supports, it's tempting to go with 'allman', as it's the only one that places the opening brace of a function on its own line (which I'd really like).

Also, dfmt doesn't respect a choice to list function parameters vertically when they won't fit on one line. E.g. (from ddbus.exception)

package T wrapErrors(T)(
  T delegate(DBusError *err) del,
  string file = __FILE__,
  size_t line = __LINE__,
  Throwable next = null
) {
  // ...
}

gets reformatted by dfmt (otbs style) like

package T wrapErrors(T)(T delegate(DBusError* err) del, string file = __FILE__,
    size_t line = __LINE__, Throwable next = null) {
  // ...
}

The first one is definitely more readable.

So yes, dfmt will certainly help maintaining a consistent formatting, but it won't bring us optimal readability.

from ddbus.

trishume avatar trishume commented on June 14, 2024

I'm okay with this. If @WebFreak001 is also okay with this, go ahead.

from ddbus.

Related Issues (19)

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.