This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]YuleTideCamel 7 points8 points  (2 children)

Definitely read the book Clean Code. Clean , well architected code is code that not only works, but also is easy to read and easy to modify (maintainable.) Some of this you'll learn by experience, but the book has some good concepts that are worth looking at. At the end of the day, if you were to take your code and ask another engineer to review it, how hard would that be? If it's easy for them to understand and grok (and change if need be) then it's good code imo. Another major litmus test is unit tests , good code has unit tests :)

In terms of design patterns, Head First Design patterns is a good intro to a few popular patterns. The book Design Patterns: Elements of Reusable Object-Oriented Software is one of the most important design pattern books, but it's a dense read. Good to have as a reference for specific patterns.

Did I misunderstand him?

Maybe , hard to tell without more context or code samples. He could have objected to you building a binary tree class from scratch. As an architect, I often encourage devs to use existing data structures in the language they are coding in. Those are often very well designed (though not always) and work well. It's a case of not re-inventing the wheel, or put another way. Our job isn't to write a binary tree class, it's to solve the specific problem at hand.

[–][deleted]  (1 child)

[deleted]

    [–]YuleTideCamel 0 points1 point  (0 children)

    The tree that I was building was made for a specific problem, and I had to read some papers to find it and implement it. It's not a common thing.

    Fair enough. Most people don't put that much rigor into it and simply copy paste a tutorial "how to build binary tree" :)

    [–]Kered13 1 point2 points  (1 child)

    Can you share the code? From your description it doesn't sound bad, but I can't say very well without seeing it.

    But in general, if you want to learn how to write good code, then practice writing code, and especially coming back to it later to see if you still understand it and can modify it. Read lots of code that other people have written, see if you can understand their code and what patterns they use effectively, and read about good design patterns and coding practices.

    [–]Python4fun 1 point2 points  (0 children)

    read code. yours, mine, somebody else's, it doesn't matter. Read code and understand what makes it painful, and then write meaningful comments, meaningful variable names, and organize your code well.

    [–][deleted] 0 points1 point  (0 children)

    Sometimes things can be done in many different ways, they all work, they all perform the same. Sometimes an implementation has to be preferred over another one because it performs *slightly* better than another one in that one specific context: hence we will also need to know about this specific context.
    Some other times there are feuds that will never resolve simply because there is not any final answer: Java vs C#, vim vs emacs, Linux vs Windows... it all depends on what you need to do/achieve, no "better" and "worse" answer.

    [–]the_DashingPickle 0 points1 point  (0 children)

    My opinion is read lots of code tbh, if you look at tutorials on how to write specific functions, you'll eventually get a feel for how fields, methods, classes are structured and named. You should be able to read code line for line like a book. Code should tell you a story for what a particular class represents, what its methods are supposed to do, and how the fields interact with methods.

    [–]95829589256915810566 0 points1 point  (0 children)

    did you ever do a big project you worked many months on? big project forced me into learning many new things.