Giter Site home page Giter Site logo

Comments (3)

abreathingcorpse avatar abreathingcorpse commented on June 14, 2024

While reading a little bit further I got to the 6.6.7 Number of methods / fields / variables section.
It says the following:

[...], this is a breach of the single responsibility principle [...]

Which makes me wonder when you said earlier:

Counting (automatically) the number of coding style breaches [...]

Did you meant that having more than a single Code Style is considered a breach?

from 2dgd_f0th.

Penaz91 avatar Penaz91 commented on June 14, 2024

It seems I created quite a bit of confusion here, my deepest apologies.

At first I thought that you meant something like Python's PEP 8

That is exactly what I meant, but elevated to an "error status" of sorts. You decide on a coding convention and stick to it. This is especially important if your project has a long duration or if you're working with other people. If everyone codes in a different way (stylistically speaking) the resulting code will be harder to read and maintain.


[...], this is a breach of the single responsibility principle [...]

The "single responsibility principle" is a coding principle where something (a function or a class, for instance) should do one and only one thing.

Breaching this principle leads to creating "God objects", which are objects that "do everything" as well as other so-called "code smells".

To make a silly example: you wouldn't trust a light fixture that also dispenses water, right? It's doing too many things (it has too many responsibilities) and some of them collide with each other (from a safety perspective in this case). It's way better having a light fixture that lights up your room and a faucet for the water.


Did you meant that having more than a single Code Style is considered a breach?

In a way, yes. If the team decides on a coding style, they should stick to it. A "coding style breach" of PEP8 (although a minor one) could be having lines longer than 79 characters.

Reading code is already hard, you're focusing on what the code is doing, if how the code is written changes from one file to another (or even inside the same file!) this will just add one more thing you have to mentally worry about.


In conclusion, my usage of "breach" was more geared towards "infringement" than actual security issues.

Hopefully this helps a bit!

from 2dgd_f0th.

abreathingcorpse avatar abreathingcorpse commented on June 14, 2024

This makes sense, thanks man.

from 2dgd_f0th.

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.