• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Teaching Swing vs JavaFX

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

First off, thanks for the site.  I usually find it on my Google searches for Java questions (that and stack ;) )  Right now I have a bit of dilemma that I hope y'all can help me with.  I teach the OOP sections at my University and in the past I've taught Swing, but I've always felt uneasy about it since JavaFX has been around for so long.  When I was a Software Dev/Engineer (not a Professor) for 6 years I noticed some things (please correct if you disagree.):

1) Lots of applications are in Swing.
2) The general trend for a long time has been to move applications to the web.
3) JavaFX is more web-like in its structure and development (FXML.).
4) A good number of businesses don't like to rewrite applications from Swing to JavaFX
5) People are weary of JavaFX because of Oracle (which I understand...)
6) Oracle is pushing JavaFX.

I have written both Swing and JavaFX applications in my Software Dev career.  For the students I wants to make sure they are prepared when they graduate.  So, which would you choose?  Keep in mind that this course is (essentially) the second programming course they take and I may only assume they understand the basics of procedural programming.  Naturally, I teach Objects and Inheritance (implements & extends) before graphics.

Thanks,

~Paul
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the the Ranch!

I'm happy to see someone who's officially from the academe.

My personal experience has been that enterprise development is primarily around web-based applications, with an increasing number of projects also focusing on mobile-based products. I have never used either Swing or JavaFX at work nor have I seen any projects using those technologies ever in over two decades of working for large corporations. YMMV.

This is not related to your question but since you are from the academe, the topic of the quality of academic instruction has come up a number of times recently. We have many students posting questions in these forums and many of them tell stories that make us think there's a troubling trend in the academe where students with a semester of programming courses are still sadly and acutely ill-equipped to handle further coursework, much less be prepared for real-world programming work. If you'd like to discuss this further, we can create another topic for that discussion.
 
Paul West
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd love to teach web-based development, but I don't have the tools to easily teach it to second semester students.  I'd have to ask them to stand up a JBoss/Tomcat/Weblogic server, teach ears/jars/wars, injection, etc...  They have just been introduced to objects--they still get classes and objects confused!

One reason I like JavaFX is that it does have some web-dev features in it (FXML), but the main issue is the support may be dwindling.  On the other hand, Swing has so many resources and legacy applications.

I'd love to talk about Academic quality (my University does take it seriously.)  So please point me to a thread or start one.

Thanks,

~Paul
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I wrote:... I seen any projects using those technologies ever in over two decades of working for large corporations. YMMV.


Logic error. I should have written "in over a decade of developing Java applications for large corporations..." from 2001.

Anyway, Paul, there's at least a couple of us moderators here who would love to talk about how kids are being taught Java and OOP these days so it'd be great if you would discuss that with us a bit. I've started another topic for this here: https://coderanch.com/t/670328/java/java/Teaching-Java-OOP
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I mentioned the same thing in the other thread but I'll repeat it here since it's relevant to the topic.

IMO, teaching technologies like Swing and JavaFX to students who are finding the concepts of classes and objects confusing will not help.  I would suggest not focusing on UI and stick with console or file input/output first. Focus on control statements, clarity, organization, and logical thinking first. This is what we see as most lacking in the examples that students post in these forums.
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Definitely what Junilu says.
Too many try and get into GUI things before knowing how to actually code in a structured way and it all becomes a bit of a mess.

It's the same thinking that has students being trained via JSPs before knowing about servlets when it comes to web development.
 
Paul West
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand what y'all are saying--students *should* understand OOP Principles (+Design Patterns) before GUIs.  On the other hand, that *is* what I'm teaching this semester and good examples motivate understanding.

That is why I don't teach a web development stack and why Swing has been good so far--it is simple.  JavaFX may be more confusing, but may give better examples of what they will experience.

Don't worry, I teach Inheritance, encapsulation, and other basics before GUIs.  Then, when they are reading for GUIs, should it be Swing, JavaFX, something else?

Thank guys--I still haven't found a good Java book,

~Paul
 
Paul West
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I should say Swing is relatively simple compared to a web stack or JavaFX.  I have considered doing JavaQT...
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul West wrote:I should say Swing is relatively simple compared to a web stack or JavaFX.  I have considered doing JavaQT...


I still think that it draws attention away from more basic concepts that you could/should focus on instead. Based on most of the code we see posted here, beginners spend way more time struggling with Swing code than they should given that they don't even have a good grasp of good program structure and organization.
 
Marshal
Posts: 8856
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul West wrote:Then, when they are reading for GUIs, should it be Swing, JavaFX, something else?


JavaFX I'd think as it is most recent Oracle's standard for desktop GUI applications. Maybe at the beginning I'd avoid showing simplicity of FXML's, instead would teach how JavaFX look in plain Java code which is similar to Swing in its concept. But opinions may differ on that.
The important thing to note is, that knowing how JavaFX done in plain Java code won't be much beneficial if students will develop applications using FXML for UI, which I don't see a point of not using Scene Builder for that as it generates code very well as it is mainly a markup language, yes, you can embed JavaScript to it, but that is different topic.
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I put myself in a beginner's shoes and open up the Swing tutorials or the JavaFX tutorials, my eyes immediately start glossing over from all the details that I'm bombarded with.  The Swing HelloWorld program alone has an event dispatching thread being passed an anonymous Runnable class that invokes a static method on the main class. That's enough to make even an experienced programmer pause and scratch his head (that would be me).
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote:has an event dispatching thread being passed an anonymous Runnable class that invokes a static method on the main class. That's enough to make even an experienced programmer pause and scratch his head (that would be me).


And it's enough even for me to get wrong. On second look, it's the SwingUtilities class invokeLater() method that gets passed the anonymous Runnable class, which presumably is passed to an event scheduling thread that is created by the invokeLater() method. Or something like that.

Going back to the previous page of that tutorial, it tells me "The Swing API is powerful, flexible — and immense. The Swing API has 18 public packages: ..."

As a beginner, I'd probably be like and

It seems to me that a top-down, problem-solving focused approach would be more helpful.  I'll explain more in the other thread.
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Swing has one advantage: if you don't understand object-oriented design very well then you very quickly get stuck because you have no idea how to use it. At that point you should stop what you're doing and go back and learn more about object-oriented design. But that's the question you're asking, isn't it? What's a good framework in which to learn object-oriented design? Unfortunately I don't have an answer to that.

But object-oriented design is the term I used there. It's not the same as object-oriented programming. That's a problem I see here a lot (bear in mind that all I see of today's education system is posts in this forum). People are being taught programming but they aren't being taught design. So they get these assignments which are often highly artificial and they throw together code until they have something which does what the assignment says, but from the design point of view it's a disaster. And then after a semester of that, we have programmers who are ready to produce the next installment of The Daily WTF. I don't know what to do about that either.
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The posts we see here are pretty representative of what kids are learning in school, from what I can tell from my son's two programming courses and their syllabi. I agree that design thinking is part of what's lacking. Maybe the thinking is that design is a more advanced topic and programming language syntax needs to be taught first. There are, however, many simple things that are related, if not part of, design. Good choice of names, for instance, is something that I consider crucial to design and design thinking. If you teach the 4 rules of simple design from the start, you'll already equip beginners with good habits and a sense of good/bad form that they can build on in understanding good structure and organization. IMO, the 4 rules are not difficult for beginners to understand: passes all tests, reveals intent, no duplication, and small. The hardest part may be the first one. None of these are even necessarily tied to OOP.
 
Paul West
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree students should design more.  There are some issues.  At my University and the ones I've attended, we take CS through practice.  We start with programming and then strap on concepts.  To that end we start with very contrived examples to further understanding.  Design is not something that is taught first, and therefore is ignored unless necessary.  That plus getting students to think first and then act is like pulling teeth.

If I had some good OOD questions for homework to accompany the programming assignments, I bet that would help student at least think first.  That and Junilu's link would probably help as well.
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul West wrote:That plus getting students to think first and then act is like pulling teeth.

If I had some good OOD questions for homework to accompany the programming assignments, I bet that would help student at least think first.  That and Junilu's link would probably help as well.



Introducing OOD can be as simple and sneaky as having the students answer these questions about their code:
1. Do your class names reflect what each class is responsible for doing?
2. Do your method and variable names clearly reveal their purpose?
3. Does your code contain any duplications?

You don't even have to tell them that they're thinking about design when they ask themselves these questions.

I tell developers whom I mentor that to start getting better at design, they should try to perform one or more of these refactorings on at least 80% of the code that they write:
1. Rename to clarify intent
2. Extract to eliminate duplication
3. Compose method to get a Single Level of Abstraction

I find that doing just these simple things constantly and consistently helps people start to recognize various problems that stem from lack of clarity, duplication, and convoluted code. Done consciously or not, that's design.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic