As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
So, those of us who've been answering questions and dealing with bug reports for a while are all deeply familiar with the concept of a "complete, minimal example". You start with a gnarly huge pile of code that's got a weird error, and you want to ask someone about it. But you don't want to send them the whole mess, so you start cutting the pile of code down into smaller pieces, until you get this little crystalized 20-line gem that still has the same bug you started with.
(And then, at least half the time, you realize what the bug is because it's staring you in the face like a luna moth, and you don't have to ask after all. But that's a side effect.)
Doing that sort of code-reduction isn't a skill that everyone has -- it takes a bit of practice, beyond the fact that a lot of newbies haven't yet learned that they ought to do it in the first place. There are several excellent sets of instructions for newbies on how to ask good questions (e.g., ESR's classic "How To Ask Questions The Smart Way"). Are there good instructions out there that explain what exactly a minimal complete example is, and how and why to create them?
It's all in the name. A complete minimal example is an example that is complete and minimal. Complete means that it contains all pertinent information, and minimal means it contains no information that is not pertinent. The ability to identify what is an is not relevant is something that only comes with practice - trying to provide instructions for this seems a little like trying to provide instructions on riding a bicycle. You can give the technical explanation and describe the mechanics (and the TeX FAQ you linked to does that very well) but in the end the only way to really learn is by doing.
I'll start this off with the ones I'm familiar with; these both come out of the TeX community, and so are a little oblique for programming. I'm hoping other people have better answers.
The TeX FAQ has an entry on How to make a “minimum example”.
That page points to a somewhat longer article on "What is a minimal working example?". Again, this is for TeX documents; the ideas are the same, but the tools and details a little different.
Edit (2013/01): Another one that I noticed in a StackOverflow comment: The "Short, Self Contained, Correct (Compilable), Example" page. Not perfect, and it suggests 20kb (!) as an upper limit, but a good addition to the list.
Edit (2013/02): Jon Skeet has a blog post about writing good questions, which includes a section on sample code that seems useful.
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I've been programming for the last 6 years. I just recently started my first degree in computer science. My work seems to be constantly marked down for different reasons, amongst many of them:
Uncommented code
Writing too long identifier names and methods
Writing too many methods
After working as a programmer for six years for numerous startup companies, and absorbing best practices which include the requirement to write "self explanatory code" I find it very difficult to go back to bad practices.
What can I do?
Self documented code is not synonymous with comments.
I've argued with many senior devs around this point. Code can go a long way in communicating intent but there are some things which simply cannot (and should not) be documented through code.
For example if you have a highly optimised function/method or chunk of code which is heavily coupled to the underlying problem domain and requires very specific knowledge of the business or solution. Comments are needed in these scenarios.
Yes, yes, comments come with there fair share of problems but this doesn't mean they aren't helpful (or mandatory in certain cases).
I can't tell you how many times I've read a colleagues line of code and thought "what the hell?!?" only for them to explain that they needed to do that due to some quirk of some library or browser we were targeting etc.
Comments are a mechanism for a developer to justify a design decision.
As for your other problems, they are subjective. How long is too long? How many is too many?
Point them at Microsoft's guidelines if you are on the MS stack or there will be countless articles for whichever language you're using...
Hope that helps.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
What programming language/method would be best suited to writing a desktop app that
filters question types and displays a listing of those questions to view.
For example, if I have a mix algebra, geometry, and calculus questions stored in the app,
I should be able to select just the algebra questions to view and print.
I have a little experience with python/django but I've never made a desktop app before.
You have lots of options. You will need to make several design decisions before you move forward. Things to consider are:
Which technologies do you feel comfortable with?
How much time/effort do you want to put into the project?
Are you willing to spend money on tools?
Etc.
That being said, the rest of this answer is to give you some options to consider:
You'll need a data structure which can filter the problems for you.
From your description, the first thing I thought of was using a
database, however I'm not sure if you are familar with databases, in
which case you'd have to create some classes/structs that would allow for you to do the filtering yourself. Some options for databases are SQL Express, Oracle, MySQL, DB2, and many more.
Another thing to consider is you mentioned several different type of
math problems. You'd want to consider how you would be displaying
the problems. Mathematica formats math problems nicely, but if you
wanted to go down this road, you'd either have to find a tool that
would allow you to display that math problems in a syntax like
Mathematica or do exports/screen shots of the problems and have those as
part of your program.
Another option would be to try to find a
language that has some sort of plugin for TeX or LaTeX (For example,
you can see how wikipedia allows for nice math formatting here:
http://en.wikipedia.org/wiki/Help:Displaying_a_formula
This sounds like a good pet project to play with to learn different technologies. If that is the intent, great. If not, then you might want to do some googling to see if someone else has already created what you are looking for.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I will be teaching only one lecture on basic Prolog to students with little to no experience in programming. I'd like them to see that programming and Prolog can be used in the real world, perhaps even to do cool things.
I have looked at this and this threads, but I cannot find anything that is visually appealing that I can show them when we wrap up the lecture.
Do you have any suggestions for cool applications that use Prolog? I'm especially looking for something that can be shown as a video or slideshow.
If what you want is to highlight the uses of prolog and use audio-visual media merely for presentation purposes, combining the following 2 links might do it:
Natural language processing with prolog in the IBM Watson system
IBM's Watson supercomputer destroys all humans in Jeopardy
Dynalearn is implemented in Prolog and has animations.
See:
http://personnel.univ-reunion.fr/fred/Enseignement/Prolog/index.html
under "La librairie clpfd", there are links to 3 finite domain constraint animations (N-Queens, Sudoku, Knight Tour) that are used in this class.
InFlow is written in Prolog. You may browse through the examples and / or contact the author for details. VisiRule might also help.
Disclaimer: I have not used either InFlow or VisiRule, but I do use WIN-Prolog which is the environment used for both programs.
+1 for Visirule. It is, as far as I can tell (and I've researched this topic quite a lot) a unique visual programming tool (I don't know of any other visual tool that is easily reduced to a turing-complete language). I have implemented a trouble-shooting website with it along with various other solutions. Highly recommended- version 5 coming out soon too.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
At some point in our lives we're put in the situation to learn a new language (either by job requirements or just passion). Personally, I'm trying to learn Objective-C coming from a background of several years coding php. My problem is that I'm bored with your average starting programs (most of them coming from maths; eg: Fibonacci).
What are your first algorithms and programs you write when learning a new language?
I'm thinking we could make a list of interesting problems to be solved and that would make the learning curve at least more entertaining.
Later edit:
My question is about fun things (and also useful), but not like Code Kata or other very boring math stuff (I've done many of those already)
Later edit [ 2 ]:
I found this today and the problems there seem fun to do.
Try to develop something proper, a project of some kind; solving algorithmic problems really only teaches you to apply the algorithm, not really a lot about the language your using.
Deciding on a useful project then deciding on a language and then 'doing it' will cover many of the bases you need to learn a new language.
I like this series of articles by Larry O'Brien.
http://www.knowing.net/index.php/2006/06/16/15-exercises-to-know-a-programming-language-part-1/
http://www.knowing.net/index.php/2006/06/16/15-exercises-to-know-a-programming-language-part-2-data-structures/
http://www.knowing.net/index.php/2006/06/16/15-exercises-to-know-a-programming-language-part-3-libraries-frameworks-and-mashups/
Have a look at these:
How do you find interesting problems to solve?
https://stackoverflow.com/questions/6327/what-are-your-programming-exercises
Just as an idea: Look at the problems of the The Computer Language Benchmarks Game.
When you've done a snippet, you can compare your solutution to the provided one.
Whenever I pick up a new language, I try using it to solve the problems at SPOJ. They basically support every mainstream language out there (as well as a few esolangs like Intercal and Whitespace). The problems are mostly from various ACM and similar format contests around the world and so can be quite hard, and perhaps be too CS/math for everyone's tastes. The tutorial problems are quite doable in any language.
I would also recommend adding that language's tag to your SO interested tags list. Many SO questions involve small snippets of code, and trying to answer them and looking at the other answers can be very enlightening.
But as soon as I've got the basics right, the strategy I choose is to try my hand at a very small project. Usually this a simple game, GUI app or a tiny webapp. This is valuable since there are some things you cannot learn by only doing small isolated blobs of code.
Try to solve these challenges using your new language. What's it all about:
In software we do our practicing on
the job, and that’s why we make
mistakes on the job. We need to find
ways of splitting the practice from
the profession. We need practice
sessions...
I sometimes use the exercises from the first few chapters of Structure and Interpretation of Computer Programs.
You can also try to understand or improve existing open source projects as suggested in this so question. Even though the answers are cocoa biased it should be a good starting point.
This way you can dive in to the level of your choice (understand, debug, improve) and in direction of your interest (UI, specific library, etc, etc...).
EDIT: When I said starting point, I meant that you can browse repositories for objective-c code, for example sourceforge
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I have recently started learning Ruby, as my first programming language. I feel comfortable with the syntax, and I've done numerous tutorials that just teach the same basics. I have written a few small programs (including my own method for sorting an array that I thought was pretty smart until someone told me to Google 'Bubble Sort'), but I feel I need to attempt something bigger and harder to understand more about Ruby. Any ideas as to how I can do this?
Ruby Resources
http://www.rubyist.net/~slagell/ruby/
http://web.njit.edu/all_topics/Prog_Lang_Docs/html/ruby/syntax.html
http://www.ruby-doc.org/core-1.8.7/index.html
http://en.wikipedia.org/wiki/Ruby_(programming_language)
http://pleac.sourceforge.net/pleac_ruby.html
http://www.zenspider.com/Languages/Ruby/QuickRef.html
http://www.ruby-doc.org/docs/ProgrammingRuby/
The "advanced" Ruby book is The Ruby Way by Hal Fulton. It wouldn't hurt to read some real Ruby code - most gem's will do for this.
Finally, you need a project. You could take a program you have already written and redo it in Ruby, or you could think of something new to write.
Rubylearning Blog is hosting a fortnightly contest. The first contest went live - http://rubylearning.com/blog/2009/09/24/rpcfn-shift-subtitle-1/
That should be a start :)
A few years back I worked through Dave Thomas' Code Kata as part of a similar exercise. Fairly simple, self-contained pieces that let me explore the language at my own speed.
The kata idea seems to be moderately popular with developers, particularly at the Agile end - Googling "code kata" with and without "ruby" ought to throw up some more ideas.
fellow newbie. :) I too have just recently started learning ruby.
Right now, I'm reading The Ruby Way. Although I'm not required to code at work, I try to find practical applications of ruby -- no matter how mundane. For instance, I prepared scripts when I needed to test something that required several files with 0 file size and when i needed to generate an xml file based on another xml file; and since there was a tennis meet at work, i tried to create a script for random pairing or grouping. (Little baby steps, i know)
My colleague has written a post listing out the resources that a Ruby newbie would find useful. It was primarily intended for members of our local Ruby User Group, but it should be useful to you too.
More importantly, a lot has changed in the last couple of years and this post is pretty up-to-date (as of September 2012).
Here's the link: http://www.jasimabasheer.com/posts/meta_introduction_to_ruby.html