没有合适的资源?快使用搜索试试~ 我知道了~
首页编程挑战宝典:57实战项目提升技能
编程挑战宝典:57实战项目提升技能
![](https://csdnimg.cn/release/wenkucmsfe/public/img/star.98a08eaa.png)
"《程序员练习册:57个挑战提升你的编程技能》是一本由Brian P. Hogan所著的专业书籍,旨在帮助程序员保持和提高编码技巧。这本书特别强调通过实践来学习编程语言,而非仅仅依赖理论。书中提供了57个基于实际软件开发场景的挑战性练习,适合初学者学习入门编程,同时也为经验丰富的开发者提供快速掌握新语言的学习路径。 书中内容涵盖了从基本的输入输出程序开始,例如货币转换、计算贷款偿还期,到复杂的任务如酒精含量测试、文件操作、网络服务应用等,这些都涉及到实用技能的锻炼。每个问题都有明确的限制和挑战,鼓励读者独立思考并找到解决方案。随着阅读的深入,书中的挑战会逐渐升级,最终引导读者完成几个大型项目,将学到的知识整合运用。 《程序员练习册》的独特之处在于它的语言中立性,无论你是初学者想学习新语言,还是想通过不同的方法解决已知问题的老手,这本书都能提供无限的重复价值。作者巧妙地设计了问题,让读者从基础出发,逐步构建坚实的基础。书中收录的积极评价证实了它的实用性和价值,比如来自高级软件工程师Stephen Orr的赞誉,他认为这本书是学习新语言的最佳资源,对初学者和有经验的程序员都有益处。 这本书是程序员提升技能和保持敏捷思维的重要工具,它不仅提供了丰富的实战练习,还培养了解决实际问题的能力,是任何想要在编程领域不断进步的程序员不可或缺的参考书。无论是为了学习新技术,还是巩固现有技能,都能从中受益匪浅。"
资源详情
资源推荐
![](https://csdnimg.cn/release/download_crawler_static/10887333/bg10.jpg)
ficult to do because it’s not clear why you’re doing them.
That makes them unapproachable, which creates a barrier
to learning.
The problems in this book are simple, real-world problems
that y o u can easily relate to and that will help yo u practice
solving problems with code.
What You Need
All y o u need is your favorite development environment—or
even one you’ve never used. This book is programming-
language agnostic. Pick a language, grab that language’s
reference guide, and dive in. B e warned though; the program-
ming language y o u choose will determine how easy, or dif-
ficult, these programs are. For example, if y o u choose to do
this book with Python or Ruby, then developing graphical
user interfaces won’t be easy. And if y o u choose to use
JavaScript in the browser, then working with external files
and w e b services will be much more complex than with
other languages. Your approach to problems will be much
different if y o u choose a functional programming language
over an object-oriented one. But that’s the real value of these
exercises; they’ll help y o u learn a language and how that
language is different from what you already know.
Y o u should have an Internet connection so y o u can do some
of the programs that use third-party services and participate
in the community for this book.
Online Resources
The book’s website
1
has a discussion forum where y o u can
discuss the book with other developers. Feel free to post
solutions there in your favorite language and discuss your
solutions with other readers. One of the most fascinating
things about programming is how people approach solving
problems differently and how each developer has his or her
own style.
1.
http://pragprog.com/titles/bhwb
report erratum • discuss
How to Use This Book • xv
![](https://csdnimg.cn/release/download_crawler_static/10887333/bg11.jpg)
CHAPTER 1
Turning Problems into Code
If you’re new to programming, y o u may wonder how
experienced developers can look at a problem and turn it
into runnable code. It turns out that writing the actual code
is only a small part of the process. Y o u have to break down
the problem before y o u can solve it. If you’ve ever watched
an experienced programmer, it may look like they just
cracked open their code editor and banged out a solution.
But over the years, they’ve broken down hundreds, if not
thousands, of problems, and they can see patterns. If you’re
just starting out, y o u might not know how to do that. So in
this chapter we’ll look at one w a y to break down problems
and turn them into code. And y o u can use this approach to
conquer the problems in the rest of this book.
Understanding the Problem
One of the best ways to figure out what y o u have to do is to
write it down. If I told y o u that I wanted a tip calculator
application, would that be enough information for y o u to
just go and build one? Probably not. You’d probably have
to ask me a few questions. This is often called gathering
requirements, but I like to think of it as figuring out what
features the program should have.
Think of a few questions y o u could ask me that would let
y o u get a clearer picture of what I want. What do y o u need
to know to build this application?
Got some questions? Great. Here are some y o u might ask:
report erratum • discuss
![](https://csdnimg.cn/release/download_crawler_static/10887333/bg12.jpg)
• What formula do y o u want to use? Can y o u explain how
the tip should be calculated?
• What’s the tip percentage? Is it 15% or should the user
be able to modify it?
• What should the program display on the screen when
it starts?
• What should the program display for its output? Do
y o u want to see the tip and the total or just the total?
Once y o u have the answers to your questions, try writing
out a problem statement that explains exactly what you’re
building. Here’s the problem statement for the program
we’re going to build:
Create a simple tip calculator. The program should prompt
for a bill amount and a tip rate. The program must compute
the tip and then display both the tip and the total amount of
the bill.
Example output:
What is the bill? $200
What is the tip percentage? 15
The tip is $30.00
The total is $230.00
Joe asks:
What do I do with complex
programs?
Break down the large program into smaller features that are
easier to manage. If y o u do that, you’ll have a better chance of
success because each feature can be fleshed out. And most
complex applications out there are composed of many smaller
programs working together. That’s how command-line tools in
Linux work; one program’s output can be another program’s
input.
If you’re ready to open your text editor and hammer out the
code, you’re jumping w a y ahead of yourself. Y o u see, if y o u
don’t take the time to carefully design the program, y o u
might end up with something that works but isn’t good
quality. And unfortunately, it’s very easy for something like
that to get out into the wild. For example, y o u hammer out
Chapter 1. Turning Problems into Code • 2
report erratum • discuss
![](https://csdnimg.cn/release/download_crawler_static/10887333/bg13.jpg)
your program without testing, planning, or documenting it,
and your boss sees it, thinks it’s done, and tells y o u to release
it. Now y o u have untested, unplanned code in production,
and you’ll probably be asked to make changes to it later.
Code that’s poorly designed is very hard to maintain or
extend. So let’s take this tip calculator example and go
through a simple process that will help y o u understand what
you’re supposed to build.
Discovering Inputs, Processes, and
Outputs
Every program has inputs, processes, and outputs, whether
it’s a simple program like this one or a complex application
like Facebook. In fact, large applications are simply a bunch
of smaller programs that communicate. The output of one
program becomes the input of another.
Y o u can ensure that both small and large programs work
well if yo u take the time to clearly state what these inputs,
processes, and outputs are. An easy w a y to do that, if y o u
have a clear problem statement, is to look at the nouns and
verbs in that statement. The nouns end up becoming your
inputs and outputs, and the verbs will be your processes.
Look at the problem statement for our tip calculator:
Create a simple tip calculator. The program should prompt
for a bill amount and a tip rate. The program must compute
the tip and then display both the tip and the total amount of
the bill.
First, look for the nouns. Circle them if y o u like, or just make
a list. Here’s my list:
• bill amount
• tip rate
• tip
• total amount
Now, what about the verbs?
• prompt
• compute
• display
report erratum • discuss
Chapter 1. Turning Problems into Code • 3
![](https://csdnimg.cn/release/download_crawler_static/10887333/bg14.jpg)
So w e know w e have to prompt for inputs, do some calcula-
tions, and display some outputs. By looking at the nouns
and verbs, w e can get an idea of what we’re being asked to
do.
Of course, the problem statement won’t always be clear. For
example, the problem statement says w e need to calculate
the tip, but it then says w e need to display the tip and the
total. It’s implied that we’ll need to also add the tip to the
original bill amount to get that output. And that’s one of the
challenges of building software. It isn’t spelled out to y o u
100% of the time. But as y o u gain more experience, you’ll
be able to fill in the gaps and read between the lines.
So with a little bit of sleuthing, w e determine that our inputs,
processes, and outputs for this program look like this:
• Inputs: bill amount, tip rate
• Processes: calculate the tip
• Outputs: tip amount, total amount
Are w e ready to start producing some code? Not just yet.
Driving Design with Tests
One of the best ways to design and develop software is to
think about the result y o u want to get right from the start.
Many professional software developers do this using a for-
mal process called test-driven development, or TDD. In TDD,
y o u write bits of code that test the outputs of your program
or the outputs of the individual programs that make up a
larger program. This process of testing as y o u go guides y o u
toward good design and helps y o u think about the issues
your program might have.
TDD does require some knowledge about the language
you’re using and a little more experience than the beginning
developer has out of the gate.
However, the essence of TDD is to think about what the
expected result of the program is ahead of time and then
work toward getting there. And if y o u do that before y o u
write code, it’ll make y o u think beyond what the initial
requirements say. So if you’re not quite comfortable doing
formal TDD, y o u can still get many of the benefits by creating
Chapter 1. Turning Problems into Code • 4
report erratum • discuss
剩余113页未读,继续阅读
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://profile-avatar.csdnimg.cn/default.jpg!1)
THESUMMERE
- 粉丝: 23
- 资源: 328
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![](https://csdnimg.cn/release/wenkucmsfe/public/img/voice.245cc511.png)
最新资源
- 解决本地连接丢失无法上网的问题
- BIOS报警声音解析:故障原因与解决方法
- 广义均值移动跟踪算法在视频目标跟踪中的应用研究
- C++Builder快捷键大全:高效编程的秘密武器
- 网页制作入门:常用代码详解
- TX2440A开发板网络远程监控系统移植教程:易搭建与通用解决方案
- WebLogic10虚拟内存配置详解与优化技巧
- C#网络编程深度解析:Socket基础与应用
- 掌握Struts1:Java MVC轻量级框架详解
- 20个必备CSS代码段提升Web开发效率
- CSS样式大全:字体、文本、列表样式详解
- Proteus元件库大全:从基础到高级组件
- 74HC08芯片:高速CMOS四输入与门详细资料
- C#获取当前路径的多种方法详解
- 修复MySQL乱码问题:设置字符集为GB2312
- C语言的诞生与演进:从汇编到系统编程的革命
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![](https://img-home.csdnimg.cn/images/20220527035711.png)
![](https://img-home.csdnimg.cn/images/20220527035711.png)
![](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![](https://csdnimg.cn/release/wenkucmsfe/public/img/green-success.6a4acb44.png)