Scala, Swing and MVC - model-view-controller

I found some informations about using Swing with Scala in Programming in Scala book. I also found some basic informations here: http://www.scala-lang.org/sid/8 . But there are no informations about how to build bigger application based on Swing. Than I found some informations in German (but code is in Scala;)): http://www.scalatutorial.de/topic123.html . And it is good... but still, it is good for small applications. I'm going to wrote something bigger. So I want to make not one, but few models, and few views for each, like in Ruby on Rails. Do you know some good tutorials or egsamples which may help me do it properly?

here's a program using scala-swing: https://github.com/lrytz/pacman, also rather small though.

Related

Ruby Object Mapper documentation

I need to use an ORM for my project and I opted to use ROM, since every other ORM seems to be directly tied to Rails and I am not using and will not use Rails.
I find the official documentation of ROM, found on www.rom-rb.org, to be awful. It doesn't provide any minimal code examples or even a cohesive experience. Instead, it gives you multitudes of theoretical breadcrumbs that are completely unrelated to each other. After reading the entire documentation under the "Learn" section, I realised my knowledge of ROM did not change in the slightest.
I need help from developers who have experience with ROM. Is there an actual source of knowledge on how to use ROM? Where can I find code examples or projects that use ROM? Or is there a good alternative ORM in Ruby that isn't tied to Rails?
Following some recommendations from the comments to the question, I decided to ditch ROM in favour of Sequel. It really turned out to be much simpler and, most importantly, to actually work.
It is quite ironic that ROM is in part based on Sequel...

XML and YML in context of Symfony2 and SpringMVC

I'm on my way of getting a decent programmer but it seems that the things there are to learn are countless. I know that there's never a certain answer when one ask which is better, but I'll try to make my question more specific hoping for a more certain answer.
I'm using/working with PHP for a year now. Starting from the most simple examples, now I'm using CodeIgniter and various libraries/frameworks for the frontend and I feel like I need to make a step ahead, which in my case is learning another PHP framework - Symfony2 and also, because I'm getting my masters degree on "Software technologies" now and there I intensively use Java, I want to try and start learning both - Symfony2 and Spring. Among the many questions how to accomplish that without ending with just a lost time, the usage of XML, YML is something where I see an option for getting an edge in my work.
Java is heavily XML, and as far as I know, there's no escaping from XML in Java. But in Symfony2 one have a choice and it's very tempting to use XML there so I won't need to learn one more thing among all others but most of the examples I see for Symfony2 use YML and I'm not very sure that skipping yml and trying to stick strictly to XML won't turns back on me.
I'm not experienced neither in Spring or Symfony so if it was you learning both of them at a time how would you approach? Using XML for both, or using YML for Symfony2?
I'm making my money as a Symfony developer, while developing my personal project in Spring MVC, so, since I've seen the both worlds, I think I have something to share on this topic.
I'm developing in PHP for like 7 years, and I know Java as a language for like 5 years, but I'm developing my first “real” Java project just for a month or two. Eventually, I want to ditch PHP for good and switch to Java and/or other JVM languages like Scala.
What's the reasoning for this? Well, don't get me wrong, Symfony2 is a great framework and I really love it. I believe it's the best PHP framework out there. But... it's still PHP, you know. No matter how great a PHP framework is, I just can't stand PHP as a language for too long. What's so wrong with PHP, you ask? There is a great article explaining exactly what I've been feeling about it for a long time (at least read the analogy section).
And since I prefer static binding and strong typing, I'm more comfortable with Java for this reason too. It's just so great what a Java IDE does compared to what the best PHP IDE does. I think I'm using the best IDEs for these languages out there — IDEA (with the PHP plugin) or PhpStorm — and Java support is just so much better it makes me want to dance.
I'm not saying that Java is the greatest language of all, but it's a huge improvement over PHP. I think Scala is very promising, but since its infrastucture/ecosystem is not mature enough for me — a pragmatic who likes to get the end-user projects done, compared to guys hacking the languages themselves and developing frameworks — I'm staying with Java for now.
So, for me it boils down to the language, community and ecosystem. While the PHP community has some great developers and I enjoy having conversations with them on IRC or other places, the Java community has much, much more great developers developing much, much more great stuff for the much, much bigger Java ecosystem.
Apart from those 3 things, I could add that Symfony is much easier to learn — its book and cookbook are great and really to the point, while I have to hunt down a lot of information about Spring in numerous books, blogs and its vast documentation.
Speaking of YML and XML, you can do a Symfony project in XML only, and you can do a Spring project completely or almost completely without XML — especially since version 3.1. I use YML in my Symfony projects but XML for bundles I share.
And since Symfony DIC and security are based on Spring and Spring Security, and Doctrine is based on JPA, learning idioms of one of these frameworks, you learn a lot about the other one. What I'm really missing is a Twig analog in the Spring MVC world — JSP gets the job done, but it's not that great. I know there are other view technologies Spring MVC integrates with, but to me it seems like JSP is the most endorsed one.

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.

What is the most functional and ready-to-use SWT API in Scala?

Is there a Scala SWT wrapper/API that has the most features and is most ready to be used? I see a couple what appear to be informal wrappers but can't tell if they're maintained. Also, one or two I see on multiple places and I'm not sure where the canonical place for them.
I've been using Dave Orme's XScalaWT with my own additions for JFace viewers for a while, and I find it great. Be sure to read the very interesting introductory blog post.
I'm also aware of SSWT but have no experience using it. I believe XSWT is more mature.

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

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

Resources