官术网_书友最值得收藏!

  • Learning D
  • Michael Parker
  • 568字
  • 2021-07-30 10:13:52

Say hello to MovieMan

Example code and snippets are quite suited to the role they play in a book such as this: highlighting the usage of a language feature in the context of an explanation about that feature. What they aren't ideal for is showing the big picture, or reinforcing how all the disparate language features work together. That role is best played by a sample project that is developed over the course of the book.

In deciding what sort of program to develop as the sample project, I had a few goals in mind. Most importantly, it should be easy for the reader to follow, shouldn't be too time-consuming to implement, shouldn't have any third-party library dependencies, and should serve as a demonstration of as many D features as possible. I finally settled on something that I think fits each requirement to some degree. Few readers will find it immediately useful in its final form, but that's no problem. A practical post-book D project is to modify or extend the sample to tailor it to a specific, customized use case.

The problem

A few months before I started on this book, my wife and I moved house. Though I rarely buy new DVDs these days, I've assembled a modest collection of them over the years. I was more than a little obsessive about keeping them in their original cases, so I kept them lined up on a number of shelves, loosely organized around genre or leading actor/actress. That is just untenable in the long run. They take up too much space and they're a pain to pack when relocating. Even so, I'm reluctant to rip them to cloud storage and throw them all out. Motivated by the move, I bought several multi-disc cases (the kind with a zipper on the outside and several CD/DVD sleeves on the inside) and transferred each disc from its original case into one of the new ones.

This was something I just wanted to get done, so I only made a meager effort to organize the cases. The result is that it's no easy thing to find a particular DVD. Since the move, I've had it in the back of my mind to whip up a program I can use to organize things, but I've continually put it off as it isn't a big priority. This book is the perfect excuse to get it done. So you and I are going to create a program that can allow me to organize my DVDs. I'm going to call it MovieMan (for Movie Manager) because that sounds much better to me than DVDMan.

The features

We're going to develop two versions of the program. In order to keep the size and complexity of the program manageable, the first version will be a command-line program with a limited number of features. The user will be able to:

  • Enter a movie title, a case ID, and a page (sleeve) number
  • Find and display movies by title
  • List all movies in a given case
  • List all movies on a given page of a given case
  • List all movies

We'll implement this first version piece by piece, adding new functionality as we learn about the language features we'll use to implement it. We'll complete the program in Chapter 7, Composing Functional Pipelines with Algorithms and Ranges.

In fairly simple programs that illustrate how several D features work together.

主站蜘蛛池模板: 天等县| 江津市| 兴义市| 湘乡市| 湘西| 孝义市| 威信县| 津南区| 西乌珠穆沁旗| 云南省| 长子县| 溧水县| 安泽县| 霍林郭勒市| 莱芜市| 井冈山市| 江西省| 高邮市| 林州市| 二连浩特市| 额尔古纳市| 太湖县| 江华| 安阳县| 盈江县| 锦州市| 天峨县| 威宁| 沂水县| 山阳县| 吉安市| 和政县| 大连市| 盐边县| 晴隆县| 礼泉县| 祁连县| 丰台区| 汉沽区| 怀柔区| 房产|