The representation of custom types in Swift Playgrounds
In Swift (and in most other programming languages), programmers can create their own custom types. When you create a struct or a class you are creating your own custom type. Many useful types are provided to us by the developers of Swift (Int, String, Bool, Double, UIViewController, etc.), but if we want to represent instances of BookReview or of Reviewer, we have to create our own custom type using a struct or a class. BookReview and Reviewer are not standard types provided by the Swift or iOS frameworks.
There are many resources with which students can learn and have fun when learning to code using Swift Playgrounds on the iPad. In some of these resources, students can use custom types and their respective properties and behaviors provided by the authors of the playground books. In Apple’s Learn-to-Code books for example, some of the first functions students use are moveForward(), turnLeft(), collectGem(), etc. These are not functions that are part of the standard Swift language, nor are they part of any of the iOS Frameworks. They are defined in hidden code included with that particular Swift Playground book. Similarly, in another Swift Playground Book on geometry (generously provided by an independent playground book author), a Pen class is defined that can have a lineWidth and inkColor properties, and can move() and drawLine().
Because these Swift types and functionalities are not part of standard Swift, but instead are custom functionality created by the authors of their playground content, there can be confusion by novice programmers when they transition to Xcode to develop their first apps. Which are actual Swift and iOS framework types and which are provided by playground book content authors? This confusion is exacerbated by the ability of Swift Playgrounds to include hidden code as part of their content. Hidden code is a fantastic feature and facilitates student learning by hiding the extraneous and boilerplate code while students focus on what is important – their code. But including hidden code does come with a price in the form of this potential confusion down the road.
We would like to kindly ask the Apple Swift Playgrounds team if it is possible for Swift Playgrounds on iPad to distinguish between standard Swift and iOS frameworks types and custom types that are included by playground book authors. Perhaps a subtle font type, weight and/or size might be enough to identify custom types to students and stave off potential confusion in their future transition to more standard app development.
Our responsibility as Swift Playgrounds users – feedback for Apple
Teachers and students need to foster an open and continuous line of communication with Apple’s Swift Playgrounds developer team. Developers at Apple have spent countless hours planning, developing and testing this incredible tool for educators and students. The results are a tool that has taken interactive learning to the next level. There are very smart and creative people at Apple iterating on this tool, constantly improving the student and teacher experience. But this tool can improve even faster, and in the directions we want, only if we educators participate in the process.
Suggestions and feedback, such as the request for identifying hidden custom types highlighted above, should be passed on to Apple at every opportunity. Fortunately, Apple makes it easy to submit feedback, feature requests and bug reports online (bugreport.apple.com).
We will send our suggestion above to bugreport.apple.com and post links or other updates here so you all can monitor the progress of this feature request. When ideasfor additional features, user interface enhancements, or odd behavior pop into your head, please provide this feedback to Apple. If you don’t have time, send them our way and we will forward on the feedback. As a reward, we teachers and Apple developers will all benefit from this shared responsibility, but most of all our future students will enjoy an even better Swift Playgrounds experience.