+ 2
Recommended resources on Algorithms, Data Structure and Design Patterns
I'm exploring "By The Community" section and read about Algorithms. While the explanation seems easy to understand, without a code snippet and real life examples, I tend to forgot what I learned. By real life examples I mean something we can actually encounter in everyday life, not a simplified binary search on a random list. Given the experience from Algorithms course, I expect Data Structure and Design Pattern have the same writing style. Would anyone recommended some material (online or book) which is suitable for people like me without Computer Science background but have basic knowledge about coding?
11 Réponses
+ 3
https://en.wikibooks.org/wiki/Computer_Science_Design_Patterns
This have C++ examples.
One thing I think about often is that design patterns are mostly for the human programmer. It is a way to abstract and manage data flow. When the program is compiled, all these are stripped away and depending on compiler optimization, what is really implemented is often unrecognizable from the abstraction we created. We might even end up with a sub-optimal performance.
There is this debate on clean code vs performance. You can google "clean code vs performance"
But if the performance hit is not too big, always go for clean code. The modern compiler can usually do the optimization for us. Unless we create spaghetti code from too much abstraction and misuse of design patterns...
While you explore design patterns, here is a nice link about anti-patterns to look out for
https://www.sciencedirect.com/topics/computer-science/spaghetti-code#:~:text=The%20Spaghetti%20Code%20is%20a,of%20global%20variables%20%5B28%5D.
+ 3
These are my recommendations:
https://adspthepodcast.com/
https://refactoring.guru/
https://mishadoff.com/blog/clojure-design-patterns/
Regarding the last one, it is about the Clojure language but nonetheless it can be very interesting for any programmer. It takes many small examples and compares coding it with a traditional "design pattern" approach vs. using a functional style. A language that supports higher order functions, for example even Python or Javascript, can make the implementation of these patterns radically simpler than what is possible with pure OOP.
Also, the Youtube channel of ArjanCodes is worth checking.
https://www.arjancodes.com/
+ 3
The design patterns are, as you say, sort of "industry best practices" and some of them actually lose their relevance over time, as the languages themselves evolve. They are meant for software engineers as blueprints, template solutions, with the goal in mind, to create software that is easier to extend and maintain in the long run. So these usually are not so helpful for coding competitions, especially when coding a quick and dirty (but working) one-off solution beats maintainability.
AoC is more about choosing the right data structure that fits the problem best - or create a custom structure to comply with specific conditions. Some days are pretty easy even for beginners, that competitive coders are able to clear within just minutes. But other times, performance optimization is critical, and you need a good understanding of even the more hidden features of the language you are using. Some of them have a clever math solution, so knowing about a specific formula or method is definitely an advantage.
+ 3
Tibor Santa
I think your link about Clojure illustrate how design pattern can be "decayed" when new languages or methods invented. But I think new design pattern will emerge for different kind of language.
However it doesn't mean the "old" design pattern become obsolete.
For an office worker if he decided to automatic his work best bet he will using VBA and writing code in procedure style. If the working environment allows him to install any programming language he likes (small size company usually doesn't has tight control on their employees), he may use Java or Python and write it in functional / OOP.
So knowing more lets you pick the most suitable method with limited resources on hand.
While reading resources I found on the net, I'm already thinking revisit day 5 part 2 using of numpy with different approach…
+ 3
Of course knowing about all the design patterns is important because you must be able to recognise them in old codebases.
What I meant by becoming obsolete, is that new language features can make some old patterns unnecessary and tedious.
As an example, Java 8 introduced streams and functional interfaces, these two language innovations alone, make many old patterns unnecessary.
I recommend this youtube video to illustrate the point:
https://youtu.be/V7iW27F9oog?si=G18Mn1UwFJbIJGDe
"Design Patterns revisited in Modern Java, by Venkat Subramaniam"
posted on channel "Devoxx UK"
+ 2
Tibor Santa
That clojure link was fun..😎
+ 2
Bob_Li Tibor Santa
I have a cold so I just skimmed the links last night.
My first impression is that design pattern can best describe as 'best practices', like different blueprints for different kinds of problems.
But what in my mind is that, when a problem presented, you have to figure out the problem nature. Then you break it into smaller parts (design pattern), and implement the solutions (algorithm). While you start writing code you may want to organize the data to fit the algorithm (data structure).
In my experience of AoC this year, I can write clean code and pass the example / first part of the quiz. In second part however the original solution may not work due to some additional requirement (design pattern), or your original solution works if brute force and take days to compute, which force you to think a new approach (algorithm / data structure).
Therefore I want to read more cases and learn how to better understand / recognize the problem nature and learn new techniques along the way.
+ 2
AoC seems to be more geared towards optimized performance than neatly implemented design patterns. Being able ro take advantage of your chosen language's native optimized methods and operations could give you a bigger advantage in performance overall.
+ 2
With 44 questions released (assume you complete part 1 everyday) at the moment I'm able to finished 27 of them.
For those unsolved questions I put them into following category: 1. Totally don't understand the problem (rare); 2. Cannot come up with a solution completely (few); 3. Partially working, missing a few components or bad coding skill; 4. Brute force solution (actually I have one did the job under 200 seconds).
I believe if I read more cases (more design pattern learned) I can solved more quizzes if not all. And if I know more about algorithms and data structure, I can write a better code than using brute force.
Anything helps is welcome.
+ 2
And pattern matching.
C#, Java and Python all have it now and it's a really powerful tool.
0
Jay Matthews
It doesn't matter. If I read and don't like the material, at least I have some keyword to search.
It is like if you search for "algorithm" in google, it returns many results to you. But without any knowledge you wouldn't know the terms "binary search" and search with this keyword.
I asked because I'm doing what you say, solving quiz on Advent of Code, and I think with some knowledge on those things I mentioned helps to come up with solutions.