A couple months ago I decided to delve into the dark arts that are seemingly only attempted by the bravest of programmers. UI Framework development. While honestly I didn't fully understand what designing and creating a UI Framework from scratch truly entailed, I had some notion that it was no easy feat. As such should be approached with caution if not entirely avoided as the amount of UI Frameworks available are as numerous and the reasons not to make one yourself. But, I decided to embark on the journey anyway..
I guess the first big question you would ask is, Why? Why would you want to do that.
To be honest, I asked myself that very question. The answer I came up with may seem rather shallow and the hallmark of an inexperienced developer..
They all suck.
In *my* personal opinion anyway. Yes, they all suck.
But that seems to be the norm in software development, we work with things that we don't really like because the idea of making the utility they provide ourselves is just as miserable if not more so than using the framework or tool in the first place. Anyway back to why all UI Frameworks suck. From hours and hours of scanning through endless lines of Desktop UI Framework source code repositories, I have come to two major conclusions about most if not all of them.
1: They all do WAY to much and try to handle every single feature, problem, platform, style, you name it. They end up bloated piles of code that seem to have no cohesive structure.
2: Everyone of them seem to have a ridiculous monolithic base Widget class that does EVERYTHING. So when you have a Screen full of Buttons you have all the infrastructure and memory requirements needed if you were to have a Screen full of Windows containing many other Widgets. Wasteful and unnecessary.
To be honest, I can see why these traits are common. UI is complex. It needs to be reusable and flexible enough to fit into any application that wants to utilize it. Doing so in a clean concise manner is no easy task. Its very easy to indulge in the temptation of easiest implementation is the best implementation. After all, people need their UI's in a timely fashion. But what if we didn't do that? What if we really sat down and looked at how a UI operates, what it *needs* to do. What type of general structure would work best for those needs.
This is what I decided to do. I decided that if I was going to make this, I was going to do it right. By my standards anyway.
Next post I intend to go into my thoughts on how UI *should* be. If anyone read this. Thanks, feel free to yell at me in the comments.
"Widget class that does EVERYTHING."
From my own experiences with UI is that the widget class often is just a abstract class or a very limited class. That is to say it does nothing or just keeps track of position and collision, it's function is to group object types into a single group.
How would you replace this?