r/AskComputerScience • • May 29 '18

Where and how can I learn good design practices? (design patterns, applying OOP concepts, modular design, etc)

Hey, interview season is upon me now. Final year of college. Need to learn how to write better code, learn code refactoring.

48 Upvotes

8 comments sorted by

11

u/[deleted] May 29 '18

Well, there's the classic, Clean Code, which I haven't read but have seen recommended as a great book on this topic. But, in my opinion, as with anything else in programming, you get better by doing, and that includes writing better code. The more code you write the more you'll see basic patterns crop up and you'll start to realize what does and doesn't work. Does inheritance make sense here or should I use some type of composition. Is it worth refactoring this piece of code out to a more general abstraction. When I write, I try to have the mindset that someone else will be using my code in the future and I should write my code in a way that is as accessible for them as possible.

1

u/sam_ridhi May 29 '18

Thanks!!

3

u/Scuba_Von_Wolfgang May 29 '18

Clean code is a great book. Other 'Uncle Bob' books are good too like Clean Architecture

Edit: I have read both

4

u/parserrr May 29 '18

I really like this site: https://refactoring.guru/ (Nope, I am not affiliated with them in any way)

2

u/qafir_arnaut May 29 '18

Engineering Software as a Service: An Agile Approach Using Cloud Computing.

It has a chapter on Design patterns in which it explains things in very simple and easy ways. Granted, this is the only book that I have used to learn design patterns, so my sample size is 1.

Good luck!

2

u/khedoros May 29 '18

I've always thought of programming as similar in some ways to painting, drawing, or writing. You can find books on techniques, and books on guidelines for when to apply techniques, but the real trick is learning when to apply a specific technique, when it makes sense to disregard the guidelines, etc. And to do that, I don't think there's a substitute for experience.

As a general habit, I hang around places like news.ycombinator.com (HackerNews). Fairly frequently, there are blog posts about coding techniques, and opinions posted about do's and don't's. Problems with languages, ways that techniques can be applied to specific problems, and so on. I like that buffet style of learning, rather than going through books.

2

u/algorithmcookies May 29 '18

My suggestion is that start with functional approach for simple problems, like converting files to other formats. Then you can write classes like filehandler, try to encapsulate read and write functions in it. Further improvements will be making the filehandler as an interface, then try to design this interface a better way for implementation. That’s the brief idea of practicing. One thing should always keep in mind, there is no shortcut in coding, you are only as good as the count of lines of code!

2

u/thelowhangingfruit May 29 '18

A book I recently read that helped me understand the important and implementation of design patterns was Head First: Design Pattern . The book introduces the concept in an informal way and makes the learning experience fun and worth it.