It has been a very long time since I have taken any time to update this site. About half a year ago, the webhoster account I had was somehow hacked and changed, so I basically had to start over completely fresh. I have also been so busy with testing and stuff because my apprenticeship was over… no matter. I have not really been taking care of this site for a long time due to a “rage quit” and life matters.
That being said, I just started a new phase where I am going to be getting to know a new way of programming user interfaces. Up until now, I have been very swing oriented. It just made sense, even if Java gui designs are not the most “up to date” or the coolest or the most windows OS oriented way of doing things. For me in a time where I was new to programming it just made sense because everythings had its object and I used those objects and all was well. It was consistant, fun, confusing, and messy. I liked it.
Now, however, the time has come where I would like to expand my knowlege and get into the Microsoft C# way of doing things. Basically, I found the following two ways to do things: Windows Forms, and Windows Presentation Foundation (WPF). Of the two, WPF is newer and “more exciting”(?).
First off, coming from such a strict language as Java, C# feels like a loose language that does not fully respect the theory of OOP (object oriented programming). And at first glance maybe it is possible to see it that way, but getting deeper into it, I must admit that it is not really so. This, however, is not the point of this article. I want to talk about WPF and Swing.
So lets jump into it and give a brief example of how I would design a main window in Swing. First off, I take a piece of paper, draw out what I want, what should happen, what should be dynamic, what should be static, etc. Then, with an understanding of what layout managers are available, I would draw out the different panels I need and mark out the best way to accomplish my mission with the different managers. In the end, I always tend to use the same Layout Managers: GridBagLayout, BorderLayout, and every once in a while I’d put in a FlowLayout. The GridLayout in my opinion was worthless, and a GridBagLayout took forever to set up and set up well, and then the code was nearly impossible to read afterward, not to mention that a complex layout could be multiple hundred lines of code. Even I, who loves Swing and would most likely want to keep using it, have to admit that something like that is stupid. This is one point where I would say that OOP is great, but there is no reason to be so into the philosophy behind it that I would want to have not only all of the controls, the layout manager and the panels, but also use a GridBagConstraints object to configure the whole thing. It is just too complex and all of this is just because of a bit of philosophy. So lets see how I think WPF makes this just a little better.
The user story is just about the same as Swing, I draw everything out on paper, mark up what I need, the highlighters run out of ink and I need to get some more from the corner store, come back, and before I know it I have a plan. Well, good. What do I do from there? In WPF, Coding forms is “old school”. Of course you can. You can even, due to the “partial class” keyword, even go so far as to have all of the design in one document and all of the actions and stuff in another document. No problem. But that is still not the full power/annoyance/new stuff that WPF has to offer.
Instead of using C# code (that only “real” programmers will know) a form of eXtensible Markup Language (XML) is used to called XAML, eXtensible Application Markup Language. Just the name is pretty cool. It also has the advantage of being written by designers in a text file or other tool without a complex IDE. When I look at a XAML document, I see all of the same sorts of definitions that I would expect to see in the code form of the window: labels, text boxes, column and row definitions, panels and layouts, but I see it in a well organized way without the confusing additions of code to select the right label, or code to set a dynamic color. I just see what I need to see to understand the layout. Then, when I look at the code for the Form or Window, I see the different functions that I need to make it look good.
Now, I am just starting out here, and I am not going to be able to say well how all of this works, but I do plan about writing about my process and hopefully get some good feedback. I am going to, soon, write a short page on how to subscribe to this page in order to write comments, but for now please just write to me at my facebook page and I will get back to you.
Thanks for reading!