5

Please, give me tips to write maintainable source code

(Long term)

Comments
  • 13
    Best advice:
    read good quality source.

    Distant second:
    ask for code reviews.

    Very distant third:
    code. the more practice you get, the better.

    Extremely distant fourth:
    read books on clean code.

    Everything else is past Jupiter.
  • 1
    @Root thanks

    Do you know any place where i can read good source code?
  • 4
    @Afrographics
    Pick a library or framework or open source project. If it's open source, you can read it.

    The Linux kernel, Ruby's source, Ruby on Rails, jQuery, Haskell's GHC (compiler), ...

    Almost everything will teach you something.
  • 5
    @Root I disagree. Pop reading about clean code [at least patterns] to the top and only then dive into reading good code. W/o knowing what a pattern is and how is either pattern structured it's hell of an overwhelming task to understand why the fuck is that code written the way it is. And why is this class called a Visitor.. And so on.

    It's like reverse-engineering an application and only then reading its docs
  • 4
    @netikras The best way to learn to write well is to read -- and to read everything you can. Reading only books on writing is a dead-end and gives no practical perspective. In fact, those books are probably the least effective way to learn how to write, and some absolutely do more harm than good.

    I firmly believe the same applies to coding.

    However, if you are not skilled enough to understand the source you are reading, then absolutely return to (or start with) the basics.
  • 0
    @Root my point exactly :) only theory is not enough. One needs practice as well. To do practice one should know the theory and have seen what a good example is. In my exp it always helps to observe good examples while learning the theory. Just watching someone do smth can teach you to be a monkey at best if you do not understand all the WHYs. Hence the theory.
  • 1
    Be hands on: Implement a project , for example a Rest api that connect to a database. By utilizing clean architecture. There are many example on github that give both guidance on theory and code construction for clean architecture/ clean code (SOLID) implementations.
  • 3
    One huge tip: Don't put one-liners in it that perform ten unrelated actions at once.
  • 0
    Write modular
    Make sure you comment reasons for checks
    Documentation, documentation, documentation
    Dont code while drunk
    Inheritance is your friend
    Documentation
    Try your hardest not to crunch
    Limit your stack to as few components as necessary
    Only use whats needed
    I swear to God if i see another static web app in a container I'm going to throw a fit
    Only use whats needed
    Documentation
  • 1
    Whenever you think "holy shit that's smart when i do it like this it works, even though it shouldn't" - stop.
  • 1
    Use Descriptive Names

    Give Each Class/Function One Purpose

    Delete/comments Unnecessary code

    Comments/documents what you think would be really hard to understand

    Write code like a blind man is going to read it
  • 0
    @p0s1x please what is restAPI?
  • 0
    @Afrographics here a guide that i’ve used to mentor my teammates on REST API (REpresential State Transfer)

    https://s3.amazonaws.com/tfpearsone...

    You could also googled it.....

    REST API’s is a communication interface where frontends communicate with to Create, Read, Update and Delete data, otherwise know as CRUD. Google CRUD...
  • 1
    @p0s1x thanks

    I'm reading and it's very interesting
  • 0
    Follow UML.
  • 1
    As a rule zero, be open to feedback and critique and be critical with yourself.

    I HATE those goddamn stupid mofos who can pray and preach every stupid coding guideline without having any common sense... It leads to the worst imaginable code...
  • 1
    @p0s1x after having traversed 16 pages of your manual

    It's like restAPI is the name given to the way that data are transferred between client and server.

    Am i right or completely out of point?🙈
  • 0
    @Afrographics yeah, kind of. Basically it is a concept that descibes how to use HTTP verbs and uris to construct a uniform interface to communicate with for example with a frontend. Rest Apis are also developed by twitter / facebook ect. They have their own api. Try to find the api documentation of the twitter, facebook, stripe ect to build a better mental model.

    Then try to setup / hack your very first api, choose a simple framework, for example nodejs. Keep it super simple, badically a hello world for rest api’s Goodluck!
  • 0
    have a look at these tutorials: https://m.youtube.com/playlist/...
  • 0
    I thought the book clean code helped me with my code style, try giving it a read and learn about different patterns
Add Comment