What real-world projects would you suggest as code examples to study? - coding-style

What real-world projects would you suggest looking through the sources?
As I'm learning Java Swing, mucommander seems to be a decent example. The code is excessively commented though.
EDIT: No shameless plugs plz :).

I learned a lot from looking at the source code to GoGrinder. It's well thought out, uses MVC correctly, and the comments are helpful (and no, I didn't write it). It's also a fun program to use if you want to learn how to play Go.

For Gui design, Patterns and general good advice I highly reccomend Jeremey Miller's series of articles on building a better CAB. For C#, but equally applicable to Java. Also using
the MVC style which Stackoverflow follows, and Apple uses for Interface Builder.
Build your own CAB
Jeremy's articles/ideas are followed in his own project, which you can download and inspect at http://storyteller.tigris.org/

Take a look at the Windows version of truecrypt. It is one of the best organized open source projects I've ever seen. You can almost tell how the whole thing works just from the directory and file layout.

What I've done to learn some new technologies over the years is to look to open source projects that both match the criteria you're looking for and also interest you.
I'm not a Swing guy, but I'd suggest finding a project that uses Java Swing, does not appear too complicated, and then start digging through the source. The nice thing is you can then see the app before you start poking through it, and then you can see what happens as you change stuff.
The idea behind picking something that interests you is that it will keep you engaged. I am intrigued by content management systems, so I might download a CMS that I can then see how stuff works, and I'm engaged because the problem domain of the project fits in with an interest.
I've done this once or twice when I had to get up to speed on C# and I think it works will. YMMV....

Some of the most well thought out source code ( c++ ) I have seen in an open source project is the Ogre3D graphics engine, I've learned a lot about OOA&D just by looking at the structure and reading the comments. It is also well maintained and the community is very active.. http://ogre3d.org

Related

Designing a GUI framework

I need to create a custom GUI framework for a project. I actually created a very primitive GUI framework which has buttons, images, text etc. But it is pretty simple and I don't have any prior knowledge of designing a GUI framework. The project we are working on got a little serious and I need to do a better job. So, what books or any kind of documentation can you recommend for me?
Note: I want to create the framework probably in an object-oriented way and I will probably use C# but the documentation does not need to be in C#.
Ok, I'm far from an expert but I'll try to write some useful stuff. I don't know much about your experience, so sorry if it seems silly.
I have been working with several GUI frameworks in the past, in various languages (wxpython, gtk+, swing, . . .).
Never as an expert, but here is what I can say :
Keep it simple. If you want to design from scratch, I guess there is no need for crazy complex stuff. Try to keep it as straightforward as possible by reducing the number of inputs and options in your elements.
b. A major common point of all the successful frameworks I know is the abstraction. Each single element can be easily handled, but it still has the power of all its parents.
This allows your objects to be really versatile while simple.
Read lots of other frameworks documentation. I like spending time reading the doc of GUI framework because it helps you understand the abstraction levels. I find the pygtk doc easy to read.
Use other frameworks. Most frameworks do things more or less in the same way. This is especially true for GUI frameworks. Frame containing layouts; menubars and statusbars; I bet 95% of the concepts you want to use can be found in the other frameworks.
In this way, the best way to know how to develop it is to know what you need and how to do it.
Whenever I work on a GUI, I start reading the corresponding series of articles here .
The writer does a great job explaining everything in a simple way, so that you can get along fast with the concepts.
Keep it open. Something I see more and more often is the use of high level syntax for describing GUIS. GTk for example can take XML files in input and create a whole interface out of it. I find it very nice for abstraction, and reuse. And I also greatly reduce the amount of code needed.
I couldn't really find books on the precise subject you want. I think you already searched on the web also.
I hope those small ideas will help you.

M Project vs Sproutcore

I cant decide between this two options.
M Project vs Sproutcore
I'm building an application that will be primary served on mobile but has to be viable on desktop.
Mproject is on the edge with number and variability of his prebuilded widgets and may happen that I will need some more or at least alter some behavior.
So this is kind of down side of Mproject. But it looked for first review that Mproject need less code for basic stuff.
And the second problem comes with the skins. I will basicaly need reskin everything a lot. The design of app has to be very unique.
So I want to know which of them is easily to reskin not just by theme-roller and similar stuff.
I would appreciate any other JavaScript-only frameworks recommendations.
Thanks for all replies.
I'm not sure what kind of application are you building so you should take care with my answer.
M-Project solved our problems fine, and help us to make it clear code ... when you understand how it works. It requires a bit of hard work, the documentation is a bit poor and is a new project where some things are not yet implemented. You can change application look modifying HTML and CSS so I think you should have no problems with this.
Also you can download their code and modify it without problems, it is easy to read and modify if you need any specific behavior.
On other side, I never used Sproutcore, it have a really nice look. But documentation say it is focused on desktop applications. Probably you will not have too much problems to adapt the output HTML for mobile devices, I guess.
Lastly, I think you can take a look on Lungo.js Framework.
Best regards.

Is there a website to look up common, already written functions?

I'm sitting here writing a function that I'm positive has been written before, somewhere on earth. It's just too common to have not been attempted, and I'm wondering why I can't just go to a website and search for a function that I can then copy and paste into my project in 2 seconds, instead of wasting my day reinventing the wheel.
Sure there are certain libraries you can use, but where do you find these libraries and when they are absent, is there a site like I'm describing?
Possibly a wiki of some type that contains free code that anybody can edit and improve?
Edit: I can code things fine, I just don't know HOW to do them. So for example, right now, I'm trying to localize a robot/car/point in space. I KNOW there is a way to do it, just based off of range and distance. Triangulation and Trilateration. How to code that is a different story. A site that could have psuedo code, step by step how to do that would be ridiculously helpful. It would also ensure the optimal solution since everybody can edit it. I'm also writing in Matlab, which I hate because it's quirky, adding to my desire for creating a website like I describe.
StackOverflow.com. No, I'm not joking.
At its best, people come here saying "hasn't some library done X already", and very often the Collective Wisdom answers "yes". But the biggest obstacle is lack of a description language: even here, a big problem for many posters is describing the problem clearly enough for others to recognize it as something they've seen before.
And if people can't understand what you're trying to do, no search engine will.
Firstly, two caveats:
Copy and pasting code you don't understand is a bad idea. Make sure you understand exactly what the code does before you use it.
Make sure you respect the license of the code you are copying. This is important!
Those caveats aside, it's often language dependent. Languages with an open development ethos (not just an open source implementation, think Python as compared to Java) tend to have official archives of open source libraries. For example:
Perl (which probably started this trend) has CPAN
Python has PyPI and Python Cookbook
PHP has PEAR
C++ has boost
Ruby has gems
R has CRAN.
Haskell has Hoogle and Hackage
Furthermore, don't forget to look in your languages standard library. Some modern languages have massive standard libraries, which have often contained the functionality I am looking for:
Java has its API documentation
C# and VB.NET have the massive MSDN
Non-openly developed languages often have non-official community archives. For example:
C# tends to have a lot of code at CodePlex and CodeProject
MATLAB has the Matlab Central File Exchange
A third category of sites are language agnostic. They are often best search through POG (plain old-fashioned Google). For example:
Stack Overflow
SourceForge
The confusingly language agnostic Java2s
Planet source code
Github
Finally, a fourth category of sites that I find increasingly useful are source-code search engines:
Google Codesearch
Koders
You may also be able to find useful source code, or at least get help writing something, through various pastebins.
Pastebin is language-agnostic
HPaste is mostly Haskell, but has a little in other languages.
Often, at the end of the day it is easiest just to google it, though.
There is a wiki that contains free code that anybody can edit and improve:
Rosetta Code.
As a means of an overview there is the "Solutions by Programming Task" page.
From the former page:
"Rosetta Code is a programming chrestomathy site. The
idea is to present solutions to the same task in as
many different languages as possible, to demonstrate
how languages are similar and different, and to aid a
person with a grounding in one approach to a problem
in learning another."
Cutting and pasting code you find on the Internet into production code would be like chewing gum found in the street. - Mike Johnson
With that in mind, try sites that host opensource projects like GitHub, CodePlex, code.google.com, etc.
I'm not sure this question is language agnostic, but I use GitHub this way ;) Other languages may have places where this is possible.
Safari Bookshelf from O'Reilly has many, many books that contain many implementations from which to choose.
http://my.safaribooksonline.com/
I was a subscriber for a few years before coming to my current job, where we have a corporate account! It's one of the best perks, and one of the best resources I have available. I haven't bought a computer book in years.
Aside from sites like this (Stack Overflow) I don't think there's many, maybe CodePlex, but I almost marked you -1 for assuming that code found on the Internet is yours to copy.
I'd suggest reading about software licencing, I hope you'd at least comment where you got it from.

Learning Cappuccino

What is the best source to learn Cappuccino? I do "traditional" web development, but i'm very interested in this new framework. Please note that I have no knowledge of Objective-C.
As mentioned above, the website is a good place, but there are also some other good resources:
http://cappuccinocasts.com/ (screencasts)
http://www.nice-panorama.com/Programmation/cappuccino/
http://www.littletreesoftware.com/blog/
http://theocacao.com/document.page/593
There are a few others too, and many of them are linked to from the site.
I wrote a real life cappuccino tutorial based on an actual customer project: http://www.springenwerk.com/2009/09/real-life-cappuccino-tutorial-part-1.html
On the tutorials is says:
A great introduction to Objective-J. Familiarity with JavaScript is recommended, prior knowledge of Objective-C not required.
http://cappuccino.org/learn/tutorials/
It seems the website is a good place to learn. Interesting framework.
You also have http://www.cappuccino-project.org/learn/
It is our new work-in-progress website. Not complete at all, it still has some very basic tutorials to help you starting coding with Cappuccino
I recently took up learning cappuccino. I found the Cappuccino Casts and the tutorials on cappuccino.org, however, like you, I come from a web development background - not cocoa / desktop apps.
Following some online tutorials was good to a degree, but I felt I lacked fundamental knowledge about the Objective-C and Cocoa and Cappuccino is modelled so closely to it. I bough a copy of Aaron Hillegass' book called "Cocoa(R) Programming for Mac(R) OS X" here: http://www.amazon.com/Cocoa-Programming-Mac-OS-3rd/dp/0321503619/ref=pd_sim_b_3 which I felt really helped with my base understand of application development rather than traditional web development.
I would definitely recommend giving it a read, I worked my way through it in a few days and thought it gave enough knowledge to understand what all the Cappuccino stuf was about.
I recently found that when I install Cappuccino from source, there is a fairly significant amount of code to learn from hidden away in <install-dir>/Cappucino/Tests/Manual
There is a wealth of code there that isn't advertised anywhere but is certainly good enough to learn from. Just drop the Frameworks next to the index.html file in each test folder and open up and learn!

Project in Ruby

I've been coding alot of web-stuff all my life, rails lately. And i can always find a website to code, but i'm kind of bored with it. Been taking alot of courses of Java and C lately so i've become a bit interested in desktop application programming.
Problem: I can't for the life of me think of a thing to code for desktop. I just can't think of anything i can code that isn't already out there for download. So what do i do?
I need some project suggestions that i can set as a goal.
I would say you should roam through github or some other open source site and find an existing young or old project that you can contribute to. Maybe there is something that is barely off the ground, or maybe there is a mature project that could use some improvement.
I find to complete a project, it needs to be something I am passionate about. I feel you need to find your own project I'm afraid.
There is always the Netflix Prize though!
I would write a ray tracer.
Oops, sorry... you're looking for an original idea. :) Ray tracers are still cool, though, and easy to get started on. Maybe you'll get an idea for a game while you're working on it.
Visit shoooes.net for a UI toolkit that's easy and fun, and then the-shoebox.org to see the kinds of things people are doing with it.
If you could make a Ruby ANSI (and xbin, and idf, and adf...) Editor, I would love you. Because that means you would have written ANSI parsing routines that I can hope you release to the open source community.
... but that is a selfish answer. Oh, and a cross-platform editor would be nice as well (although TundraDraw somewhat takes care of that).

Resources