Exploring SFML Graphics in C++ – Refactoring Wave 4

The application framework that we have embarked upon has seen a few modifications on the way to a solid basis upon which to build a program. Abstractions were introduced in the last article, Exploring SFML Graphics in C++ – Refactoring Wave 3, that focused on cleaner and clearer ways to represent certain concepts such as windows and views. I have refined this framework to better express the idea of a view. A view is where graphic elements are arranged and contained and there needs to be an approach for defining, introducing and transitioning views. I do not describe that latter objective here but defining and introducing views or, in this case, a single view, is necessary. The information that follows show the progress that has been made in reaching this goal.

This is the final article on this particular series of refinements to the application framework and test program that I have been exploring. First, let’s start with some code.

Continue reading

Exploring SFML Graphics in C++ – Refactoring Wave 3

An incremental revision the application framework is described in this post. After testing out some ideas in terms of a type of scene graph that would work comfortably with the application framework I am building I decided to consolidate and simplify a few areas. First, I needed to migrate towards a more consistent representation of the type system I am setting up. Not so much on paper as in actual code form in C++. What you define in an initial blueprint and what actually works and feels well can differ by a modest measure.

As I proceed along the shaping of the framework I am observing that more effective C++ code trends towards the concept of Resource Acquisition Is Initialization as espoused by the creator of C++. While the RAII technique may be viewed as entirely optional in languages like C#, C, and Java among others, in C++, RAII can be somewhat necessary to have code work well with the language specification. Rather than avoid RAII in favor of more generalized class based OOP, I decided to embrace it more in the context of C++ to streamline the design and function of the program. The remainder of my post documents some of the changes I made that clarifies the program in a more legible and streamlined design. Continue reading