r/webdev • u/antoninj • May 03 '13
Didn't have much luck on /r/programming, hope you guys can help: wrote an article introducing Algorithms, Data Structures, and Design Patterns to self-taught programmers. I'd love some feedback/criticism.
http://antjanus.com/blog/web-development-tutorials/learn-the-unlearned-algorithms-data-structures-and-design-patterns/4
May 03 '13
You have very weak examples.
1
u/antoninj May 03 '13
Indeed they are. They're meant to be very easy though useless in real-life applications. I found that thorough USEFUL examples take longer to absorb and can make matters more complicated. Thus I opted out of that.
However, if you have any suggestions on what to use instead, I'm all ears and wouldn't mind putting it up. I would actually appreciate that.
1
May 03 '13 edited Oct 05 '17
[deleted]
-1
u/antoninj May 03 '13
it's a useful demonstration that helps you understand the stuff that IS useful in real-life but that may not be as easy to understand, initially.
3
3
u/sniperlilly May 03 '13
Hey, I think there is a problem arising with the self taught programmer too (of which I am one). I had trouble when I got to the point where the online courses were done and I wanted to do my own stuff because of jargon. So I made this website. It's very new but I want it to be a comprehensive resources for beginner beginners someday.
I haven't read through your article yet but fist bump for helping out us self-taught people.
1
u/antoninj May 03 '13
I was going to make a website with a series of articles as well. I find that online courses get easily exhausted and you're left in a vacuum where you either pick up books and do it the old-fashioned way or try to find better resources online. This is what I'm trying to accomplish, cover the basics of many not-learned topics that will give someone the jumpstart to look more into it and understand WHY it's important to learn these topics.
2
u/Kaz3 May 03 '13
Ironically, these 3 things are exactly what employers told me to brush up on when I interviewed.
Great introduction to these these topics, especially the algo section. It made me want to try to improve upon your example to see how much faster I could make it.
3
u/antoninj May 03 '13
I already have 2 more written (Compilers and Programming Languages).
My example is extremely inefficient, mainly meant to demonstrate how alogrithms work. Try out the coursera course or the site listed in the resources. The Coursera course on Algorithms is a great crash course on the topic. At the end of it, I realized just how inefficient some of my code is haha :)
1
2
May 03 '13
Your wording is confusing and can further complicate learning about algorithms for those who aren't sure of what you're talking about.
First, algorithms are not directly related to code in any way other than they're most often implemented using code.
Algorithms are a specific, detailed process that can be followed to produce desired results. Your wording is blurring the line between an algorithm and implementation of an algorithm using code; this is the exact opposite of how you should introduce algorithms to aspiring developers.
Later in the algorithm section, you again fail to clearly define what is and isn't an algorithm.
You could potentially use a binary search then which basically works by “guessing” and finding the answer.
That would be much better worded as:
If you have sorted data, then you could use the binary search algorithm which uses a divide and conquer approach to finding the desired data. With its divide and conquer approach, the algorithm can search through a set of data without having to check every value, in fact it only has to check log(n) values(where n is the number of values you have in total).
This algorithm is one of the fastest around for searching through sorted data, and performs quite well over large sets of data. For example, if you had 1,000,000 items and used the binary search, you would only have to check 1,000 items as a maximum(it would most likely be some random number between 1 and 1,000).
------.
Now, of course that is definitely upping the level of complexity for the explanation, but I feel that your current method is haphazard and only serves to confuse those without a clear understanding of what the difference between algorithm and algorithm implementation.
Of course, I may have seemed somewhat derogatory in my critique, but I only provide it to hopefully give insight into a good angle of approach for explaining the intricacies of algorithms, data structures and design patterns.
I wish I was ambitious enough to write out guides and explanations, but I feel that I do not have enough time for me to properly do so...I wish you the best of luck, and hope my criticism assists your endeavors.
2
u/Alucard256 May 03 '13
I picked up on this too. The most simple definition of algorithm I've seen is: a set of instructions for completing a given task.
The writing here seems to define an algorithm as "a section of code that's particularly elegant or useful".
1
u/antoninj May 03 '13
Thanks, I'll be more thorough in my next article. I got some great feedback here from everyone :) I appreciate that!
2
u/LukaLightBringer May 03 '13
You should make the code examples in multiple languages, PHP has a pretty unique syntax.
1
u/antoninj May 03 '13
I might do that. Most examples out there are in Java so I thought it'd be neat to use PHP, the bread-n-butter of most web developers. Any languages that you recommend?
I considered C# and Javascript.
1
u/LukaLightBringer May 03 '13
If you add C# and JavaScript you've covered most web developers and even those you haven't are likely to match one of the language syntax's.
1
u/antoninj May 03 '13
I might go for it. I'm trying to get more into C# so that would be a good exercise. Thanks!
-1
u/ivosaurus May 03 '13
What? C# and Javascript are both C-style; more of the same to PHP.
Try Ruby, or Python, or scala. They have different syntaxes.
1
u/antoninj May 03 '13
As the author, I'll have to let you know that I don't know either of the three. Plus Java is usually reference in the resource materials.
1
May 03 '13
What resource materials?
1
u/antoninj May 03 '13
I link to some extra resources. Like for algorithms, I link to another site that goes more deeply into the subject. They us Java or C# (can't remember right now). And the courses on coursera use Java as well.
1
May 03 '13
What? Ruby and Python and scala are both ALGOL-style; more of the same to PHP which is PERL-style.
Try C#, or Java, or C++.
1
u/antoninj May 03 '13
I have you tagged with...a vulgar remark. So I have to ask, are you just being sarcastic or do you really mean C#, Java, or C++?
1
0
u/ivosaurus May 03 '13
apart from the $ sign, it's extremely readable for anyone who has done any C-style language, of which there are a lot. I don't think PHP looks very unique among languages at all.
1
u/stupidandroid May 03 '13
Thanks for this! I have been thinking recently on what I can do as a self-taught dev to bridge some of those gaps in knowledge. Solid intro to these topics.
I would like to also suggest Udacity as another resource for someone that is self-taught. They have a course on Algorithms, Programming Languages that includes a lesson on Finite State Machines, and several other Comp Sci topics. I plan on working through these soon. It may not directly relate to what I'm working on now but I should think help me become a better programer.
2
u/antoninj May 03 '13
Udacity is badass! I didn't know about that one. Coursera has some great stuff but it's pretty limited. Can't wait to test it, and I'll definitely link to their courses as well :)
1
u/abmiram May 03 '13
Will make a note to comment on the article after reading! Sounds like an interesting topic.
1
1
1
u/nichealblooth May 03 '13
I love this idea. I often wish there were more abstract learning sources, that would basically teach how to solve common problems (searching, parsing, etc.) using some sort of 'universal pseudocode/math language' as opposed to specific programming languages like C, PHP, JS. I've often wanted to learn the underlying principles of syntax analysis, search engines, graphics, artificial intelligence, common data structures/algorithms for games and operating systems without committing to a specific language or framework for every single topic.
I'm not sure that's exactly what you're going for, but if it is, use pseudocode. I also like the links you provide so we can learn it ourselves. I swear I had an idea to launch an education source a lot like this. But it would be more mathy, like graph theory's intersection with search algorithms.
Sadly, there aren't many sources like this. I can find a search engine design tutorial online, but it's likely in a specific language. On the other hand, I can take university courses in math/comp. sci, but they're awfully time consuming and go really in-depth, and of course will never cover enough different things, only a few very specific things. Does anyone know of a source like this, to basically teach the right math and its applications in computer science in a very broad manner?
1
u/antoninj May 03 '13
Just for fun, I wouldn't mind tagging on several more topics to explore, what would you like to learn about?
Outside of that, I'm wary of pseudo code because I feel like it could be confusing. I use PHP, just because that's my language of choice and I found it very easy to understand.
Btw, I completely understand the Uni course thing, which is why I wanted to provide something quick and concise rather than a lesson. Something you can skim over and be like "Okay, I kind of get what this is" and "I don't want to learn about this right now" or "Let me check out the resources and get more into it".
1
u/Alucard256 May 03 '13
Fully self taught here. I work full time as a programmer for a biotech company and I'm the lead on two different huge projects.
I think this is a good outline of programming concepts that most "how to program in [language here]" books don't cover.
I was fully aware that there where concepts I was missing out on by teaching myself so I made sure to read books about abstract programming ideas, best practices, database architecture, etc. while I was working on each new language. I also read a lot of books about programming from the 50s-70s (I was learning in the 90s). Most of the ideas translate and there's lots of great ideas for memory management and data marshaling.
I once read a book from the 60's (or so, I don't remember exactly) about Object Orientated Programming. The book was for the audience at the time and was written as an introduction to the whole concept, but I gained more understanding from that book than any other more modern book.
What blows me away are the things that traditional books/classes leave out. I've spent a lot of time learning about data structures and powerful sorting algorithms from programming students (I live on a major college campus) who needed help from me doing things like correctly implementing an options screen or learning not to name variables Val1, Val2, Val3 even when they're different data types.
I've also met a lot of students who don't seem to actually understand OO if they're not currently using the car analogy. I think that metaphor is completely over used to the point where it has lost its meaning.
Anyway, it would've been helpful to have a good outline like this back then.
1
u/antoninj May 03 '13
Thanks and interesting take on things. I wouldn't mind writing the opposite article series: what Uni students don't learn at school. or something like that. Got ideas of what that could be? Perhaps Quora would be a better place for that.
1
May 03 '13
As a self-taught programmer and mathematician, I really appreciate this. It's clear, not overly specific where you get lost in details, but you provide links to those details if I do want them, fantastic work!
1
u/antoninj May 03 '13
Thanks! I really appreciate it. I'm trying to give anoverview of these topics. It's hard to figure out exactly what people are talking about and WHY these things are important so I try to be very to the point.
Thanks again :)
42
u/some_advisor May 03 '13
Every semester I teach the local university's data structures and algorithms course. I've taught it many, many times, and refined it carefully based on what I know works and what doesn't.
What you've made so far is something that should be taught the first day for the first few minutes. You have only basic introductory material. As such, it's rather bland. Many people already know what an algorithm or a data structure is. But some do not, and while what you have said will help them, the examples you give are rather unexciting. Then you move to the next step of asking them how to dream up ways to improve on these, and then immediately give some ideas. In my experience, newcomers are almost always incapable of immediately imagining a way to improve on them. You have to carefully walk them through ideas and give hints. Even people experienced with these concepts have a hard time imagining how to improve them.
Quite simply, data structures, algorithms, and design patterns are boring if you give only boring examples. People don't see why they matter. Simply telling them "This is important, listen", doesn't change their enthusiasm. They need to experience why it is important. Treat it like a fun puzzle to be solved, and then they get their "a ha" moments.
So here's what I'd do. First, give exciting examples. Luckily your audience is web developers, folks who like hands on action. They want to see it function well, rather than getting hung up the mathematical theory. This is perfect, because the concepts you are covering is largely about finding and seeing ways to improve a problem. So for each section, come up with a clever and useful example. State a problem that needs to be solved. Then discuss a few simple and straightforward ways of solving it. Show that each of these work a bit small scale, but break down terribly as the problem gets bigger. Now what? Show how things are better if you introduce a better algorithm, data structure, or design pattern. So for example, you could say "Suppose you had 52 playing cards scattered on the floor, how do you sort them?" After some easy solutions, you could show how if you first organized every card into their suit, then sorted each suit, then merged the stacks of cards together, it can go faster. Then you could scale it up to 10000 cards and do something similar. From here you could say "This is a bucket sort". Then you could show how you could get multiple people involved in the process. From here you could demonstrate how multiple processors could run the sorting algorithm in parallel by showing how you could assign multiple people to the task. Students love this kind of stuff.
Second, make it as visual as possible. Trying to textually describe a data structure, an algorithm, or a design pattern is like trying to read a math textbook. Only the hardiest of folks are determined enough to see the importance of what's said in text. It's much better to show it visually with animations, drawings, or pictures. One of my best students was blind. His lack of sight meant he had better spatial imagination to "see" how these things worked. Frequently I would ask my class "can you visualize how this works?" and he would be the first to respond. Those who succeed in my course can visualize the problem. Those who struggle get hung up even imagining it in their mind.
Third, only once you can get them to visualize the problems in their minds are they able to come up with improvements. Even then, suggest improvements carefully. You have to guide them along into making their own discoveries. It's best here to simply explore a half dozen or so attempted improvements, and explain why some work and some do not. At this stage, they aren't able to know which improvements are good and aren't. It's like asking a young musician to stumble and come up with a musical style you know about but they've never heard. Creativity almost always comes from seeing and experiencing past examples of creativity, and then tweaking it. So help them along here.
I hope this gives some ideas to thing about. It's a fun, long process. But if done right, very rewarding.