Gail Anderson

Author
+ Follow
since Jul 07, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Gail Anderson

Here is perhaps another way to look at it.

Dependency injection is the mechanism that lets you configure code dependencies, as opposed to have dependencies "hard wired." In Spring, when you configure dependencies, you do so using XML or annotations. There are advantages and disadvantages to each way.

But, there is a bit more to the story. Spring supports building software systems that are loosely coupled. It does this by having you "code to interfaces." When you code to interfaces, you specify the things a service (or repository) object should do. Let's start with a service object. The interface object you design should provide the service-level use cases of your system or subsystem. For example, let's say you have a web application that lists all of the recordings stored somewhere (either in a database or accessible through a web service--it doesn't matter).

Here is a really simple example so you can see some Java code. First, we have an interface that defines our getRecordingList() method.



Then we implement this interface with a Java implementation class. Note below that there is a property called musicDao. This property is an object that does the work. But we don't know how the work is done. In our application code, we just call the interface method getRecordingList().



Now we also have configuration code that says provides the "bean wiring." That is, it performs the dependency injection for us. This is where Spring comes in. The Spring container reads the XML file and (using Java reflection) builds the objects for us. Here is a sample XML code. (Note, that I am only showing part of the system.) Below, you see a bean identified as "musicManager" is instantiated with class music.service.MyMusicManager, which has a property that should be injected with a bean called "musicDao". Here we implement the "musicDao" bean using Jpa, but we could just as easily use another technology: jdbc or web services. The point is that the MusicManager interface simply provides the methods and the implementation is configured. This helps the software engineer create loosely coupled systems.



Does that help?
12 years ago
In the big picture of software design, Spring helps the software architect build loosely coupled systems.

It does this by having you code to Java interfaces. When you implement the interface with an appropriate Java class, you "configure" the implementation class using either annotations or xml. This is called bean wiring. Behind the scenes, the Spring container makes sure the correct class is plugged in. This is called dependency injection, where the system dependencies are "injected" by the Spring container. The dependencies, therefore, are not hardwired, but specified externally.

The beauty is that you can plug and play implementation classes (for example, you can implement persistence using Spring JDBC, "native JDBC", Spring JPA, native JPA). With JPA (Java Persistence API) you can use EclipseLink, Hibernate, etc.. It also makes it easy to implement different front-end frameworks. I have implemented the same system using both Swing and JSF 2. When you deal with well-designed service modules, this type of reimplementation is straightforward.

The disadvantage is that XML configuration can be verbose. Annotations are generally easier to read, but may be spread out in different source files.

In my opinion, building loosely coupled systems far outweighs any disadvantages.
12 years ago
Thanks, Henry.

Congratulations to all the winners. We really enjoyed the questions and discussions. Looking forward to JavaFX having its own forum as more people use it. Perhaps we'll even have some JavaFX programming questions!

Regards & signing off!

Gail

14 years ago
And, perhaps more elegant, but not exactly the same behavior is using this slider and completely removing the second timeline (the 100ms update timeline).



With a second slider you could reflect/control movement of the ball in the y direction.

I hope you like!

Gail
14 years ago
Well, since this week this is also a JavaFX forum, I thought I would show all of you the sample Swing code implemented in JavaFX. I did add an "easeout" interpolator that slows down the movement at the end. If you remove the tween Interpolator.EASEOUT, then you'll get normal linear interpolation. I resisted the urge to add drop shadows to the circle, linear gradients to the background, etc.

The code does show the scene graph metaphor well. You can see that you "set things up" by defining your nodes (circles, rectangles, slider) and then it just goes! No painting, no threading, no runnables.



Gail
14 years ago
It sounds like JavaFX is the replacement for Swing, but Sun has said many times that Swing isn't going away. So, no.

And no, you absolutely do not have to first get Java under your belt. While JavaFX lets you leverage your Java knowledge, it is absolutely not a requirement for building JavaFX apps or learning JavaFX and experimenting with building GUIs.

Your toes are in the water, just jump in already!
14 years ago
JavaFX hasn't implemented every Swing control, but you can use Swing controls with JavaFX.

Eventually, they will have a very complete UI control set. As I've said in other posts, the JavaFX UI engineers come from a Swing background and want to make JavaFX UI controls an improved system from what you get with Swing. So, eventually the JavaFX "native" UI controls will probably be what you want to use.

JavaFX is much, much easier to use than Swing. I could post some code (I posted some code that transforms a rectangle by scaling, rotating, and shearing using a slider, but I can't find that post right now) that lets you see, but at this point, I think you would get most of your questions answered if you downloaded JavaFX and tried it out. It's not a huge time investment and you could see how you personally like it.
14 years ago
Hi Ibn,

I respectively disagree. While the book you describe is indeed useful, the book I want when learning JavaFX shows me how to use JavaFX. The book you describe is a big picture book and many portions have nothing to do with JavaFX in particular, but have to do with software engineering and architecture. These, of course, are important but belong in a different book.

For example, in designing an online store you must decide on your persistence strategy. Will you use Hibernate, jdbc/database, ejb? Any /all of these strategies can be used with JavaFX, your front end.

If you include "learning JavaFX" with these topics, your book will be 1,000 pages. (I personally don't like 1,000-page books.)

I don't know about you, but when I'm learning a new language, I appreciate the work the author has done to build the examples and explain the language features used. A previous poster said, "I can learn everything about the language using Google and scouring the internet." Maybe. But it will take you 3-4 times as long.

For example. Let's say you want to write a game in JavaFX. You will need animation. Looking up the APIs you see that JavaFX implements animation with the Timeline class. Oh, and there's also Transitions: TranslateTransition, ScaleTransition, RotateTransition, FadeTransition, PathTransition, PauseTransition. There's compound transitions too: ParallelTransition and SequentialTransition. Okay, time to study these APIs.

In our chapter on Animation, we talk about all of this. And it turns out that you use Timeline for periodic updates, the kind you would use in a game situation (have I collided with something yet?).

When writing a book, the Table of Contents is a collaborative effort with the acquisitions editor, the authors, other technical parties, perhaps engineers involved with the topic. Our goal was targeting programmers who want to learn JavaFX. We don't assume Java or Swing experience. (Indeed I have found that people without extensive Java knowledge accept the JavaFX programming paradigm more rapidly. Some Java programmers find the scene graph metaphor different.)

One final point. Not every piece of software is an elaborate system. Some are "just widgets." One of our examples shows a flickr-based slideshow (an animated carousel). It uses JavaFX support for web services and pull parsers (to parse either XML or JSON). This is not a large example (thanks to JavaFX) but it is hugely useful (and fun). You can embed it in a web page and show your own (or others') flickr photographs.

In summary, the book you describe is very useful. But, that's not the book I would want to learn JavaFX. Just my opinion.
14 years ago
Hi André,

Are you asking if JavaFX is available for Linux?

Yes, it is available for Windows, Mac, Solaris, and Linux. JavaFX/NetBeans Download Page (all)

However, currently, the mobile handset emulators are only available with Windows. Hopefully that will change soon.

Gail
14 years ago
Oh, and there is also a third-party JFX Builder. I haven't used it, but it looks interesting and is featured on the JavaFX web site.
14 years ago
Hi Michael - that's awesome!

Hi John (MS software engineering student) - I had numerous discussions with other engineers and book authors about the great match with using JavaFX in the software engineering student environment. I think JavaFX is an excellent fit because it's not that hard to build applications that are interesting/fun. It is a full-fledged language with a type system (and type inference) and supports object oriented programming. You can use it for games, web services, or desktop/database applications. I'm interested in seeing how it works in your summer course.

Our son wrote the Banker game Launch Banker. His prior software experience was MatLab and little bit of HTML. That says a lot about the ease of learning and creating JavaFX applications.

Gail
14 years ago
The design of a JavaFX program is fundamentally different than a Java program (although, in the end, JavaFX is turned into Java).

In our overview chapter, we discuss this difference, which can be called the "scene graph metaphor." In JavaFX, you describe your scene graph (using declarative syntax) by specifying the look and behavior of all of its nodes. Then, your application just "runs." Some applications need input from the user; others just run on their own.

The power of the scene graph is that, not only do you capture the entire structure of your application in a data structure, but you can change the display simply by modifying properties of the objects in the scene graph.

This is the JavaFX-centric description.

JavaFX GUI can be a front-end for a traditional MVC application and any number of design patterns can be applied. In particular, if you have a Java-based middleware/backend system, JavaFX frontend can hook into it seamlessly.

We also spend time in Chapter 6 (Anatomy of a JavaFX Application) discussing how to use object oriented design principles to construct custom nodes.

Gail
14 years ago
Hi Nikes,

Downloading the necessary runtime happens automatically (once) when the page with a JavaFX app loads. So, it is transparent to the user.
14 years ago
Hi Nikes,

Not yet, but Sun is working on an Authoring Tool that was demoed at JavaOne. It looks great!
14 years ago